diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-05-09 16:00:32 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-05-09 16:00:41 +0200 |
commit | d54985f3f1385481696dbc53bce4aa3c0205a597 (patch) | |
tree | 12a7546b0c70170b77a4e0d4d831e92197d113a6 /src/main.h | |
parent | aaab675a78378c8f087639b24feba10f0e25630f (diff) | |
parent | 942b33a19d3aa96326acc044c1834c48beff777c (diff) |
Merge pull request #3884
942b33a Split AcceptBlockHeader from AcceptBlock. (Pieter Wuille)
f457347 Split up CheckBlock in a block and header version (Pieter Wuille)
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main.h b/src/main.h index 825e577d1e..f63f4d5f11 100644 --- a/src/main.h +++ b/src/main.h @@ -603,11 +603,13 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos& pos); // Context-independent validity checks +bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true); bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true); // Store block on disk // if dbp is provided, the file is known to already reside on disk -bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp = NULL); +bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex **pindex, CDiskBlockPos* dbp = NULL); +bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL); @@ -865,6 +867,29 @@ public: { LogPrintf("%s\n", ToString().c_str()); } + + // Check whether this block index entry is valid up to the passed validity level. + bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const + { + assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed. + if (nStatus & BLOCK_FAILED_MASK) + return false; + return ((nStatus & BLOCK_VALID_MASK) >= nUpTo); + } + + // Raise the validity level of this block index entry. + // Returns true if the validity was changed. + bool RaiseValidity(enum BlockStatus nUpTo) + { + assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed. + if (nStatus & BLOCK_FAILED_MASK) + return false; + if ((nStatus & BLOCK_VALID_MASK) < nUpTo) { + nStatus = (nStatus & ~BLOCK_VALID_MASK) | nUpTo; + return true; + } + return false; + } }; |