diff options
| author | Pieter Wuille <[email protected]> | 2014-03-11 17:36:21 +0100 |
|---|---|---|
| committer | langerhans <[email protected]> | 2014-05-29 20:14:00 +0200 |
| commit | 4340df89600d4a73209b2f4d6dd3af02e6c33c11 (patch) | |
| tree | b42b88454004abe67f50ec381966771799e1d4ec /src/main.cpp | |
| parent | Revision in OS X plist (diff) | |
| download | discoin-4340df89600d4a73209b2f4d6dd3af02e6c33c11.tar.xz discoin-4340df89600d4a73209b2f4d6dd3af02e6c33c11.zip | |
Split up CheckBlock in a block and header version
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/main.cpp b/src/main.cpp index db08f63e7..3cf4aab5d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2393,16 +2393,8 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne } -bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot) +bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW) { - // These are checks that are independent of context - // that can be verified before saving an orphan block. - - // Size limits - if (block.vtx.empty() || block.vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) - return state.DoS(100, error("CheckBlock() : size limits failed"), - REJECT_INVALID, "bad-blk-length"); - // Check proof of work matches claimed amount if (fCheckPOW && !CheckProofOfWork(block.GetPoWHash(), block.nBits)) return state.DoS(50, error("CheckBlock() : proof of work failed"), @@ -2413,6 +2405,22 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo return state.Invalid(error("CheckBlock() : block timestamp too far in the future"), REJECT_INVALID, "time-too-new"); + return true; +} + +bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot) +{ + // These are checks that are independent of context + // that can be verified before saving an orphan block. + + if (!CheckBlockHeader(block, state, fCheckPOW)) + return false; + + // Size limits + if (block.vtx.empty() || block.vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) + return state.DoS(100, error("CheckBlock() : size limits failed"), + REJECT_INVALID, "bad-blk-length"); + // First transaction must be coinbase, the rest must not be if (block.vtx.empty() || !block.vtx[0].IsCoinBase()) return state.DoS(100, error("CheckBlock() : first tx is not coinbase"), |