Skip to content

Commit fa5b892

Browse files
author
MarcoFalke
committed
rpc: Use untranslated error strings in loadtxoutset
1 parent fa45865 commit fa5b892

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ static RPCHelpMan loadtxoutset()
28332833

28342834
auto activation_result{chainman.ActivateSnapshot(afile, metadata, false)};
28352835
if (!activation_result) {
2836-
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf(_("Unable to load UTXO snapshot: %s\n"), util::ErrorString(activation_result)).original);
2836+
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Unable to load UTXO snapshot: %s. (%s)", util::ErrorString(activation_result).original, path.utf8string()));
28372837
}
28382838

28392839
UniValue result(UniValue::VOBJ);

src/validation.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5655,7 +5655,7 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
56555655
int base_blockheight = metadata.m_base_blockheight;
56565656

56575657
if (this->SnapshotBlockhash()) {
5658-
return util::Error{_("Can't activate a snapshot-based chainstate more than once")};
5658+
return util::Error{Untranslated("Can't activate a snapshot-based chainstate more than once")};
56595659
}
56605660

56615661
{
@@ -5664,26 +5664,26 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
56645664
if (!GetParams().AssumeutxoForBlockhash(base_blockhash).has_value()) {
56655665
auto available_heights = GetParams().GetAvailableSnapshotHeights();
56665666
std::string heights_formatted = util::Join(available_heights, ", ", [&](const auto& i) { return util::ToString(i); });
5667-
return util::Error{strprintf(_("assumeutxo block hash in snapshot metadata not recognized (hash: %s, height: %s). The following snapshot heights are available: %s."),
5667+
return util::Error{strprintf(Untranslated("assumeutxo block hash in snapshot metadata not recognized (hash: %s, height: %s). The following snapshot heights are available: %s"),
56685668
base_blockhash.ToString(),
56695669
base_blockheight,
56705670
heights_formatted)};
56715671
}
56725672

56735673
CBlockIndex* snapshot_start_block = m_blockman.LookupBlockIndex(base_blockhash);
56745674
if (!snapshot_start_block) {
5675-
return util::Error{strprintf(_("The base block header (%s) must appear in the headers chain. Make sure all headers are syncing, and call loadtxoutset again."),
5675+
return util::Error{strprintf(Untranslated("The base block header (%s) must appear in the headers chain. Make sure all headers are syncing, and call loadtxoutset again"),
56765676
base_blockhash.ToString())};
56775677
}
56785678

56795679
bool start_block_invalid = snapshot_start_block->nStatus & BLOCK_FAILED_MASK;
56805680
if (start_block_invalid) {
5681-
return util::Error{strprintf(_("The base block header (%s) is part of an invalid chain."), base_blockhash.ToString())};
5681+
return util::Error{strprintf(Untranslated("The base block header (%s) is part of an invalid chain"), base_blockhash.ToString())};
56825682
}
56835683

56845684
auto mempool{m_active_chainstate->GetMempool()};
56855685
if (mempool && mempool->size() > 0) {
5686-
return util::Error{_("Can't activate a snapshot when mempool not empty.")};
5686+
return util::Error{Untranslated("Can't activate a snapshot when mempool not empty")};
56875687
}
56885688
}
56895689

@@ -5732,7 +5732,7 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
57325732
static_cast<size_t>(current_coinstip_cache_size * SNAPSHOT_CACHE_PERC));
57335733
}
57345734

5735-
auto cleanup_bad_snapshot = [&](const char* reason) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
5735+
auto cleanup_bad_snapshot = [&](bilingual_str&& reason) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
57365736
this->MaybeRebalanceCaches();
57375737

57385738
// PopulateAndValidateSnapshot can return (in error) before the leveldb datadir
@@ -5748,12 +5748,12 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
57485748
"Manually remove it before restarting.\n"), fs::PathToString(*snapshot_datadir)));
57495749
}
57505750
}
5751-
return util::Error{_(reason)};
5751+
return util::Error{std::move(reason)};
57525752
};
57535753

57545754
if (!this->PopulateAndValidateSnapshot(*snapshot_chainstate, coins_file, metadata)) {
57555755
LOCK(::cs_main);
5756-
return cleanup_bad_snapshot("population failed");
5756+
return cleanup_bad_snapshot(Untranslated("population failed"));
57575757
}
57585758

57595759
LOCK(::cs_main); // cs_main required for rest of snapshot activation.
@@ -5762,13 +5762,13 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
57625762
// work chain than the active chainstate; a user could have loaded a snapshot
57635763
// very late in the IBD process, and we wouldn't want to load a useless chainstate.
57645764
if (!CBlockIndexWorkComparator()(ActiveTip(), snapshot_chainstate->m_chain.Tip())) {
5765-
return cleanup_bad_snapshot("work does not exceed active chainstate");
5765+
return cleanup_bad_snapshot(Untranslated("work does not exceed active chainstate"));
57665766
}
57675767
// If not in-memory, persist the base blockhash for use during subsequent
57685768
// initialization.
57695769
if (!in_memory) {
57705770
if (!node::WriteSnapshotBaseBlockhash(*snapshot_chainstate)) {
5771-
return cleanup_bad_snapshot("could not write base blockhash");
5771+
return cleanup_bad_snapshot(Untranslated("could not write base blockhash"));
57725772
}
57735773
}
57745774

0 commit comments

Comments
 (0)