aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2020-09-10 14:27:36 +0200
committerAntoine Poinsot <darosior@protonmail.com>2020-12-03 12:56:37 +0100
commit4e28753f60613ecd35cdef87bef5f99c302c3fbd (patch)
tree6e020d200f0b0bee38790f7f17549e158063ae3b /src/init.cpp
parente8ea6ad9c16997bdc7e22a20eca16e234290b7ff (diff)
feestimator: encapsulate estimation file logic
This moves the fee_estimates file management to the CBlockPolicyEstimator Flush() method. Co-authored-by: John Newbery <john@johnnewbery.com> Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/init.cpp b/src/init.cpp
index de8f32cf6a..6877f5db47 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -98,8 +98,6 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
#define MIN_CORE_FILEDESCRIPTORS 150
#endif
-static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
-
static const char* DEFAULT_ASMAP_FILENAME="ip_asn.map";
/**
@@ -235,17 +233,8 @@ void Shutdown(NodeContext& node)
DumpMempool(*node.mempool);
}
- if (node.fee_estimator) {
- node.fee_estimator->FlushUnconfirmed();
- fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
- CAutoFile est_fileout(fsbridge::fopen(est_path, "wb"), SER_DISK, CLIENT_VERSION);
- if (!est_fileout.IsNull()) {
- node.fee_estimator->Write(est_fileout);
- } else {
- LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
- }
- }
-
+ // Drop transactions we were still watching, and record fee estimations.
+ if (node.fee_estimator) node.fee_estimator->Flush();
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
if (node.chainman) {
@@ -1790,12 +1779,6 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
return false;
}
- fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
- CAutoFile est_filein(fsbridge::fopen(est_path, "rb"), SER_DISK, CLIENT_VERSION);
- // Allowed to fail as this file IS missing on first startup.
- if (node.fee_estimator && !est_filein.IsNull()) {
- node.fee_estimator->Read(est_filein);
- }
// ********************************************************* Step 8: start indexers
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
g_txindex = MakeUnique<TxIndex>(nTxIndexCache, false, fReindex);