From e8ea6ad9c16997bdc7e22a20eca16e234290b7ff Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Sun, 6 Sep 2020 19:37:13 +0200 Subject: init: don't create a CBlockPolicyEstimator if we don't relay transactions Signed-off-by: Antoine Poinsot --- src/init.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 5c06b0459d..de8f32cf6a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1384,13 +1384,20 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA // is not yet setup and may end up being set up twice if we // need to reindex later. + // see Step 2: parameter interactions for more information about these + fListen = args.GetBoolArg("-listen", DEFAULT_LISTEN); + fDiscover = args.GetBoolArg("-discover", true); + g_relay_txes = !args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); + assert(!node.banman); node.banman = MakeUnique(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME)); assert(!node.connman); node.connman = MakeUnique(GetRand(std::numeric_limits::max()), GetRand(std::numeric_limits::max()), args.GetBoolArg("-networkactive", true)); assert(!node.fee_estimator); - node.fee_estimator = std::make_unique(); + // Don't initialize fee estimation with old data if we don't relay transactions, + // as they would never get updated. + if (g_relay_txes) node.fee_estimator = std::make_unique(); assert(!node.mempool); int check_ratio = std::min(std::max(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000); @@ -1476,11 +1483,6 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA } } - // see Step 2: parameter interactions for more information about these - fListen = args.GetBoolArg("-listen", DEFAULT_LISTEN); - fDiscover = args.GetBoolArg("-discover", true); - g_relay_txes = !args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); - for (const std::string& strAddr : args.GetArgs("-externalip")) { CService addrLocal; if (Lookup(strAddr, addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid()) -- cgit v1.2.3