From 884d659b7d8945e20fb50e99cc3d960c20ad2efd Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 12 Aug 2024 18:12:53 +0700 Subject: [PATCH 1/3] feat: only require reindexing when the index was off going to off --- src/init.cpp | 12 ++++++------ test/functional/feature_addressindex.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 04b4876f711f0..ae17f89c8f103 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1917,20 +1917,20 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) } // Check for changed -addressindex state - if (fAddressIndex != args.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX)) { - strLoadError = _("You need to rebuild the database using -reindex to change -addressindex"); + if (!fAddressIndex && fAddressIndex != args.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX)) { + strLoadError = _("You need to rebuild the database using -reindex to enable -addressindex"); break; } // Check for changed -timestampindex state - if (fTimestampIndex != args.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX)) { - strLoadError = _("You need to rebuild the database using -reindex to change -timestampindex"); + if (!fTimestampIndex && fTimestampIndex != args.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX)) { + strLoadError = _("You need to rebuild the database using -reindex to enable -timestampindex"); break; } // Check for changed -spentindex state - if (fSpentIndex != args.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX)) { - strLoadError = _("You need to rebuild the database using -reindex to change -spentindex"); + if (!fSpentIndex && fSpentIndex != args.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX)) { + strLoadError = _("You need to rebuild the database using -reindex to enable -spentindex"); break; } diff --git a/test/functional/feature_addressindex.py b/test/functional/feature_addressindex.py index 1cf66fd5d2bdf..ca7807faf30a6 100755 --- a/test/functional/feature_addressindex.py +++ b/test/functional/feature_addressindex.py @@ -42,12 +42,12 @@ def setup_network(self): def run_test(self): self.log.info("Test that settings can't be changed without -reindex...") self.stop_node(1) - self.nodes[1].assert_start_raises_init_error(["-addressindex=0"], "You need to rebuild the database using -reindex to change -addressindex", match=ErrorMatch.PARTIAL_REGEX) + self.nodes[1].assert_start_raises_init_error(["-addressindex=0"], "You need to rebuild the database using -reindex to enable -addressindex", match=ErrorMatch.PARTIAL_REGEX) self.start_node(1, ["-addressindex=0", "-reindex"]) self.connect_nodes(0, 1) self.sync_all() self.stop_node(1) - self.nodes[1].assert_start_raises_init_error(["-addressindex"], "You need to rebuild the database using -reindex to change -addressindex", match=ErrorMatch.PARTIAL_REGEX) + self.nodes[1].assert_start_raises_init_error(["-addressindex"], "You need to rebuild the database using -reindex to enable -addressindex", match=ErrorMatch.PARTIAL_REGEX) self.start_node(1, ["-addressindex", "-reindex"]) self.connect_nodes(0, 1) self.sync_all() From 59761d55926a0c186593af8214f6cd0afc86c8c9 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 24 Sep 2024 09:02:54 -0500 Subject: [PATCH 2/3] don't need to reindex to disable in tests --- test/functional/feature_addressindex.py | 3 +-- test/functional/feature_spentindex.py | 3 +-- test/functional/feature_timestampindex.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/test/functional/feature_addressindex.py b/test/functional/feature_addressindex.py index ca7807faf30a6..4bd46bbedc02a 100755 --- a/test/functional/feature_addressindex.py +++ b/test/functional/feature_addressindex.py @@ -42,8 +42,7 @@ def setup_network(self): def run_test(self): self.log.info("Test that settings can't be changed without -reindex...") self.stop_node(1) - self.nodes[1].assert_start_raises_init_error(["-addressindex=0"], "You need to rebuild the database using -reindex to enable -addressindex", match=ErrorMatch.PARTIAL_REGEX) - self.start_node(1, ["-addressindex=0", "-reindex"]) + self.start_node(1, ["-addressindex=0"]) self.connect_nodes(0, 1) self.sync_all() self.stop_node(1) diff --git a/test/functional/feature_spentindex.py b/test/functional/feature_spentindex.py index a8837348dbe4e..0f10782f1bba6 100755 --- a/test/functional/feature_spentindex.py +++ b/test/functional/feature_spentindex.py @@ -43,8 +43,7 @@ def setup_network(self): def run_test(self): self.log.info("Test that settings can't be changed without -reindex...") self.stop_node(1) - self.nodes[1].assert_start_raises_init_error(["-spentindex=0"], "You need to rebuild the database using -reindex to change -spentindex", match=ErrorMatch.PARTIAL_REGEX) - self.start_node(1, ["-spentindex=0", "-reindex"]) + self.start_node(1, ["-spentindex=0"]) self.connect_nodes(0, 1) self.sync_all() self.stop_node(1) diff --git a/test/functional/feature_timestampindex.py b/test/functional/feature_timestampindex.py index 454cdc71efda6..86cb22297e1c3 100755 --- a/test/functional/feature_timestampindex.py +++ b/test/functional/feature_timestampindex.py @@ -35,8 +35,7 @@ def setup_network(self): def run_test(self): self.log.info("Test that settings can't be changed without -reindex...") self.stop_node(1) - self.nodes[1].assert_start_raises_init_error(["-timestampindex=0"], "You need to rebuild the database using -reindex to change -timestampindex", match=ErrorMatch.PARTIAL_REGEX) - self.start_node(1, ["-timestampindex=0", "-reindex"]) + self.start_node(1, ["-timestampindex=0") self.connect_nodes(0, 1) self.sync_all() self.stop_node(1) From 84ff7b7df97515f0dea4ee39bc53d1341ab4361d Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:35:28 -0500 Subject: [PATCH 3/3] Update test/functional/feature_timestampindex.py Co-authored-by: UdjinM6 --- test/functional/feature_timestampindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/feature_timestampindex.py b/test/functional/feature_timestampindex.py index 86cb22297e1c3..9f3573e3220b7 100755 --- a/test/functional/feature_timestampindex.py +++ b/test/functional/feature_timestampindex.py @@ -35,7 +35,7 @@ def setup_network(self): def run_test(self): self.log.info("Test that settings can't be changed without -reindex...") self.stop_node(1) - self.start_node(1, ["-timestampindex=0") + self.start_node(1, ["-timestampindex=0"]) self.connect_nodes(0, 1) self.sync_all() self.stop_node(1)