Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: only require reindexing when the index was on going to off #6203

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 2 additions & 3 deletions test/functional/feature_addressindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ 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.start_node(1, ["-addressindex=0", "-reindex"])
self.start_node(1, ["-addressindex=0"])
Comment on lines 44 to +45
Copy link
Collaborator

@knst knst Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-self.stop_node(1)
-self.start_node(1, ["-addressindex=0"])
+self.restart_node(1, "[-addressindex=0"])

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()
Expand Down
3 changes: 1 addition & 2 deletions test/functional/feature_spentindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions test/functional/feature_timestampindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
PastaPastaPasta marked this conversation as resolved.
Show resolved Hide resolved
self.connect_nodes(0, 1)
self.sync_all()
self.stop_node(1)
Expand Down
Loading