-
Notifications
You must be signed in to change notification settings - Fork 32
Merge with Bitmark Project Master #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4e67627
increase hashrate units to GH/s
f2a8fa9
gigawork
5f638d2
fix fork warning conditions
3c65aab
safeguard against low height case
f9edb92
add version command to daemon
c4319dd
fork2: bug fixes
ffb4773
fix type declaration
0c07f93
optimizations
5c0887b
950/1000 required for fork2
bb862b5
Merge branch 'master' into dev
bitmark-protocol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1202,12 +1202,17 @@ bool onFork (const CBlockIndex * pindex) { | |
| return pindex->onFork(); | ||
| } | ||
|
|
||
| bool onFork2(const CBlockIndex * pindex) { | ||
| return pindex->onFork2(); | ||
| } | ||
|
|
||
| int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool noScale) | ||
| { | ||
| // for testnet | ||
| int nHeight = pindex->nHeight; | ||
| bool onForkNow = onFork(pindex); | ||
|
|
||
| if (!onFork(pindex)) { | ||
| if (!onForkNow) { | ||
| int64_t nHalfReward = 10 * COIN; | ||
| int64_t nSubsidy = 0; | ||
| int halvings = nHeight / Params().SubsidyHalvingInterval(); | ||
|
|
@@ -1236,10 +1241,10 @@ int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool noScale) | |
| emitted = NUM_ALGOS * get_mpow_ms_correction(pindex); | ||
| } | ||
|
|
||
| unsigned int scalingFactor = 0; | ||
| if (onFork(pindex) && !noScale) { | ||
| CBigNum scalingFactor = CBigNum(0); | ||
| if (onForkNow && !noScale) { | ||
| scalingFactor = pindex->subsidyScalingFactor; | ||
| if (!scalingFactor) { // find the key block and recalculate | ||
| if (!scalingFactor.getuint()) { // find the key block and recalculate | ||
| CBlockIndex * pprev_algo = pindex; | ||
| do { | ||
| if (update_ssf(pprev_algo->nVersion)) { | ||
|
|
@@ -1549,7 +1554,7 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, int algo) { | |
| if (lastInRow>=9 && !lastInRowMod) { | ||
| bnNew /= 3; | ||
| } | ||
| else if (!justHadSurge) { | ||
| else if (!justHadSurge || smultiply && CBlockIndex::IsSuperMajority(5,pindexLast,75,100)) { | ||
| bnNew *= nActualTimespan; | ||
| bnNew /= _nTargetTimespan; | ||
| } | ||
|
|
@@ -2106,15 +2111,22 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C | |
| // Check it again in case a previous version let a bad block in | ||
| if (!CheckBlock(block, state, !fJustCheck, !fJustCheck)) | ||
| return false; | ||
|
|
||
| bool onForkNow = onFork(pindex); | ||
|
|
||
| // Force min version after fork | ||
| if (onFork(pindex) && block.nVersion<CBlock::CURRENT_VERSION) { | ||
| LogPrintf("nVersion<=2 and after fork\n"); | ||
| if (onForkNow && block.nVersion<4) { | ||
| LogPrintf("version<4 and after fork\n"); | ||
| return false; | ||
| } | ||
|
|
||
| if (onFork2(pindex) && GetBlockVersion(block.nVersion)<5) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential forking change. |
||
| LogPrintf("version<5 and after fork\n"); | ||
| return false; | ||
| } | ||
|
|
||
| // Check SSF | ||
| if (onFork(pindex)) { //new multi algo blocks are identified like this | ||
| if (onForkNow) { //new multi algo blocks are identified like this | ||
| CBlockIndex * pprev_algo = pindex; | ||
| if (update_ssf(pindex->nVersion)) { | ||
| for (int i=0; i<nSSF; i++) { | ||
|
|
@@ -2189,7 +2201,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C | |
| flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; | ||
| } | ||
|
|
||
| if (onFork(pindex)) { | ||
| if (onForkNow) { | ||
| flags |= SCRIPT_VERIFY_DERSIG; | ||
| } | ||
|
|
||
|
|
@@ -2250,7 +2262,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C | |
|
|
||
| CBlockIndex * pprev_algo = 0; | ||
| if (!fJustCheck) pprev_algo = get_pprev_algo(pindex,-1); | ||
| if (!fJustCheck && onFork(pindex)) { // set scaling factor | ||
| if (!fJustCheck && onForkNow) { // set scaling factor | ||
| if (update_ssf(pindex->nVersion)) { | ||
| pindex->subsidyScalingFactor = get_ssf(pindex); | ||
| } | ||
|
|
@@ -2264,7 +2276,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C | |
| if (block.vtx[0].GetValueOut() > block_value_needed) | ||
| return state.DoS(100, | ||
| error("ConnectBlock() : coinbase pays too much (actual=%d vs limit=%d)", | ||
| block.vtx[0].GetValueOut(), GetBlockValue(pindex, nFees, false)), | ||
| block.vtx[0].GetValueOut(), block_value_needed), | ||
| REJECT_INVALID, "bad-cb-amount"); | ||
|
|
||
| if (block.vtx[0].GetValueOut() < block_value_needed) { | ||
|
|
@@ -2282,7 +2294,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C | |
|
|
||
| // Increment the nMoneySupply to include this blocks subsidy | ||
|
|
||
| if (onFork(pindex)) { | ||
| if (onForkNow) { | ||
| if (pprev_algo) { | ||
| pindex->nMoneySupply = pprev_algo->nMoneySupply + block.vtx[0].GetValueOut() - nFees; | ||
| } | ||
|
|
@@ -4956,8 +4968,8 @@ bool update_ssf (int nVersion) { | |
| return nVersion & BLOCK_VERSION_UPDATE_SSF; | ||
| } | ||
|
|
||
| unsigned int get_ssf (CBlockIndex * pindex) { | ||
| unsigned int scalingFactor = 0; // ensures that it has no effect | ||
| CBigNum get_ssf (CBlockIndex * pindex) { | ||
| CBigNum scalingFactor = CBigNum(0); // ensures that it has no effect | ||
| CBlockIndex * pprev_algo = pindex; | ||
| CBigNum hashes_peak = CBigNum(0); | ||
| CBigNum hashes_cur = CBigNum(0); | ||
|
|
@@ -5004,7 +5016,12 @@ unsigned int get_ssf (CBlockIndex * pindex) { | |
| if (i==0) hashes_cur = hashes; | ||
| } | ||
| if (hashes_peak > CBigNum(0) && hashes_cur != hashes_peak) { | ||
| scalingFactor = ((100000000*hashes_peak)/(hashes_peak-hashes_cur)).getuint(); // a 9-10 digit integer | ||
| if (onFork2(pindex)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forking change. |
||
| scalingFactor = (100000000*hashes_peak)/(hashes_peak-hashes_cur); | ||
| } | ||
| else { | ||
| scalingFactor = CBigNum(((100000000*hashes_peak)/(hashes_peak-hashes_cur)).getuint()); | ||
| } | ||
| } | ||
| //LogPrintf("return scaling factor %lu\n",scalingFactor); | ||
| return scalingFactor; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is forking change.