From 77979e0172d0bc86bfbc60f6a652e26c77722e29 Mon Sep 17 00:00:00 2001 From: ismaelsadeeq Date: Thu, 8 Jun 2023 13:14:11 +0100 Subject: tx fees, policy: periodically flush fee estimates to fee_estimates.dat This reduces chances of having old estimates in fee_estimates.dat. Github-Pull: #27622 Rebased-From: 5b886f2b436eaa8c2b7de58dc4644dc6223040da --- src/init.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 25b40c6c6e..7fcd1fee2f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1253,7 +1253,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) assert(!node.fee_estimator); // Don't initialize fee estimation with old data if we don't relay transactions, // as they would never get updated. - if (!ignores_incoming_txs) node.fee_estimator = std::make_unique(FeeestPath(args)); + if (!ignores_incoming_txs) { + node.fee_estimator = std::make_unique(FeeestPath(args)); + + // Flush estimates to disk periodically + CBlockPolicyEstimator* fee_estimator = node.fee_estimator.get(); + node.scheduler->scheduleEvery([fee_estimator] { fee_estimator->FlushFeeEstimates(); }, FEE_FLUSH_INTERVAL); + } // sanitize comments per BIP-0014, format user agent and check total size std::vector uacomments; -- cgit v1.2.3