mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-17 00:42:45 +00:00
validation: remove sentinel block from ConnectTrace
The sentinel pattern was necessary to collect conflicted transactions before their associated block was recorded, but that tracking was removed in 5613f9842b4000fed088b8cf7b99674c328d15e1.
This commit is contained in:
parent
9cad97f6cd
commit
b83de7f28e
@ -2990,39 +2990,24 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
|
||||
struct PerBlockConnectTrace {
|
||||
CBlockIndex* pindex = nullptr;
|
||||
std::shared_ptr<const CBlock> pblock;
|
||||
PerBlockConnectTrace() = default;
|
||||
};
|
||||
/**
|
||||
* Used to track blocks whose transactions were applied to the UTXO state as a
|
||||
* part of a single ActivateBestChainStep call.
|
||||
*
|
||||
* This class is single-use, once you call GetBlocksConnected() you have to throw
|
||||
* it away and make a new one.
|
||||
*/
|
||||
class ConnectTrace {
|
||||
private:
|
||||
std::vector<PerBlockConnectTrace> blocksConnected;
|
||||
|
||||
public:
|
||||
explicit ConnectTrace() : blocksConnected(1) {}
|
||||
|
||||
void BlockConnected(CBlockIndex* pindex, std::shared_ptr<const CBlock> pblock) {
|
||||
assert(!blocksConnected.back().pindex);
|
||||
assert(pindex);
|
||||
assert(pblock);
|
||||
blocksConnected.back().pindex = pindex;
|
||||
blocksConnected.back().pblock = std::move(pblock);
|
||||
blocksConnected.emplace_back();
|
||||
blocksConnected.emplace_back(pindex, std::move(pblock));
|
||||
}
|
||||
|
||||
std::vector<PerBlockConnectTrace>& GetBlocksConnected() {
|
||||
// We always keep one extra block at the end of our list because
|
||||
// blocks are added after all the conflicted transactions have
|
||||
// been filled in. Thus, the last entry should always be an empty
|
||||
// one waiting for the transactions from the next block. We pop
|
||||
// the last entry here to make sure the list we return is sane.
|
||||
assert(!blocksConnected.back().pindex);
|
||||
blocksConnected.pop_back();
|
||||
const std::vector<PerBlockConnectTrace>& GetBlocksConnected() const
|
||||
{
|
||||
return blocksConnected;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user