20#include <validation.h>
50 "Failed to open mempool file from disk. Continuing anyway.\n");
98 if (pool.
exists(tx->GetId())) {
125 if (pool.
get(txid) !=
nullptr) {
129 }
catch (
const std::exception &
e) {
130 LogPrintf(
"Failed to deserialize mempool data on disk: %s. Continuing "
136 LogPrintf(
"Imported mempool transactions from disk: %i succeeded, %i "
137 "failed, %i expired, %i already there, %i waiting for initial "
145 auto start = SteadyClock::now();
148 std::vector<TxMempoolInfo>
vinfo;
156 for (
const auto &i : pool.mapDeltas) {
164 auto mid = SteadyClock::now();
178 for (
const auto &i :
vinfo) {
187 LogPrintf(
"Writing %d unbroadcast transactions to disk.\n",
192 throw std::runtime_error(
"FileCommit failed");
196 throw std::runtime_error(
"Rename failed");
198 auto last = SteadyClock::now();
200 LogPrintf(
"Dumped mempool: %gs to copy, %gs to dump\n",
203 }
catch (
const std::exception &
e) {
204 LogPrintf(
"Failed to dump mempool: %s. Continuing anyway.\n",
e.what());
static constexpr Amount SATOSHI
bool IsNull() const
Return true if the wrapped FILE* is nullptr, false otherwise.
FILE * Get() const
Get wrapped FILE* without transfer of ownership.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
const std::chrono::seconds m_expiry
std::vector< TxMempoolInfo > infoAll() const
bool exists(const TxId &txid) const
std::set< TxId > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
CTransactionRef get(const TxId &txid) const
void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
void AddUnbroadcastTx(const TxId &txid)
Adds a transaction to the unbroadcast set.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
bool RenameOver(fs::path src, fs::path dest)
bool FileCommit(FILE *file)
Ensure file contents are fully committed to disk, using a platform-specific feature analogous to fsyn...
std::function< FILE *(const fs::path &, const char *)> FopenFn
bool DumpMempool(const CTxMemPool &pool, const fs::path &dump_path, FopenFn mockable_fopen_function, bool skip_file_commit)
static const uint64_t MEMPOOL_DUMP_VERSION
bool LoadMempool(CTxMemPool &pool, const fs::path &load_path, Chainstate &active_chainstate, FopenFn mockable_fopen_function)
std::shared_ptr< const CTransaction > CTransactionRef
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
static constexpr Amount zero() noexcept
@ VALID
Fully validated, valid.
static time_point now() noexcept
Return current system time or mocked time, if set.
constexpr int64_t count_seconds(std::chrono::seconds t)
MempoolAcceptResult AcceptToMemoryPool(Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept, unsigned int heightOverride)
Try to add a transaction to the mempool.