Browse Source

Avoid duplicate CheckBlock checks

0.13
Pieter Wuille 9 years ago
parent
commit
3b33ec85ed
  1. 6
      src/main.cpp
  2. 4
      src/primitives/block.h

6
src/main.cpp

@ -2587,6 +2587,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
{ {
// These are checks that are independent of context. // These are checks that are independent of context.
if (block.fChecked)
return true;
// Check that the header is valid (particularly PoW). This is mostly // Check that the header is valid (particularly PoW). This is mostly
// redundant with the call in AcceptBlockHeader. // redundant with the call in AcceptBlockHeader.
if (!CheckBlockHeader(block, state, fCheckPOW)) if (!CheckBlockHeader(block, state, fCheckPOW))
@ -2642,6 +2645,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
return state.DoS(100, error("CheckBlock(): out-of-bounds SigOpCount"), return state.DoS(100, error("CheckBlock(): out-of-bounds SigOpCount"),
REJECT_INVALID, "bad-blk-sigops", true); REJECT_INVALID, "bad-blk-sigops", true);
if (fCheckPOW && fCheckMerkleRoot)
block.fChecked = true;
return true; return true;
} }

4
src/primitives/block.h

@ -77,6 +77,9 @@ public:
// network and disk // network and disk
std::vector<CTransaction> vtx; std::vector<CTransaction> vtx;
// memory only
mutable bool fChecked;
CBlock() CBlock()
{ {
SetNull(); SetNull();
@ -100,6 +103,7 @@ public:
{ {
CBlockHeader::SetNull(); CBlockHeader::SetNull();
vtx.clear(); vtx.clear();
fChecked = false;
} }
CBlockHeader GetBlockHeader() const CBlockHeader GetBlockHeader() const

Loading…
Cancel
Save