rpc: Use untranslated error strings in loadtxoutset

This commit is contained in:
MarcoFalke
2024-07-05 10:08:32 +02:00
parent fa45865778
commit fa5b8920be
2 changed files with 11 additions and 11 deletions

View File

@@ -5655,7 +5655,7 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
int base_blockheight = metadata.m_base_blockheight;
if (this->SnapshotBlockhash()) {
return util::Error{_("Can't activate a snapshot-based chainstate more than once")};
return util::Error{Untranslated("Can't activate a snapshot-based chainstate more than once")};
}
{
@@ -5664,7 +5664,7 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
if (!GetParams().AssumeutxoForBlockhash(base_blockhash).has_value()) {
auto available_heights = GetParams().GetAvailableSnapshotHeights();
std::string heights_formatted = util::Join(available_heights, ", ", [&](const auto& i) { return util::ToString(i); });
return util::Error{strprintf(_("assumeutxo block hash in snapshot metadata not recognized (hash: %s, height: %s). The following snapshot heights are available: %s."),
return util::Error{strprintf(Untranslated("assumeutxo block hash in snapshot metadata not recognized (hash: %s, height: %s). The following snapshot heights are available: %s"),
base_blockhash.ToString(),
base_blockheight,
heights_formatted)};
@@ -5672,18 +5672,18 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
CBlockIndex* snapshot_start_block = m_blockman.LookupBlockIndex(base_blockhash);
if (!snapshot_start_block) {
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."),
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"),
base_blockhash.ToString())};
}
bool start_block_invalid = snapshot_start_block->nStatus & BLOCK_FAILED_MASK;
if (start_block_invalid) {
return util::Error{strprintf(_("The base block header (%s) is part of an invalid chain."), base_blockhash.ToString())};
return util::Error{strprintf(Untranslated("The base block header (%s) is part of an invalid chain"), base_blockhash.ToString())};
}
auto mempool{m_active_chainstate->GetMempool()};
if (mempool && mempool->size() > 0) {
return util::Error{_("Can't activate a snapshot when mempool not empty.")};
return util::Error{Untranslated("Can't activate a snapshot when mempool not empty")};
}
}
@@ -5732,7 +5732,7 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
static_cast<size_t>(current_coinstip_cache_size * SNAPSHOT_CACHE_PERC));
}
auto cleanup_bad_snapshot = [&](const char* reason) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
auto cleanup_bad_snapshot = [&](bilingual_str&& reason) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
this->MaybeRebalanceCaches();
// PopulateAndValidateSnapshot can return (in error) before the leveldb datadir
@@ -5748,12 +5748,12 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
"Manually remove it before restarting.\n"), fs::PathToString(*snapshot_datadir)));
}
}
return util::Error{_(reason)};
return util::Error{std::move(reason)};
};
if (!this->PopulateAndValidateSnapshot(*snapshot_chainstate, coins_file, metadata)) {
LOCK(::cs_main);
return cleanup_bad_snapshot("population failed");
return cleanup_bad_snapshot(Untranslated("population failed"));
}
LOCK(::cs_main); // cs_main required for rest of snapshot activation.
@@ -5762,13 +5762,13 @@ util::Result<void> ChainstateManager::ActivateSnapshot(
// work chain than the active chainstate; a user could have loaded a snapshot
// very late in the IBD process, and we wouldn't want to load a useless chainstate.
if (!CBlockIndexWorkComparator()(ActiveTip(), snapshot_chainstate->m_chain.Tip())) {
return cleanup_bad_snapshot("work does not exceed active chainstate");
return cleanup_bad_snapshot(Untranslated("work does not exceed active chainstate"));
}
// If not in-memory, persist the base blockhash for use during subsequent
// initialization.
if (!in_memory) {
if (!node::WriteSnapshotBaseBlockhash(*snapshot_chainstate)) {
return cleanup_bad_snapshot("could not write base blockhash");
return cleanup_bad_snapshot(Untranslated("could not write base blockhash"));
}
}