-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from RavenProject/dwg-sync-fix
Dwg sync fix
- Loading branch information
Showing
4 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
#include "uint256.h" | ||
#include "util.h" | ||
#include "validation.h" | ||
#include "chainparams.h" | ||
#include "tinyformat.h" | ||
|
||
unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { | ||
/* current difficulty formula, dash - DarkGravity v3, written by Evan Duffield - [email protected] */ | ||
|
@@ -123,16 +125,19 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead | |
int dgw = DarkGravityWave(pindexLast, pblock, params); | ||
int btc = GetNextWorkRequiredBTC(pindexLast, pblock, params); | ||
int64_t nPrevBlockTime = (pindexLast->pprev ? pindexLast->pprev->GetBlockTime() : pindexLast->GetBlockTime()); | ||
if (AreAssetsDeployed()) { | ||
LogPrintf("Block %s: found next work required using DGW: [%s] (BTC would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", | ||
pindexLast->nHeight, dgw, btc, btc - dgw, (float)(btc - dgw) * 100.0 / (float)dgw, pindexLast->GetBlockTime() - nPrevBlockTime); | ||
|
||
int version = (pblock->nVersion & 0xF0000000) >> 28; | ||
if (version >= 3 && !CheckPOWHeightAssets(pindexLast->nHeight + 1)) { | ||
LogPrint(BCLog::NET, "Block %s - version: %s: found next work required using DGW: [%s] (BTC would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", | ||
pindexLast->nHeight, pblock->nVersion, dgw, btc, btc - dgw, (float)(btc - dgw) * 100.0 / (float)dgw, pindexLast->GetBlockTime() - nPrevBlockTime); | ||
return dgw; | ||
} | ||
else { | ||
LogPrintf("Block %s: found next work required using BTC: [%s] (DGW would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", | ||
pindexLast->nHeight, btc, dgw, dgw - btc, (float)(dgw - btc) * 100.0 / (float)btc, pindexLast->GetBlockTime() - nPrevBlockTime); | ||
LogPrint(BCLog::NET, "Block %s - version: %s: found next work required using BTC: [%s] (DGW would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", | ||
pindexLast->nHeight, pblock->nVersion, btc, dgw, dgw - btc, (float)(dgw - btc) * 100.0 / (float)btc, pindexLast->GetBlockTime() - nPrevBlockTime); | ||
return btc; | ||
} | ||
|
||
} | ||
|
||
unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params) | ||
|
@@ -178,3 +183,25 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& | |
|
||
return true; | ||
} | ||
|
||
// Used to determine if one of these block heights is failing the check because these were mined with block version of 3 before RIP2 was active. | ||
bool CheckPOWHeightAssets(const int height) | ||
{ | ||
if (Params().NetworkIDString() == "test") { | ||
return (height == 319456 || | ||
height == 319468 || | ||
height == 319469 || | ||
height == 319494 || | ||
height == 319500 || | ||
height == 319501 || | ||
height == 319502 || | ||
height == 319520 || | ||
height == 319522 || | ||
height == 319532 || | ||
height == 319533); | ||
} else { | ||
return false; | ||
} | ||
|
||
|
||
} |
This file contains 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 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