Changeset View
Changeset View
Standalone View
Standalone View
src/kernel/mempool_persist.cpp
// Copyright (c) 2022 The Bitcoin Core developers | // Copyright (c) 2022 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <kernel/mempool_persist.h> | #include <kernel/mempool_persist.h> | ||||
#include <clientversion.h> | #include <clientversion.h> | ||||
#include <config.h> | |||||
#include <consensus/amount.h> | #include <consensus/amount.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <logging.h> | #include <logging.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
Show All 15 Lines | |||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
using fsbridge::FopenFn; | using fsbridge::FopenFn; | ||||
namespace kernel { | namespace kernel { | ||||
static const uint64_t MEMPOOL_DUMP_VERSION = 1; | static const uint64_t MEMPOOL_DUMP_VERSION = 1; | ||||
bool LoadMempool(const Config &config, CTxMemPool &pool, | bool LoadMempool(CTxMemPool &pool, const fs::path &load_path, | ||||
const fs::path &load_path, Chainstate &active_chainstate, | Chainstate &active_chainstate, | ||||
FopenFn mockable_fopen_function) { | FopenFn mockable_fopen_function) { | ||||
if (load_path.empty()) { | if (load_path.empty()) { | ||||
return false; | return false; | ||||
} | } | ||||
FILE *filestr{mockable_fopen_function(load_path, "rb")}; | FILE *filestr{mockable_fopen_function(load_path, "rb")}; | ||||
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); | CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); | ||||
if (file.IsNull()) { | if (file.IsNull()) { | ||||
Show All 30 Lines | try { | ||||
Amount amountdelta = nFeeDelta * SATOSHI; | Amount amountdelta = nFeeDelta * SATOSHI; | ||||
if (amountdelta != Amount::zero()) { | if (amountdelta != Amount::zero()) { | ||||
pool.PrioritiseTransaction(tx->GetId(), amountdelta); | pool.PrioritiseTransaction(tx->GetId(), amountdelta); | ||||
} | } | ||||
if (nTime > | if (nTime > | ||||
TicksSinceEpoch<std::chrono::seconds>(now - pool.m_expiry)) { | TicksSinceEpoch<std::chrono::seconds>(now - pool.m_expiry)) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const auto &accepted = | const auto &accepted = | ||||
AcceptToMemoryPool(config, active_chainstate, tx, nTime, | AcceptToMemoryPool(active_chainstate, tx, nTime, | ||||
/*bypass_limits=*/false, | /*bypass_limits=*/false, | ||||
/*test_accept=*/false); | /*test_accept=*/false); | ||||
if (accepted.m_result_type == | if (accepted.m_result_type == | ||||
MempoolAcceptResult::ResultType::VALID) { | MempoolAcceptResult::ResultType::VALID) { | ||||
++count; | ++count; | ||||
} else { | } else { | ||||
// mempool may contain the transaction already, e.g. from | // mempool may contain the transaction already, e.g. from | ||||
// wallet(s) having loaded it while we were processing | // wallet(s) having loaded it while we were processing | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |