MCPcopy Create free account
hub / github.com/LUX-Core/lux / ReceivedBlockTransactions

Function ReceivedBlockTransactions

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

4143
4144/** Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). */
4145bool ReceivedBlockTransactions(const CBlock& block, CValidationState& state, CBlockIndex* pindexNew, const CDiskBlockPos& pos)
4146{
4147 if (block.IsProofOfStake())
4148 pindexNew->SetProofOfStake();
4149 pindexNew->nTx = block.vtx.size();
4150 pindexNew->nChainTx = 0;
4151 pindexNew->nFile = pos.nFile;
4152 pindexNew->nDataPos = pos.nPos;
4153 pindexNew->nUndoPos = 0;
4154 pindexNew->nStatus |= BLOCK_HAVE_DATA;
4155 if (IsWitnessEnabled(pindexNew->pprev, Params().GetConsensus())) {
4156 pindexNew->nStatus |= BLOCK_OPT_WITNESS;
4157 }
4158 pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
4159 setDirtyBlockIndex.insert(pindexNew);
4160
4161 if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) {
4162 // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
4163 deque<CBlockIndex*> queue;
4164 queue.push_back(pindexNew);
4165
4166 // Recursively process any descendant blocks that now may be eligible to be connected.
4167 while (!queue.empty()) {
4168 CBlockIndex* pindex = queue.front();
4169 queue.pop_front();
4170 pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
4171 {
4172 LOCK(cs_nBlockSequenceId);
4173 pindex->nSequenceId = nBlockSequenceId++;
4174 }
4175 if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pindex, chainActive.Tip())) {
4176 setBlockIndexCandidates.insert(pindex);
4177 }
4178 std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap<CBlockIndex*, CBlockIndex*>::iterator> range = mapBlocksUnlinked.equal_range(pindex);
4179 while (range.first != range.second) {
4180 std::multimap<CBlockIndex*, CBlockIndex*>::iterator it = range.first;
4181 queue.push_back(it->second);
4182 range.first++;
4183 mapBlocksUnlinked.erase(it);
4184 }
4185 }
4186 } else {
4187 if (pindexNew->pprev && pindexNew->pprev->IsValid(BLOCK_VALID_TREE)) {
4188 mapBlocksUnlinked.insert(std::make_pair(pindexNew->pprev, pindexNew));
4189 }
4190 }
4191
4192 return true;
4193}
4194
4195bool FindBlockPos(CValidationState& state, CDiskBlockPos& pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false)
4196{

Callers 2

AcceptBlockFunction · 0.85
InitBlockIndexFunction · 0.85

Calls 13

IsWitnessEnabledFunction · 0.85
SetProofOfStakeMethod · 0.80
RaiseValidityMethod · 0.80
TipMethod · 0.80
ParamsClass · 0.70
IsProofOfStakeMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
equal_rangeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected