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

Class ConnectTrace

src/validation.cpp:2870–2896  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

2868 * it away and make a new one.
2869 */
2870class ConnectTrace {
2871private:
2872 std::vector<PerBlockConnectTrace> blocksConnected;
2873
2874public:
2875 explicit ConnectTrace() : blocksConnected(1) {}
2876
2877 void BlockConnected(CBlockIndex* pindex, std::shared_ptr<const CBlock> pblock) {
2878 assert(!blocksConnected.back().pindex);
2879 assert(pindex);
2880 assert(pblock);
2881 blocksConnected.back().pindex = pindex;
2882 blocksConnected.back().pblock = std::move(pblock);
2883 blocksConnected.emplace_back();
2884 }
2885
2886 std::vector<PerBlockConnectTrace>& GetBlocksConnected() {
2887 // We always keep one extra block at the end of our list because
2888 // blocks are added after all the conflicted transactions have
2889 // been filled in. Thus, the last entry should always be an empty
2890 // one waiting for the transactions from the next block. We pop
2891 // the last entry here to make sure the list we return is sane.
2892 assert(!blocksConnected.back().pindex);
2893 blocksConnected.pop_back();
2894 return blocksConnected;
2895 }
2896};
2897
2898/**
2899 * Connect a new block to m_chain. pblock is either nullptr or a pointer to a CBlock

Callers

nothing calls this directly

Calls 1

pop_backMethod · 0.45

Tested by

no test coverage detected