mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
init: move asmap code earlier in init process
and update feature_asmap.py and test_runner.py This commit moves the asmap init.cpp code from the end of "Step 12: start node" to "Step 6: network initialization" to provide feedback on passing an -asmap config arg much more quickly. This change speeds up the feature_asmap.py functional test file from 60 to 5 seconds by accelerating the 2 tests that use `assert_start_raises_init_error`. Credit to Wladimir J. van der Laan for the suggestion.
This commit is contained in:
parent
5ba829e12e
commit
1ba3e1cc21
3 changed files with 27 additions and 28 deletions
50
src/init.cpp
50
src/init.cpp
|
@ -1418,6 +1418,31 @@ bool AppInitMain(NodeContext& node)
|
||||||
return InitError(ResolveErrMsg("externalip", strAddr));
|
return InitError(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)) {
|
||||||
|
InitError(strprintf(_("Could not find asmap file %s").translated, asmap_path));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<bool> asmap = CAddrMan::DecodeAsmap(asmap_path);
|
||||||
|
if (asmap.size() == 0) {
|
||||||
|
InitError(strprintf(_("Could not parse asmap file %s").translated, asmap_path));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const uint256 asmap_version = SerializeHash(asmap);
|
||||||
|
node.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");
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_ZMQ
|
#if ENABLE_ZMQ
|
||||||
g_zmq_notification_interface = CZMQNotificationInterface::Create();
|
g_zmq_notification_interface = CZMQNotificationInterface::Create();
|
||||||
|
|
||||||
|
@ -1825,31 +1850,6 @@ bool AppInitMain(NodeContext& node)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)) {
|
|
||||||
InitError(strprintf(_("Could not find asmap file %s").translated, asmap_path));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::vector<bool> asmap = CAddrMan::DecodeAsmap(asmap_path);
|
|
||||||
if (asmap.size() == 0) {
|
|
||||||
InitError(strprintf(_("Could not parse asmap file %s").translated, asmap_path));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const uint256 asmap_version = SerializeHash(asmap);
|
|
||||||
node.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 13: finished
|
// ********************************************************* Step 13: finished
|
||||||
|
|
||||||
SetRPCWarmupFinished();
|
SetRPCWarmupFinished();
|
||||||
|
|
|
@ -18,8 +18,7 @@ Verify node behaviour and debug log when launching bitcoind in these cases:
|
||||||
|
|
||||||
6. `bitcoind -asmap` with an empty (unparsable) default asmap file
|
6. `bitcoind -asmap` with an empty (unparsable) default asmap file
|
||||||
|
|
||||||
The tests are order-independent. The slowest tests (missing default asmap and
|
The tests are order-independent.
|
||||||
empty asmap) are placed last.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -101,7 +101,6 @@ BASE_SCRIPTS = [
|
||||||
'rpc_txoutproof.py',
|
'rpc_txoutproof.py',
|
||||||
'wallet_listreceivedby.py',
|
'wallet_listreceivedby.py',
|
||||||
'wallet_abandonconflict.py',
|
'wallet_abandonconflict.py',
|
||||||
'feature_asmap.py',
|
|
||||||
'feature_csv_activation.py',
|
'feature_csv_activation.py',
|
||||||
'rpc_rawtransaction.py',
|
'rpc_rawtransaction.py',
|
||||||
'wallet_address_types.py',
|
'wallet_address_types.py',
|
||||||
|
@ -207,6 +206,7 @@ BASE_SCRIPTS = [
|
||||||
'p2p_dos_header_tree.py',
|
'p2p_dos_header_tree.py',
|
||||||
'p2p_unrequested_blocks.py',
|
'p2p_unrequested_blocks.py',
|
||||||
'feature_includeconf.py',
|
'feature_includeconf.py',
|
||||||
|
'feature_asmap.py',
|
||||||
'rpc_deriveaddresses.py',
|
'rpc_deriveaddresses.py',
|
||||||
'rpc_deriveaddresses.py --usecli',
|
'rpc_deriveaddresses.py --usecli',
|
||||||
'rpc_scantxoutset.py',
|
'rpc_scantxoutset.py',
|
||||||
|
|
Loading…
Add table
Reference in a new issue