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

Method ReceivedBlockTransactions

src/validation.cpp:3516–3558  ·  view source on GitHub ↗

Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */

Source from the content-addressed store, hash-verified

3514
3515/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */
3516void CChainState::ReceivedBlockTransactions(const CBlock& block, CBlockIndex* pindexNew, const FlatFilePos& pos)
3517{
3518 AssertLockHeld(cs_main);
3519 pindexNew->nTx = block.vtx.size();
3520 pindexNew->nChainTx = 0;
3521 pindexNew->nFile = pos.nFile;
3522 pindexNew->nDataPos = pos.nPos;
3523 pindexNew->nUndoPos = 0;
3524 pindexNew->nStatus |= BLOCK_HAVE_DATA;
3525 if (DeploymentActiveAt(*pindexNew, m_params.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) {
3526 pindexNew->nStatus |= BLOCK_OPT_WITNESS;
3527 }
3528 pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
3529 m_blockman.m_dirty_blockindex.insert(pindexNew);
3530
3531 if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveTxsDownloaded()) {
3532 // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
3533 std::deque<CBlockIndex*> queue;
3534 queue.push_back(pindexNew);
3535
3536 // Recursively process any descendant blocks that now may be eligible to be connected.
3537 while (!queue.empty()) {
3538 CBlockIndex *pindex = queue.front();
3539 queue.pop_front();
3540 pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
3541 pindex->nSequenceId = nBlockSequenceId++;
3542 if (m_chain.Tip() == nullptr || !setBlockIndexCandidates.value_comp()(pindex, m_chain.Tip())) {
3543 setBlockIndexCandidates.insert(pindex);
3544 }
3545 std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = m_blockman.m_blocks_unlinked.equal_range(pindex);
3546 while (range.first != range.second) {
3547 std::multimap<CBlockIndex*, CBlockIndex*>::iterator it = range.first;
3548 queue.push_back(it->second);
3549 range.first++;
3550 m_blockman.m_blocks_unlinked.erase(it);
3551 }
3552 }
3553 } else {
3554 if (pindexNew->pprev && pindexNew->pprev->IsValid(BLOCK_VALID_TREE)) {
3555 m_blockman.m_blocks_unlinked.insert(std::make_pair(pindexNew->pprev, pindexNew));
3556 }
3557 }
3558}
3559
3560static bool CheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true)
3561{

Callers

nothing calls this directly

Calls 9

DeploymentActiveAtFunction · 0.85
HaveTxsDownloadedMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
TipMethod · 0.45
eraseMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected