diff --git a/src/chain.h b/src/chain.h --- a/src/chain.h +++ b/src/chain.h @@ -233,6 +233,9 @@ uint32_t nBits; uint32_t nNonce; + //! (memory only) block header metadata + uint64_t nTimeReceived; + //! (memory only) Sequential id assigned to distinguish order in which //! blocks are received. int32_t nSequenceId; @@ -258,6 +261,7 @@ nVersion = 0; hashMerkleRoot = uint256(); nTime = 0; + nTimeReceived = 0; nBits = 0; nNonce = 0; } @@ -311,6 +315,14 @@ int64_t GetBlockTimeMax() const { return int64_t(nTimeMax); } + int64_t GetHeaderTimeReceived() const { + // Default to GetBlockTime() if nTimeReceived is not set, which + // in effect assumes that this block is honestly mined. + // Note that nTimeReceived isn't written to disk, so blocks read from + // disk will be assumed to be honestly mined. + return nTimeReceived ? nTimeReceived : GetBlockTime(); + } + enum { nMedianTimeSpan = 11 }; int64_t GetMedianTimePast() const {