120
120
#include < zmq/zmqrpc.h>
121
121
#endif
122
122
123
- static bool fFeeEstimatesInitialized = false ;
124
123
static const bool DEFAULT_PROXYRANDOMIZE = true ;
125
124
static const bool DEFAULT_REST_ENABLE = false ;
126
125
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false ;
@@ -136,8 +135,6 @@ static CDSNotificationInterface* pdsNotificationInterface = nullptr;
136
135
#define MIN_CORE_FILEDESCRIPTORS 150
137
136
#endif
138
137
139
- static const char * FEE_ESTIMATES_FILENAME=" fee_estimates.dat" ;
140
-
141
138
static const char * DEFAULT_ASMAP_FILENAME=" ip_asn.map" ;
142
139
/* *
143
140
* The PID file facilities.
@@ -286,17 +283,8 @@ void PrepareShutdown(NodeContext& node)
286
283
DumpMempool (*node.mempool );
287
284
}
288
285
289
- if (fFeeEstimatesInitialized )
290
- {
291
- ::feeEstimator.FlushUnconfirmed ();
292
- fs::path est_path = GetDataDir () / FEE_ESTIMATES_FILENAME;
293
- CAutoFile est_fileout (fsbridge::fopen (est_path, " wb" ), SER_DISK, CLIENT_VERSION);
294
- if (!est_fileout.IsNull ())
295
- ::feeEstimator.Write (est_fileout);
296
- else
297
- LogPrintf (" %s: Failed to write fee estimates to %s\n " , __func__, est_path.string ());
298
- fFeeEstimatesInitialized = false ;
299
- }
286
+ // Drop transactions we were still watching, and record fee estimations.
287
+ if (node.fee_estimator ) node.fee_estimator ->Flush ();
300
288
301
289
// FlushStateToDisk generates a ChainStateFlushed callback, which we should avoid missing
302
290
if (node.chainman ) {
@@ -405,6 +393,7 @@ void Shutdown(NodeContext& node)
405
393
globalVerifyHandle.reset ();
406
394
ECC_Stop ();
407
395
node.mempool .reset ();
396
+ node.fee_estimator .reset ();
408
397
node.chainman = nullptr ;
409
398
node.scheduler .reset ();
410
399
@@ -1761,11 +1750,21 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
1761
1750
// is not yet setup and may end up being set up twice if we
1762
1751
// need to reindex later.
1763
1752
1753
+ // see Step 2: parameter interactions for more information about these
1754
+ fListen = args.GetBoolArg (" -listen" , DEFAULT_LISTEN);
1755
+ fDiscover = args.GetBoolArg (" -discover" , true );
1756
+ g_relay_txes = !args.GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY);
1757
+
1764
1758
assert (!node.banman );
1765
1759
node.banman = std::make_unique<BanMan>(GetDataDir () / " banlist.dat" , &uiInterface, args.GetArg (" -bantime" , DEFAULT_MISBEHAVING_BANTIME));
1766
1760
assert (!node.connman );
1767
1761
node.connman = std::make_unique<CConnman>(GetRand (std::numeric_limits<uint64_t >::max ()), GetRand (std::numeric_limits<uint64_t >::max ()));
1768
1762
1763
+ assert (!node.fee_estimator );
1764
+ // Don't initialize fee estimation with old data if we don't relay transactions,
1765
+ // as they would never get updated.
1766
+ if (g_relay_txes) node.fee_estimator = std::make_unique<CBlockPolicyEstimator>();
1767
+
1769
1768
assert (!node.mempool );
1770
1769
int check_ratio = std::min<int >(std::max<int >(args.GetArg (" -checkmempool" , chainparams.DefaultConsistencyChecks () ? 1 : 0 ), 0 ), 1000000 );
1771
1770
node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator .get (), check_ratio);
@@ -1887,11 +1886,6 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
1887
1886
}
1888
1887
}
1889
1888
1890
- // see Step 2: parameter interactions for more information about these
1891
- fListen = args.GetBoolArg (" -listen" , DEFAULT_LISTEN);
1892
- fDiscover = args.GetBoolArg (" -discover" , true );
1893
- g_relay_txes = !args.GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY);
1894
-
1895
1889
for (const std::string& strAddr : args.GetArgs (" -externalip" )) {
1896
1890
CService addrLocal;
1897
1891
if (Lookup (strAddr, addrLocal, GetListenPort (), fNameLookup ) && addrLocal.IsValid ())
@@ -2257,13 +2251,6 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
2257
2251
return false ;
2258
2252
}
2259
2253
2260
- fs::path est_path = GetDataDir () / FEE_ESTIMATES_FILENAME;
2261
- CAutoFile est_filein (fsbridge::fopen (est_path, " rb" ), SER_DISK, CLIENT_VERSION);
2262
- // Allowed to fail as this file IS missing on first startup.
2263
- if (!est_filein.IsNull ())
2264
- ::feeEstimator.Read (est_filein);
2265
- fFeeEstimatesInitialized = true ;
2266
-
2267
2254
// ********************************************************* Step 8: start indexers
2268
2255
if (args.GetBoolArg (" -txindex" , DEFAULT_TXINDEX)) {
2269
2256
g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false , fReindex );
@@ -2318,7 +2305,9 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
2318
2305
2319
2306
::coinJoinServer = std::make_unique<CCoinJoinServer>(*node.mempool , *node.connman , ::masternodeSync);
2320
2307
#ifdef ENABLE_WALLET
2321
- ::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*node.connman , ::masternodeSync);
2308
+ if (g_relay_txes) {
2309
+ ::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*node.connman , ::masternodeSync);
2310
+ }
2322
2311
#endif // ENABLE_WALLET
2323
2312
2324
2313
g_wallet_init_interface.InitCoinJoinSettings ();
@@ -2389,8 +2378,8 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
2389
2378
node.scheduler ->scheduleEvery (std::bind (&CCoinJoinServer::DoMaintenance, std::ref (*::coinJoinServer)), std::chrono::seconds{1 });
2390
2379
node.scheduler ->scheduleEvery (std::bind (&llmq::CDKGSessionManager::CleanupOldContributions, std::ref (*node.llmq_ctx ->qdkgsman )), std::chrono::hours{1 });
2391
2380
#ifdef ENABLE_WALLET
2392
- } else if ( CCoinJoinClientOptions::IsEnabled ()) {
2393
- node.scheduler ->scheduleEvery (std::bind (&DoCoinJoinMaintenance, std::ref (*node.connman ), std::ref (::feeEstimator ), std::ref (*node.mempool )), std::chrono::seconds{1 });
2381
+ } else if (g_relay_txes && CCoinJoinClientOptions::IsEnabled ()) {
2382
+ node.scheduler ->scheduleEvery (std::bind (&DoCoinJoinMaintenance, std::ref (*node.connman ), std::ref (*node. fee_estimator ), std::ref (*node.mempool )), std::chrono::seconds{1 });
2394
2383
#endif // ENABLE_WALLET
2395
2384
}
2396
2385
0 commit comments