Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | static bool AcceptToMemoryPoolWorker( | ||||
// mempool "read lock" (held through | // mempool "read lock" (held through | ||||
// GetMainSignals().TransactionAddedToMempool()) | // GetMainSignals().TransactionAddedToMempool()) | ||||
LOCK(pool.cs); | LOCK(pool.cs); | ||||
if (pfMissingInputs) { | if (pfMissingInputs) { | ||||
*pfMissingInputs = false; | *pfMissingInputs = false; | ||||
} | } | ||||
// Coinbase is only valid in a block, not as a loose transaction. | // Coinbase is only valid in a block, not as a loose transaction. | ||||
if (!CheckRegularTransaction(tx, state, true)) { | if (!CheckRegularTransaction(tx, state)) { | ||||
// state filled in by CheckRegularTransaction. | // state filled in by CheckRegularTransaction. | ||||
return false; | return false; | ||||
} | } | ||||
// Rather not work on nonstandard transactions (unless -testnet/-regtest) | // Rather not work on nonstandard transactions (unless -testnet/-regtest) | ||||
std::string reason; | std::string reason; | ||||
if (fRequireStandard && !IsStandardTx(tx, reason)) { | if (fRequireStandard && !IsStandardTx(tx, reason)) { | ||||
return state.DoS(0, false, REJECT_NONSTANDARD, reason); | return state.DoS(0, false, REJECT_NONSTANDARD, reason); | ||||
▲ Show 20 Lines • Show All 2,676 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)) { | ||||
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())); | ||||
} | } | ||||
} | } | ||||
if (validationOptions.shouldValidatePoW() && | if (validationOptions.shouldValidatePoW() && | ||||
▲ Show 20 Lines • Show All 2,009 Lines • Show Last 20 Lines |