GetBlockWorkAdjusted fix

This commit is contained in:
myriadcoin
2015-07-12 16:12:59 +02:00
parent 15a341c28d
commit e3fb0ff772
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -1732,8 +1732,8 @@ void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev)
block.nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
// Updating time can change work required on testnet:
if (TestNet())
block.nBits = GetNextWorkRequired(pindexPrev, &block, block.GetAlgo());
//if (TestNet())
// block.nBits = GetNextWorkRequired(pindexPrev, &block, block.GetAlgo());
}
@@ -2668,6 +2668,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, int nHeight, bool
bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
{
LogPrintf("AcceptBlock: BlockTime=%d\n", block.nTime);
AssertLockHeld(cs_main);
// Check for duplicate
uint256 hash = block.GetHash();
+2 -1
View File
@@ -964,7 +964,7 @@ public:
CBigNum GetBlockWorkAdjusted() const
{
CBigNum bnRes;
if ((TestNet() && (nHeight > 500)) ||
if ((TestNet() && (nHeight > 50)) ||
(nHeight >= GeoAvgWork_Start))
{
CBigNum nBlockWork = GetBlockWork();
@@ -978,6 +978,7 @@ public:
nBlockWork *= nBlockWorkAlt;
}
}
bnRes = nBlockWork;
// Compute the geometric mean
bnRes = bnRes.nthRoot(NUM_ALGOS);
// Scale to roughly match the old work calculation