index: Drop legacy -txindex check

This commit is contained in:
MarcoFalke
2023-08-01 11:01:48 +02:00
parent fa69148a0a
commit fa8685597e
4 changed files with 12 additions and 40 deletions

View File

@@ -6,15 +6,23 @@
#include <txdb.h>
#include <chain.h>
#include <coins.h>
#include <dbwrapper.h>
#include <kernel/cs_main.h>
#include <logging.h>
#include <pow.h>
#include <primitives/transaction.h>
#include <random.h>
#include <serialize.h>
#include <sync.h>
#include <uint256.h>
#include <util/signalinterrupt.h>
#include <util/translation.h>
#include <util/vector.h>
#include <stdint.h>
#include <cassert>
#include <cstdlib>
#include <iterator>
static constexpr uint8_t DB_COIN{'C'};
static constexpr uint8_t DB_BLOCK_FILES{'f'};
@@ -28,26 +36,9 @@ static constexpr uint8_t DB_LAST_BLOCK{'l'};
// Keys used in previous version that might still be found in the DB:
static constexpr uint8_t DB_COINS{'c'};
static constexpr uint8_t DB_TXINDEX_BLOCK{'T'};
// uint8_t DB_TXINDEX{'t'}
util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db)
{
CBlockLocator ignored{};
if (block_tree_db.Read(DB_TXINDEX_BLOCK, ignored)) {
return util::Error{_("The -txindex upgrade started by a previous version cannot 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 util::Error{Untranslated("Failed to write block index db flag 'txindex'='0'")};
}
return util::Error{_("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 {};
}
// CBlockTreeDB::DB_TXINDEX_BLOCK{'T'};
// CBlockTreeDB::DB_TXINDEX{'t'}
// CBlockTreeDB::ReadFlag("txindex")
bool CCoinsViewDB::NeedsUpgrade()
{