Auto merge of #4165 - oxarbitrage:issue4029, r=mdr0id
Remove CheckProofOfWork errors from logs To fix https://github.com/zcash/zcash/issues/4029 bitcoin patch(https://github.com/bitcoin/bitcoin/pull/7459) was ported.
This commit is contained in:
commit
173d6a7c18
|
@ -3105,8 +3105,9 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
|
||||||
nTimeBestReceived = GetTime();
|
nTimeBestReceived = GetTime();
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
|
|
||||||
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
LogPrintf("%s: new best=%s height=%d bits=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
||||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nBits,
|
||||||
|
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
||||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
||||||
Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||||
|
|
||||||
|
|
13
src/pow.cpp
13
src/pow.cpp
|
@ -12,7 +12,6 @@
|
||||||
#include "primitives/block.h"
|
#include "primitives/block.h"
|
||||||
#include "streams.h"
|
#include "streams.h"
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include "sodium.h"
|
#include "sodium.h"
|
||||||
|
|
||||||
|
@ -71,9 +70,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||||
// Limit adjustment step
|
// Limit adjustment step
|
||||||
// Use medians to prevent time-warp attacks
|
// Use medians to prevent time-warp attacks
|
||||||
int64_t nActualTimespan = nLastBlockTime - nFirstBlockTime;
|
int64_t nActualTimespan = nLastBlockTime - nFirstBlockTime;
|
||||||
LogPrint("pow", " nActualTimespan = %d before dampening\n", nActualTimespan);
|
|
||||||
nActualTimespan = averagingWindowTimespan + (nActualTimespan - averagingWindowTimespan)/4;
|
nActualTimespan = averagingWindowTimespan + (nActualTimespan - averagingWindowTimespan)/4;
|
||||||
LogPrint("pow", " nActualTimespan = %d before bounds\n", nActualTimespan);
|
|
||||||
|
|
||||||
if (nActualTimespan < minActualTimespan) {
|
if (nActualTimespan < minActualTimespan) {
|
||||||
nActualTimespan = minActualTimespan;
|
nActualTimespan = minActualTimespan;
|
||||||
|
@ -92,12 +89,6 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||||
bnNew = bnPowLimit;
|
bnNew = bnPowLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// debug print
|
|
||||||
LogPrint("pow", "GetNextWorkRequired RETARGET\n");
|
|
||||||
LogPrint("pow", "params.AveragingWindowTimespan(%d) = %d nActualTimespan = %d\n", nextHeight, averagingWindowTimespan, nActualTimespan);
|
|
||||||
LogPrint("pow", "Current average: %08x %s\n", bnAvg.GetCompact(), bnAvg.ToString());
|
|
||||||
LogPrint("pow", "After: %08x %s\n", bnNew.GetCompact(), bnNew.ToString());
|
|
||||||
|
|
||||||
return bnNew.GetCompact();
|
return bnNew.GetCompact();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,11 +129,11 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&
|
||||||
|
|
||||||
// Check range
|
// Check range
|
||||||
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit))
|
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit))
|
||||||
return error("CheckProofOfWork(): nBits below minimum work");
|
return false;
|
||||||
|
|
||||||
// Check proof of work matches claimed amount
|
// Check proof of work matches claimed amount
|
||||||
if (UintToArith256(hash) > bnTarget)
|
if (UintToArith256(hash) > bnTarget)
|
||||||
return error("CheckProofOfWork(): hash doesn't match nBits");
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue