mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Make adjusted time type safe
This commit is contained in:
@@ -3442,7 +3442,7 @@ std::vector<unsigned char> ChainstateManager::GenerateCoinbaseCommitment(CBlock&
|
||||
* in ConnectBlock().
|
||||
* Note that -reindex-chainstate skips the validation that happens here!
|
||||
*/
|
||||
static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const ChainstateManager& chainman, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const ChainstateManager& chainman, const CBlockIndex* pindexPrev, NodeClock::time_point now) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
assert(pindexPrev != nullptr);
|
||||
@@ -3470,8 +3470,9 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "time-too-old", "block's timestamp is too early");
|
||||
|
||||
// Check timestamp
|
||||
if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME)
|
||||
if (block.Time() > now + std::chrono::seconds{MAX_FUTURE_BLOCK_TIME}) {
|
||||
return state.Invalid(BlockValidationResult::BLOCK_TIME_FUTURE, "time-too-new", "block timestamp too far in the future");
|
||||
}
|
||||
|
||||
// Reject blocks with outdated version
|
||||
if ((block.nVersion < 2 && DeploymentActiveAfter(pindexPrev, chainman, Consensus::DEPLOYMENT_HEIGHTINCB)) ||
|
||||
@@ -3832,7 +3833,7 @@ bool TestBlockValidity(BlockValidationState& state,
|
||||
CChainState& chainstate,
|
||||
const CBlock& block,
|
||||
CBlockIndex* pindexPrev,
|
||||
const std::function<int64_t()>& adjusted_time_callback,
|
||||
const std::function<NodeClock::time_point()>& adjusted_time_callback,
|
||||
bool fCheckPOW,
|
||||
bool fCheckMerkleRoot)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user