MCPcopy Create free account
hub / github.com/ElementsProject/elements / RollforwardBlock

Method RollforwardBlock

src/validation.cpp:4420–4439  ·  view source on GitHub ↗

Apply the effects of a block on the utxo cache, ignoring that it may already have been applied. */

Source from the content-addressed store, hash-verified

4418
4419/** Apply the effects of a block on the utxo cache, ignoring that it may already have been applied. */
4420bool CChainState::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& inputs)
4421{
4422 AssertLockHeld(cs_main);
4423 // TODO: merge with ConnectBlock
4424 CBlock block;
4425 if (!ReadBlockFromDisk(block, pindex, m_params.GetConsensus())) {
4426 return error("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
4427 }
4428
4429 for (const CTransactionRef& tx : block.vtx) {
4430 if (!tx->IsCoinBase()) {
4431 for (const CTxIn &txin : tx->vin) {
4432 inputs.SpendCoin(txin.prevout);
4433 }
4434 }
4435 // Pass check = true as every addition may be an overwrite.
4436 AddCoins(inputs, *tx, pindex->nHeight, true);
4437 }
4438 return true;
4439}
4440
4441bool CChainState::ReplayBlocks()
4442{

Callers

nothing calls this directly

Calls 7

ReadBlockFromDiskFunction · 0.85
errorFunction · 0.85
AddCoinsFunction · 0.85
SpendCoinMethod · 0.80
ToStringMethod · 0.45
GetBlockHashMethod · 0.45
IsCoinBaseMethod · 0.45

Tested by

no test coverage detected