MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / ReceivedBlockTransactions

Function ReceivedBlockTransactions

src/main.cpp:3154–3199  ·  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

3152
3153/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */
3154bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos)
3155{
3156 pindexNew->nTx = block.vtx.size();
3157 pindexNew->nChainTx = 0;
3158 pindexNew->nFile = pos.nFile;
3159 pindexNew->nDataPos = pos.nPos;
3160 pindexNew->nUndoPos = 0;
3161 pindexNew->nMaxBlockSizeVote = GetMaxBlockSizeVote(block.vtx[0].vin[0].scriptSig, pindexNew->nHeight);
3162 pindexNew->nStatus |= BLOCK_HAVE_DATA;
3163 pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
3164 setDirtyBlockIndex.insert(pindexNew);
3165
3166 if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) {
3167 // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
3168 deque<CBlockIndex*> queue;
3169 queue.push_back(pindexNew);
3170
3171 // Recursively process any descendant blocks that now may be eligible to be connected.
3172 while (!queue.empty()) {
3173 CBlockIndex *pindex = queue.front();
3174 queue.pop_front();
3175 pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
3176 {
3177 LOCK(cs_nBlockSequenceId);
3178 pindex->nSequenceId = nBlockSequenceId++;
3179 }
3180 pindex->nMaxBlockSize = GetNextMaxBlockSize(pindex->pprev, Params().GetConsensus());
3181 if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pindex, chainActive.Tip())) {
3182 setBlockIndexCandidates.insert(pindex);
3183 }
3184 std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex);
3185 while (range.first != range.second) {
3186 std::multimap<CBlockIndex*, CBlockIndex*>::iterator it = range.first;
3187 queue.push_back(it->second);
3188 range.first++;
3189 mapBlocksUnlinked.erase(it);
3190 }
3191 }
3192 } else {
3193 if (pindexNew->pprev && pindexNew->pprev->IsValid(BLOCK_VALID_TREE)) {
3194 mapBlocksUnlinked.insert(std::make_pair(pindexNew->pprev, pindexNew));
3195 }
3196 }
3197
3198 return true;
3199}
3200
3201bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false)
3202{

Callers 2

AcceptBlockFunction · 0.85
InitBlockIndexFunction · 0.85

Calls 11

GetMaxBlockSizeVoteFunction · 0.85
GetNextMaxBlockSizeFunction · 0.85
RaiseValidityMethod · 0.80
ParamsClass · 0.70
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