mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Merge pull request #4377
654871dreplace ComputeMinWork with CheckMinWork (jtimon)b343c1aMove CBlockIndex::GetBlockWork() to pow::GetProofIncrement(nBits) (jtimon)c2c02f3Move UpdateTime to pow (jtimon)
This commit is contained in:
35
src/main.cpp
35
src/main.cpp
@@ -1420,25 +1420,6 @@ void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev)
|
||||
{
|
||||
block.nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||
|
||||
// Updating time can change work required on testnet:
|
||||
if (Params().AllowMinDifficultyBlocks())
|
||||
block.nBits = GetNextWorkRequired(pindexPrev, &block);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
|
||||
{
|
||||
bool ret;
|
||||
@@ -2435,12 +2416,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
|
||||
return state.DoS(100, error("CheckBlockHeader() : block with timestamp before last checkpoint"),
|
||||
REJECT_CHECKPOINT, "time-too-old");
|
||||
}
|
||||
bool fOverflow = false;
|
||||
uint256 bnNewBlock;
|
||||
bnNewBlock.SetCompact(block.nBits, NULL, &fOverflow);
|
||||
uint256 bnRequired;
|
||||
bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime));
|
||||
if (fOverflow || bnNewBlock > bnRequired)
|
||||
if (!CheckMinWork(block.nBits, pcheckpoint->nBits, deltaTime))
|
||||
{
|
||||
return state.DoS(100, error("CheckBlockHeader() : block with too little proof-of-work"),
|
||||
REJECT_INVALID, "bad-diffbits");
|
||||
@@ -3297,15 +3273,6 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
||||
return nLoaded > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CAlert
|
||||
|
||||
Reference in New Issue
Block a user