Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 913 Lines • ▼ Show 20 Lines | bool visited(std::optional<txiter> it) const | ||||
return !it || visited(*it); | return !it || visited(*it); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* CCoinsView that brings transactions from a mempool into view. | * CCoinsView that brings transactions from a mempool into view. | ||||
* It does not check for spendings by memory pool transactions. | * It does not check for spendings by memory pool transactions. | ||||
* Instead, it provides access to all Coins which are either unspent in the | * Instead, it provides access to all Coins which are either unspent in the | ||||
* base CCoinsView, or are outputs from any mempool transaction! | * base CCoinsView, are outputs from any mempool transaction, or are | ||||
* tracked temporarily to allow transaction dependencies in package validation. | |||||
* This allows transaction replacement to work as expected, as you want to | * This allows transaction replacement to work as expected, as you want to | ||||
* have all inputs "available" to check signatures, and any cycles in the | * have all inputs "available" to check signatures, and any cycles in the | ||||
* dependency graph are checked directly in AcceptToMemoryPool. | * dependency graph are checked directly in AcceptToMemoryPool. | ||||
* It also allows you to sign a double-spend directly in | * It also allows you to sign a double-spend directly in | ||||
* signrawtransactionwithkey and signrawtransactionwithwallet, | * signrawtransactionwithkey and signrawtransactionwithwallet, | ||||
* as long as the conflicting transaction is not yet confirmed. | * as long as the conflicting transaction is not yet confirmed. | ||||
*/ | */ | ||||
class CCoinsViewMemPool : public CCoinsViewBacked { | class CCoinsViewMemPool : public CCoinsViewBacked { | ||||
/** | |||||
* Coins made available by transactions being validated. Tracking these | |||||
* allows for package validation, since we can access transaction outputs | |||||
* without submitting them to mempool. | |||||
*/ | |||||
std::unordered_map<COutPoint, Coin, SaltedOutpointHasher> m_temp_added; | |||||
protected: | protected: | ||||
const CTxMemPool &mempool; | const CTxMemPool &mempool; | ||||
public: | public: | ||||
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn); | CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn); | ||||
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; | bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; | ||||
/** Add the coins created by this transaction. */ | |||||
void PackageAddTransaction(const CTransactionRef &tx); | |||||
}; | }; | ||||
/** | /** | ||||
* DisconnectedBlockTransactions | * DisconnectedBlockTransactions | ||||
* | * | ||||
* During the reorg, it's desirable to re-add previously confirmed transactions | * During the reorg, it's desirable to re-add previously confirmed transactions | ||||
* to the mempool, so that anything not re-confirmed in the new chain is | * to the mempool, so that anything not re-confirmed in the new chain is | ||||
* available to be mined. However, it's more efficient to wait until the reorg | * available to be mined. However, it's more efficient to wait until the reorg | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |