Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
| Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | |||||
| * In the event of a reorg, the invariant that all newly-added tx's have no | * In the event of a reorg, the invariant that all newly-added tx's have no | ||||
| * in-mempool children must be maintained. On top of this, we use a topological | * in-mempool children must be maintained. On top of this, we use a topological | ||||
| * index (GetEntryId). As such, we always dump mempool tx's into a disconnect | * index (GetEntryId). As such, we always dump mempool tx's into a disconnect | ||||
| * pool on reorg, and simply add them one by one, along with tx's from | * pool on reorg, and simply add them one by one, along with tx's from | ||||
| * disconnected blocks, when the reorg is complete. | * disconnected blocks, when the reorg is complete. | ||||
| */ | */ | ||||
| class CTxMemPool { | class CTxMemPool { | ||||
| private: | private: | ||||
| //! Value n means that 1 times in n we check. | |||||
| const int m_check_ratio; | |||||
| //! Used by getblocktemplate to trigger CreateNewBlock() invocation | //! Used by getblocktemplate to trigger CreateNewBlock() invocation | ||||
| std::atomic<uint32_t> nTransactionsUpdated{0}; | std::atomic<uint32_t> nTransactionsUpdated{0}; | ||||
| //! sum of all mempool tx's sizes. | //! sum of all mempool tx's sizes. | ||||
| uint64_t totalTxSize GUARDED_BY(cs); | uint64_t totalTxSize GUARDED_BY(cs); | ||||
| //! Check whether the finalized txs would fit a block | //! Check whether the finalized txs would fit a block | ||||
| node::BlockFitter m_finalizedTxsFitter GUARDED_BY(cs); | node::BlockFitter m_finalizedTxsFitter GUARDED_BY(cs); | ||||
| //! sum of all mempool tx's fees (NOT modified fee) | //! sum of all mempool tx's fees (NOT modified fee) | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | bool CalculateAncestors(setEntries &setAncestors, | ||||
| EXCLUSIVE_LOCKS_REQUIRED(cs); | EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
| public: | public: | ||||
| indirectmap<COutPoint, CTransactionRef> mapNextTx GUARDED_BY(cs); | indirectmap<COutPoint, CTransactionRef> mapNextTx GUARDED_BY(cs); | ||||
| std::map<TxId, Amount> mapDeltas GUARDED_BY(cs); | std::map<TxId, Amount> mapDeltas GUARDED_BY(cs); | ||||
| using Options = kernel::MemPoolOptions; | using Options = kernel::MemPoolOptions; | ||||
| const int64_t m_max_size_bytes; | const Options m_opts; | ||||
| const std::chrono::seconds m_expiry; | |||||
| const CFeeRate m_min_relay_feerate; | |||||
| const CFeeRate m_dust_relay_feerate; | |||||
| const bool m_permit_bare_multisig; | |||||
| const std::optional<unsigned> m_max_datacarrier_bytes; | |||||
| const bool m_require_standard; | |||||
| ValidationSignals *const m_signals; | |||||
| /** | /** | ||||
| * Create a new CTxMemPool. | * Create a new CTxMemPool. | ||||
| * Sanity checks will be off by default for performance, because otherwise | * Sanity checks will be off by default for performance, because otherwise | ||||
| * accepting transactions becomes O(N^2) where N is the number of | * accepting transactions becomes O(N^2) where N is the number of | ||||
| * transactions in the pool. | * transactions in the pool. | ||||
| */ | */ | ||||
| CTxMemPool(const Config &config, const Options &opts); | CTxMemPool(const Config &config, Options opts); | ||||
| ~CTxMemPool(); | ~CTxMemPool(); | ||||
| /** | /** | ||||
| * If sanity-checking is turned on, check makes sure the pool is consistent | * If sanity-checking is turned on, check makes sure the pool is consistent | ||||
| * (does not contain two transactions that spend the same inputs, all inputs | * (does not contain two transactions that spend the same inputs, all inputs | ||||
| * are in the mapNextTx array). If sanity-checking is turned off, check does | * are in the mapNextTx array). If sanity-checking is turned off, check does | ||||
| * nothing. | * nothing. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | public: | ||||
| */ | */ | ||||
| void CalculateDescendants(txiter it, setEntries &setDescendants) const | void CalculateDescendants(txiter it, setEntries &setDescendants) const | ||||
| EXCLUSIVE_LOCKS_REQUIRED(cs); | EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
| /** | /** | ||||
| * The minimum fee to get into the mempool, which may itself not be enough | * The minimum fee to get into the mempool, which may itself not be enough | ||||
| * for larger-sized transactions. | * for larger-sized transactions. | ||||
| */ | */ | ||||
| CFeeRate GetMinFee() const { return GetMinFee(m_max_size_bytes); } | CFeeRate GetMinFee() const { return GetMinFee(m_opts.max_size_bytes); } | ||||
| CFeeRate GetMinFee(size_t sizelimit) const; | CFeeRate GetMinFee(size_t sizelimit) const; | ||||
| /** | /** | ||||
| * Remove transactions from the mempool until its dynamic size is <= | * Remove transactions from the mempool until its dynamic size is <= | ||||
| * sizelimit. pvNoSpendsRemaining, if set, will be populated with the list | * sizelimit. pvNoSpendsRemaining, if set, will be populated with the list | ||||
| * of outpoints which are not in mempool which no longer have any spends in | * of outpoints which are not in mempool which no longer have any spends in | ||||
| * this mempool. | * this mempool. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines | |||||