Skip to content

Commit fa86855

Browse files
author
MarcoFalke
committed
index: Drop legacy -txindex check
1 parent fa69148 commit fa86855

File tree

4 files changed

+12
-40
lines changed

4 files changed

+12
-40
lines changed

src/init.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,11 +1550,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15501550
// ********************************************************* Step 8: start indexers
15511551

15521552
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
1553-
auto result{WITH_LOCK(cs_main, return CheckLegacyTxindex(*Assert(chainman.m_blockman.m_block_tree_db)))};
1554-
if (!result) {
1555-
return InitError(util::ErrorString(result));
1556-
}
1557-
15581553
g_txindex = std::make_unique<TxIndex>(interfaces::MakeChain(node), cache_sizes.tx_index, false, fReindex);
15591554
node.indexes.emplace_back(g_txindex.get());
15601555
}

src/txdb.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@
66
#include <txdb.h>
77

88
#include <chain.h>
9+
#include <coins.h>
10+
#include <dbwrapper.h>
11+
#include <kernel/cs_main.h>
912
#include <logging.h>
1013
#include <pow.h>
14+
#include <primitives/transaction.h>
1115
#include <random.h>
16+
#include <serialize.h>
17+
#include <sync.h>
1218
#include <uint256.h>
1319
#include <util/signalinterrupt.h>
1420
#include <util/translation.h>
1521
#include <util/vector.h>
1622

17-
#include <stdint.h>
23+
#include <cassert>
24+
#include <cstdlib>
25+
#include <iterator>
1826

1927
static constexpr uint8_t DB_COIN{'C'};
2028
static constexpr uint8_t DB_BLOCK_FILES{'f'};
@@ -28,26 +36,9 @@ static constexpr uint8_t DB_LAST_BLOCK{'l'};
2836

2937
// Keys used in previous version that might still be found in the DB:
3038
static constexpr uint8_t DB_COINS{'c'};
31-
static constexpr uint8_t DB_TXINDEX_BLOCK{'T'};
32-
// uint8_t DB_TXINDEX{'t'}
33-
34-
util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db)
35-
{
36-
CBlockLocator ignored{};
37-
if (block_tree_db.Read(DB_TXINDEX_BLOCK, ignored)) {
38-
return util::Error{_("The -txindex upgrade started by a previous version cannot be completed. Restart with the previous version or run a full -reindex.")};
39-
}
40-
bool txindex_legacy_flag{false};
41-
block_tree_db.ReadFlag("txindex", txindex_legacy_flag);
42-
if (txindex_legacy_flag) {
43-
// Disable legacy txindex and warn once about occupied disk space
44-
if (!block_tree_db.WriteFlag("txindex", false)) {
45-
return util::Error{Untranslated("Failed to write block index db flag 'txindex'='0'")};
46-
}
47-
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.")};
48-
}
49-
return {};
50-
}
39+
// CBlockTreeDB::DB_TXINDEX_BLOCK{'T'};
40+
// CBlockTreeDB::DB_TXINDEX{'t'}
41+
// CBlockTreeDB::ReadFlag("txindex")
5142

5243
bool CCoinsViewDB::NeedsUpgrade()
5344
{

src/txdb.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <kernel/cs_main.h>
1212
#include <sync.h>
1313
#include <util/fs.h>
14-
#include <util/result.h>
1514

1615
#include <cstddef>
1716
#include <cstdint>
@@ -105,6 +104,4 @@ class CBlockTreeDB : public CDBWrapper
105104
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
106105
};
107106

108-
[[nodiscard]] util::Result<void> CheckLegacyTxindex(CBlockTreeDB& block_tree_db);
109-
110107
#endif // BITCOIN_TXDB_H

test/functional/feature_txindex_compatibility.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
Previous releases are required by this test, see test/README.md.
88
"""
99

10-
import os
1110
import shutil
1211

1312
from test_framework.test_framework import BitcoinTestFramework
@@ -55,23 +54,13 @@ def run_test(self):
5554
drop_index_chain_dir = self.nodes[1].chain_path
5655
shutil.rmtree(drop_index_chain_dir)
5756
shutil.copytree(legacy_chain_dir, drop_index_chain_dir)
58-
self.nodes[1].assert_start_raises_init_error(
59-
extra_args=["-txindex"],
60-
expected_msg="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.",
61-
)
6257
# Build txindex from scratch and check there is no error this time
6358
self.start_node(1, extra_args=["-txindex"])
6459
self.wait_until(lambda: self.nodes[1].getindexinfo()["txindex"]["synced"] == True)
6560
self.nodes[1].getrawtransaction(txid=spend_utxo["txid"]) # Requires -txindex
6661

6762
self.stop_nodes()
6863

69-
self.log.info("Check migrated txindex cannot be read by legacy node")
70-
err_msg = f": You need to rebuild the database using -reindex to change -txindex.{os.linesep}Please restart with -reindex or -reindex-chainstate to recover."
71-
shutil.rmtree(legacy_chain_dir)
72-
shutil.copytree(drop_index_chain_dir, legacy_chain_dir)
73-
self.nodes[0].assert_start_raises_init_error(extra_args=["-txindex"], expected_msg=err_msg)
74-
7564

7665
if __name__ == "__main__":
7766
TxindexCompatibilityTest().main()

0 commit comments

Comments
 (0)