23#include <validation.h>
49 LogInfo(
"Failed to open mempool file. Continuing anyway.\n");
65 file.SetObfuscation({});
82 LogInfo(
"Progress loading mempool transactions from file: %d%% (tried %u, %u remaining)\n",
95 if (opts.use_current_time) {
100 if (
amountdelta && opts.apply_fee_delta_priority) {
113 if (pool.
exists(tx->GetHash())) {
128 if (opts.apply_fee_delta_priority) {
136 if (opts.apply_unbroadcast_set) {
144 }
catch (
const std::exception&
e) {
145 LogInfo(
"Failed to deserialize mempool data on file: %s. Continuing anyway.\n",
e.what());
155 auto start = SteadyClock::now();
158 std::vector<TxMempoolInfo>
vinfo;
166 for (
const auto &i : pool.mapDeltas) {
173 auto mid = SteadyClock::now();
191 for (
const auto& i :
vinfo) {
205 throw std::runtime_error(
"Commit failed");
207 if (file.fclose() != 0) {
208 throw std::runtime_error(
212 throw std::runtime_error(
"Rename failed");
214 auto last = SteadyClock::now();
216 LogInfo(
"Dumped mempool: %.3fs to copy, %.3fs to dump, %d bytes dumped to file\n",
220 }
catch (
const std::exception&
e) {
221 LogInfo(
"Failed to dump mempool: %s. Continuing anyway.\n",
e.what());
int64_t CAmount
Amount in satoshis (Can be negative)
Non-refcounted RAII wrapper for FILE*.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const Txid &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
CTransactionRef get(const Txid &hash) const
Return a mempool transaction with a given hash.
std::vector< TxMempoolInfo > infoAll() const
bool exists(const Txid &txid) const
void AddUnbroadcastTx(const Txid &txid)
Adds a transaction to the unbroadcast set.
std::set< Txid > GetUnbroadcastTxs() const
Returns a copy of the unbroadcast txid set.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
static constexpr size_t KEY_SIZE
std::vector< B > randbytes(size_t len) noexcept
Generate random bytes.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
static std::string PathToString(const path &path)
Convert path object to a byte string.
bool RenameOver(fs::path src, fs::path dest)
Rename src to dest.
std::function< FILE *(const fs::path &, const char *)> FopenFn
static const uint64_t MEMPOOL_DUMP_VERSION_NO_XOR_KEY
static const uint64_t MEMPOOL_DUMP_VERSION
bool LoadMempool(CTxMemPool &pool, const fs::path &load_path, Chainstate &active_chainstate, ImportMempoolOptions &&opts)
Import the file and attempt to add its contents to the mempool.
bool DumpMempool(const CTxMemPool &pool, const fs::path &dump_path, FopenFn mockable_fopen_function, bool skip_file_commit)
constexpr TransactionSerParams TX_WITH_WITNESS
std::shared_ptr< const CTransaction > CTransactionRef
static time_point now() noexcept
Return current system time or mocked time, if set.
std::chrono::seconds expiry
std::string SysErrorString(int err)
Return system error string from errno value.
constexpr int64_t count_seconds(std::chrono::seconds t)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
MempoolAcceptResult AcceptToMemoryPool(Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept)
Try to add a transaction to the mempool.