Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
752auto [chunk_entries, chunk_feerate] = *res;753for (TxGraph::Ref* ref : chunk_entries) {754entries.emplace_back(static_cast<const CTxMemPoolEntry&>(*ref));755}756return chunk_feerate;757}758void IncludeBuilderChunk() const EXCLUSIVE_LOCKS_REQUIRED(cs) { m_builder->Include(); }759void SkipBuilderChunk() const EXCLUSIVE_LOCKS_REQUIRED(cs) { m_builder->Skip(); }760void StopBlockBuilding() const EXCLUSIVE_LOCKS_REQUIRED(cs) { m_builder.reset(); }761};763/**764* CCoinsView that brings transactions from a mempool into view.765* It does not check for spendings by memory pool transactions.766* Instead, it provides access to all Coins which are either unspent in the767* base CCoinsView, are outputs from any mempool transaction, or are768* tracked temporarily to allow transaction dependencies in package validation.769* This allows transaction replacement to work as expected, as you want to770* have all inputs "available" to check signatures, and any cycles in the771* dependency graph are checked directly in AcceptToMemoryPool.772* It also allows you to sign a double-spend directly in773* signrawtransactionwithkey and signrawtransactionwithwallet,774* as long as the conflicting transaction is not yet confirmed.775*/776class CCoinsViewMemPool : public CCoinsViewBacked777{778/**779* Coins made available by transactions being validated. Tracking these allows for package780* validation, since we can access transaction outputs without submitting them to mempool.781*/782std::unordered_map<COutPoint, Coin, SaltedOutpointHasher> m_temp_added;784/**785* Set of all coins that have been fetched from mempool or created using PackageAddTransaction786* (not base). Used to track the origin of a coin, see GetNonBaseCoins().787*/788mutable std::unordered_set<COutPoint, SaltedOutpointHasher> m_non_base_coins;789protected:790const CTxMemPool& mempool;792public:793CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn);794/** GetCoin, returning whether it exists and is not spent. Also updates m_non_base_coins if the795* coin is not fetched from base. May populate the base view on cache misses. */796std::optional<Coin> GetCoin(const COutPoint& outpoint) const override;797/** Add the coins created by this transaction. These coins are only temporarily stored in798* m_temp_added and cannot be flushed to the back end. Only used for package validation. */799void PackageAddTransaction(const CTransactionRef& tx);800/** Get all coins in m_non_base_coins. */801const std::unordered_set<COutPoint, SaltedOutpointHasher>& GetNonBaseCoins() const { return m_non_base_coins; }802/** Clear m_temp_added and m_non_base_coins. */803void Reset();804};805#endif // BITCOIN_TXMEMPOOL_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.