Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,073 Lines • ▼ Show 20 Lines | bool CheckBlock(const Config &config, const CBlock &block, | ||||
auto currentBlockSize = | auto currentBlockSize = | ||||
::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); | ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); | ||||
if (currentBlockSize > nMaxBlockSize) { | if (currentBlockSize > nMaxBlockSize) { | ||||
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", false, | return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", false, | ||||
"size limits failed"); | "size limits failed"); | ||||
} | } | ||||
// And a valid coinbase. | // And a valid coinbase. | ||||
if (!CheckCoinbase(*block.vtx[0], state, false)) { | if (!CheckCoinbase(*block.vtx[0], state)) { | ||||
return state.Invalid(false, state.GetRejectCode(), | return state.Invalid(false, state.GetRejectCode(), | ||||
state.GetRejectReason(), | state.GetRejectReason(), | ||||
strprintf("Coinbase check failed (txid %s) %s", | strprintf("Coinbase check failed (txid %s) %s", | ||||
block.vtx[0]->GetId().ToString(), | block.vtx[0]->GetId().ToString(), | ||||
state.GetDebugMessage())); | state.GetDebugMessage())); | ||||
} | } | ||||
// Keep track of the sigops count. | // Keep track of the sigops count. | ||||
Show All 17 Lines | while (true) { | ||||
// Go to the next transaction. | // Go to the next transaction. | ||||
i++; | i++; | ||||
// We reached the end of the block, success. | // We reached the end of the block, success. | ||||
if (i >= txCount) { | if (i >= txCount) { | ||||
break; | break; | ||||
} | } | ||||
// Check that the transaction is valid. because this check differs for | // Check that the transaction is valid. Because this check differs for | ||||
// the coinbase, the loos is arranged such as this only runs after at | // the coinbase, the loop is arranged such as this only runs after at | ||||
// least one increment. | // least one increment. | ||||
tx = block.vtx[i].get(); | tx = block.vtx[i].get(); | ||||
if (!CheckRegularTransaction(*tx, state, false)) { | if (!CheckRegularTransaction(*tx, state, false)) { | ||||
return state.Invalid( | return state.Invalid( | ||||
false, state.GetRejectCode(), state.GetRejectReason(), | false, state.GetRejectCode(), state.GetRejectReason(), | ||||
strprintf("Transaction check failed (txid %s) %s", | strprintf("Transaction check failed (txid %s) %s", | ||||
tx->GetId().ToString(), state.GetDebugMessage())); | tx->GetId().ToString(), state.GetDebugMessage())); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,012 Lines • Show Last 20 Lines |