diff --git a/src/init.cpp b/src/init.cpp index d2ec711a6cdbd..b5a731f07ec7b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1475,6 +1475,31 @@ bool AppInitMain() return UIError(ResolveErrMsg("externalip", strAddr)); } + // Read asmap file if configured + if (gArgs.IsArgSet("-asmap")) { + fs::path asmap_path = fs::path(gArgs.GetArg("-asmap", "")); + if (asmap_path.empty()) { + asmap_path = DEFAULT_ASMAP_FILENAME; + } + if (!asmap_path.is_absolute()) { + asmap_path = GetDataDir() / asmap_path; + } + if (!fs::exists(asmap_path)) { + UIError(strprintf(_("Could not find asmap file %s"), asmap_path)); + return false; + } + std::vector asmap = CAddrMan::DecodeAsmap(asmap_path); + if (asmap.size() == 0) { + UIError(strprintf(_("Could not parse asmap file %s"), asmap_path)); + return false; + } + const uint256 asmap_version = SerializeHash(asmap); + connman.SetAsmap(std::move(asmap)); + LogPrintf("Using asmap version %s for IP bucketing\n", asmap_version.ToString()); + } else { + LogPrintf("Using /16 prefix for IP bucketing\n"); + } + // Warn if network-specific options (-addnode, -connect, etc) are // specified in default section of config file, but not overridden // on the command line or in this network's section of the config file. @@ -1967,31 +1992,6 @@ bool AppInitMain() } #endif - // Read asmap file if configured - if (gArgs.IsArgSet("-asmap")) { - fs::path asmap_path = fs::path(gArgs.GetArg("-asmap", "")); - if (asmap_path.empty()) { - asmap_path = DEFAULT_ASMAP_FILENAME; - } - if (!asmap_path.is_absolute()) { - asmap_path = GetDataDir() / asmap_path; - } - if (!fs::exists(asmap_path)) { - UIError(strprintf(_("Could not find asmap file %s"), asmap_path)); - return false; - } - std::vector asmap = CAddrMan::DecodeAsmap(asmap_path); - if (asmap.size() == 0) { - UIError(strprintf(_("Could not parse asmap file %s"), asmap_path)); - return false; - } - const uint256 asmap_version = SerializeHash(asmap); - connman.SetAsmap(std::move(asmap)); - LogPrintf("Using asmap version %s for IP bucketing\n", asmap_version.ToString()); - } else { - LogPrintf("Using /16 prefix for IP bucketing\n"); - } - // ********************************************************* Step 12: finished SetRPCWarmupFinished(); diff --git a/test/functional/feature_asmap.py b/test/functional/feature_asmap.py index 58f09f6af8720..30f5f482270d4 100755 --- a/test/functional/feature_asmap.py +++ b/test/functional/feature_asmap.py @@ -18,8 +18,7 @@ 6. `pivxd -asmap` with an empty (unparsable) default asmap file -The tests are order-independent. The slowest tests (missing default asmap and -empty asmap) are placed last. +The tests are order-independent. """ import os diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index dac6a99cfd33b..d72f92583cfb7 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -121,6 +121,7 @@ 'rpc_signrawtransaction.py', # ~ 50 sec 'rpc_decodescript.py', # ~ 50 sec 'rpc_blockchain.py', # ~ 50 sec + 'feature_asmap.py', 'wallet_disable.py', # ~ 50 sec 'wallet_autocombine.py', # ~ 49 sec 'mining_v5_upgrade.py', # ~ 48 sec @@ -183,7 +184,6 @@ # vv Tests less than 60s vv #'p2p_feefilter.py', 'feature_abortnode.py', - 'feature_asmap.py', 'rpc_bind.py', # vv Tests less than 30s vv #'example_test.py',