Merge 71bdf0bff1 into merged_master (Bitcoin PR bitcoin/bitcoin#22626)

This commit is contained in:
Byron Hambly 2023-04-21 12:36:24 +00:00
commit 8d89f4e102
8 changed files with 45 additions and 176 deletions

View file

@ -5,6 +5,7 @@
#include <txdb.h>
#include <chain.h>
#include <node/ui_interface.h>
#include <pow.h>
#include <random.h>
@ -35,6 +36,28 @@ static const char DB_PEGIN_FLAG = 'w';
// static const char DB_INVALID_BLOCK_Q = 'q'; // No longer used, but avoid reuse.
static const char DB_PAK = 'p';
// Keys used in previous version that might still be found in the DB:
static constexpr uint8_t DB_TXINDEX_BLOCK{'T'};
// uint8_t DB_TXINDEX{'t'}
std::optional<bilingual_str> CheckLegacyTxindex(CBlockTreeDB& block_tree_db)
{
CBlockLocator ignored{};
if (block_tree_db.Read(DB_TXINDEX_BLOCK, ignored)) {
return _("The -txindex upgrade started by a previous version can not be completed. Restart with the previous version or run a full -reindex.");
}
bool txindex_legacy_flag{false};
block_tree_db.ReadFlag("txindex", txindex_legacy_flag);
if (txindex_legacy_flag) {
// Disable legacy txindex and warn once about occupied disk space
if (!block_tree_db.WriteFlag("txindex", false)) {
return Untranslated("Failed to write block index db flag 'txindex'='0'");
}
return _("The block index db contains a legacy 'txindex'. To clear the occupied disk space, run a full -reindex, otherwise ignore this error. This error message will not be displayed again.");
}
return std::nullopt;
}
namespace {
struct CoinEntry {