MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / RollforwardBlock

Method RollforwardBlock

src/validation.cpp:4328–4346  ·  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

4326
4327/** Apply the effects of a block on the utxo cache, ignoring that it may already have been applied. */
4328bool CChainState::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& inputs, const CChainParams& params)
4329{
4330 // TODO: merge with ConnectBlock
4331 CBlock block;
4332 if (!ReadBlockFromDisk(block, pindex, params.GetConsensus())) {
4333 return error("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
4334 }
4335
4336 for (const CTransactionRef& tx : block.vtx) {
4337 if (!tx->IsCoinBase()) {
4338 for (const CTxIn &txin : tx->vin) {
4339 inputs.SpendCoin(txin.prevout);
4340 }
4341 }
4342 // Pass check = true as every addition may be an overwrite.
4343 AddCoins(inputs, *tx, pindex->nHeight, true);
4344 }
4345 return true;
4346}
4347
4348bool CChainState::ReplayBlocks(const CChainParams& params, CCoinsView* view)
4349{

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