aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2024-02-26 10:56:45 +0000
committerfanquake <fanquake@gmail.com>2024-02-26 11:11:25 +0000
commitba90b058bd9003d6286d22f88f26c35ec877b87d (patch)
treed1edb51858aa5ad97e655cefcb272da8e012792c /src/rpc
parentd0a9e339a9df4c6a7ab932e0409ce96263aeef95 (diff)
parentfaa30a4c566c5b720c7994c55f276352a119129f (diff)
downloadbitcoin-ba90b058bd9003d6286d22f88f26c35ec877b87d.tar.xz
Merge bitcoin/bitcoin#29345: rpc: Do not wait for headers inside loadtxoutset
faa30a4c566c5b720c7994c55f276352a119129f rpc: Do not wait for headers inside loadtxoutset (MarcoFalke) Pull request description: While the `loadtxoutset` default 10 minute timeout is convenient when it is sufficient, it may cause hassle where it is not. For example: * When P2P connections are missing, it seems better to abort early than wait for the timeout. * When the 10 minute timeout is not sufficient, the RPC will have to be called again, so a check or loop is needed outside the RPC either way. So might as well remove the loop inside the RPC. ACKs for top commit: fjahr: ACK faa30a4c56 theStack: Code-review ACK faa30a4c566c5b720c7994c55f276352a119129f pablomartin4btc: tACK faa30a4c566c5b720c7994c55f276352a119129f TheCharlatan: ACK faa30a4c566c5b720c7994c55f276352a119129f Tree-SHA512: 9167c7d8b2889bb3fd369de4acd2cc4d24a2fe225018d82bd9568ecd737093f6e19be7cc62815b574137b61076a6f773c29bff75398991b5cd702423aab2322b
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 34d308211b..50908e9f96 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -2571,7 +2571,7 @@ static RPCHelpMan dumptxoutset()
{
return RPCHelpMan{
"dumptxoutset",
- "Write the serialized UTXO set to disk.",
+ "Write the serialized UTXO set to a file.",
{
{"path", RPCArg::Type::STR, RPCArg::Optional::NO, "Path to the output file. If relative, will be prefixed by datadir."},
},
@@ -2699,7 +2699,7 @@ static RPCHelpMan loadtxoutset()
{
return RPCHelpMan{
"loadtxoutset",
- "Load the serialized UTXO set from disk.\n"
+ "Load the serialized UTXO set from a file.\n"
"Once this snapshot is loaded, its contents will be "
"deserialized into a second chainstate data structure, which is then used to sync to "
"the network's tip. "
@@ -2753,34 +2753,14 @@ static RPCHelpMan loadtxoutset()
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Unable to load UTXO snapshot, "
"assumeutxo block hash in snapshot metadata not recognized (%s)", base_blockhash.ToString()));
}
- int max_secs_to_wait_for_headers = 60 * 10;
- CBlockIndex* snapshot_start_block = nullptr;
-
- LogPrintf("[snapshot] waiting to see blockheader %s in headers chain before snapshot activation\n",
- base_blockhash.ToString());
-
- while (max_secs_to_wait_for_headers > 0) {
- snapshot_start_block = WITH_LOCK(::cs_main,
+ CBlockIndex* snapshot_start_block = WITH_LOCK(::cs_main,
return chainman.m_blockman.LookupBlockIndex(base_blockhash));
- max_secs_to_wait_for_headers -= 1;
-
- if (!IsRPCRunning()) {
- throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");
- }
-
- if (!snapshot_start_block) {
- std::this_thread::sleep_for(std::chrono::seconds(1));
- } else {
- break;
- }
- }
if (!snapshot_start_block) {
- LogPrintf("[snapshot] timed out waiting for snapshot start blockheader %s\n",
- base_blockhash.ToString());
throw JSONRPCError(
RPC_INTERNAL_ERROR,
- "Timed out waiting for base block header to appear in headers chain");
+ strprintf("The base block header (%s) must appear in the headers chain. Make sure all headers are syncing, and call this RPC again.",
+ base_blockhash.ToString()));
}
if (!chainman.ActivateSnapshot(afile, metadata, false)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to load UTXO snapshot " + fs::PathToString(path));