diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-02-05 11:19:36 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-02-05 11:19:45 +0100 |
commit | e7ea5db0c19085d871cd2d4a12ee98e44849572c (patch) | |
tree | b8daece36f32651076d586b8c33586dd44fe0413 /src | |
parent | cf63d5c710edd1ec6b7a24e3ec5121ec539709b3 (diff) | |
parent | f3757a039196c804f252a4efba294e8f2b4d301d (diff) |
Merge #7459: Consensus: Decouple pow.o from util.o
f3757a0 Consensus: Decouple pow.cpp from util.h (Jorge Timón)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/pow.cpp | 12 |
2 files changed, 5 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp index ecfbf91539..89b4b2930c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2291,8 +2291,9 @@ void static UpdateTip(CBlockIndex *pindexNew) { nTimeBestReceived = GetTime(); mempool.AddTransactionsUpdated(1); - LogPrintf("%s: new best=%s height=%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, + 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(), 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()), Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); diff --git a/src/pow.cpp b/src/pow.cpp index 40c72f9d79..058404f357 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -9,7 +9,6 @@ #include "chain.h" #include "primitives/block.h" #include "uint256.h" -#include "util.h" unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { @@ -57,7 +56,6 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF // Limit adjustment step int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime; - LogPrintf(" nActualTimespan = %d before bounds\n", nActualTimespan); if (nActualTimespan < params.nPowTargetTimespan/4) nActualTimespan = params.nPowTargetTimespan/4; if (nActualTimespan > params.nPowTargetTimespan*4) @@ -75,12 +73,6 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF if (bnNew > bnPowLimit) bnNew = bnPowLimit; - /// debug print - LogPrintf("GetNextWorkRequired RETARGET\n"); - LogPrintf("params.nPowTargetTimespan = %d nActualTimespan = %d\n", params.nPowTargetTimespan, nActualTimespan); - LogPrintf("Before: %08x %s\n", pindexLast->nBits, bnOld.ToString()); - LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.ToString()); - return bnNew.GetCompact(); } @@ -94,11 +86,11 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& // Check range 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 if (UintToArith256(hash) > bnTarget) - return error("CheckProofOfWork(): hash doesn't match nBits"); + return false; return true; } |