mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #6203: feat: only require reindexing when the index was on going to off
c96f9e0285
feat: only require reindexing when the index was off going to off (pasta) Pull request description: ## What was done? It does not seem reasonable that we need to reindex when turning indexes off. this logic was introduced ine0781095f0
## How Has This Been Tested? Hasn't ## Breaking Changes None, basically ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACKc96f9e0285
Tree-SHA512: a5b634b9fbb6632b35286055a8e5b8db340738b7327a7d860e645ec1f6ef5b5cddc140a3e1c51b09c2f47db375c83e7c53fe5eaf221ab8df1d173caf50fa862d
This commit is contained in:
commit
ce28029063
36
src/init.cpp
36
src/init.cpp
@ -1952,23 +1952,31 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
return InitError(_("Incorrect or no devnet genesis block found. Wrong datadir for devnet specified?"));
|
return InitError(_("Incorrect or no devnet genesis block found. Wrong datadir for devnet specified?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for changed -addressindex state
|
if (!fReset && !fReindexChainState) {
|
||||||
if (fAddressIndex != args.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX)) {
|
// Check for changed -addressindex state
|
||||||
strLoadError = _("You need to rebuild the database using -reindex to change -addressindex");
|
if (!fAddressIndex && fAddressIndex != args.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX)) {
|
||||||
break;
|
strLoadError = _("You need to rebuild the database using -reindex to enable -addressindex");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for changed -timestampindex state
|
||||||
|
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 && fSpentIndex != args.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX)) {
|
||||||
|
strLoadError = _("You need to rebuild the database using -reindex to enable -spentindex");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for changed -timestampindex state
|
chainman.InitAdditionalIndexes();
|
||||||
if (fTimestampIndex != args.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX)) {
|
|
||||||
strLoadError = _("You need to rebuild the database using -reindex to change -timestampindex");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for changed -spentindex state
|
LogPrintf("%s: address index %s\n", __func__, fAddressIndex ? "enabled" : "disabled");
|
||||||
if (fSpentIndex != args.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX)) {
|
LogPrintf("%s: timestamp index %s\n", __func__, fTimestampIndex ? "enabled" : "disabled");
|
||||||
strLoadError = _("You need to rebuild the database using -reindex to change -spentindex");
|
LogPrintf("%s: spent index %s\n", __func__, fSpentIndex ? "enabled" : "disabled");
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
|
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
|
||||||
// in the past, but is now trying to run unpruned.
|
// in the past, but is now trying to run unpruned.
|
||||||
|
@ -394,16 +394,10 @@ bool BlockManager::LoadBlockIndexDB()
|
|||||||
|
|
||||||
// Check whether we have an address index
|
// Check whether we have an address index
|
||||||
m_block_tree_db->ReadFlag("addressindex", fAddressIndex);
|
m_block_tree_db->ReadFlag("addressindex", fAddressIndex);
|
||||||
LogPrintf("%s: address index %s\n", __func__, fAddressIndex ? "enabled" : "disabled");
|
|
||||||
|
|
||||||
// Check whether we have a timestamp index
|
// Check whether we have a timestamp index
|
||||||
m_block_tree_db->ReadFlag("timestampindex", fTimestampIndex);
|
m_block_tree_db->ReadFlag("timestampindex", fTimestampIndex);
|
||||||
LogPrintf("%s: timestamp index %s\n", __func__, fTimestampIndex ? "enabled" : "disabled");
|
|
||||||
|
|
||||||
// Check whether we have a spent index
|
// Check whether we have a spent index
|
||||||
m_block_tree_db->ReadFlag("spentindex", fSpentIndex);
|
m_block_tree_db->ReadFlag("spentindex", fSpentIndex);
|
||||||
LogPrintf("%s: spent index %s\n", __func__, fSpentIndex ? "enabled" : "disabled");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4535,22 +4535,27 @@ bool ChainstateManager::LoadBlockIndex()
|
|||||||
// needs_init.
|
// needs_init.
|
||||||
|
|
||||||
LogPrintf("Initializing databases...\n");
|
LogPrintf("Initializing databases...\n");
|
||||||
|
InitAdditionalIndexes();
|
||||||
// Use the provided setting for -addressindex in the new database
|
|
||||||
fAddressIndex = gArgs.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX);
|
|
||||||
m_blockman.m_block_tree_db->WriteFlag("addressindex", fAddressIndex);
|
|
||||||
|
|
||||||
// Use the provided setting for -timestampindex in the new database
|
|
||||||
fTimestampIndex = gArgs.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX);
|
|
||||||
m_blockman.m_block_tree_db->WriteFlag("timestampindex", fTimestampIndex);
|
|
||||||
|
|
||||||
// Use the provided setting for -spentindex in the new database
|
|
||||||
fSpentIndex = gArgs.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX);
|
|
||||||
m_blockman.m_block_tree_db->WriteFlag("spentindex", fSpentIndex);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChainstateManager::InitAdditionalIndexes()
|
||||||
|
{
|
||||||
|
// Use the provided setting for -addressindex in the new database
|
||||||
|
fAddressIndex = gArgs.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX);
|
||||||
|
m_blockman.m_block_tree_db->WriteFlag("addressindex", fAddressIndex);
|
||||||
|
|
||||||
|
// Use the provided setting for -timestampindex in the new database
|
||||||
|
fTimestampIndex = gArgs.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX);
|
||||||
|
m_blockman.m_block_tree_db->WriteFlag("timestampindex", fTimestampIndex);
|
||||||
|
|
||||||
|
// Use the provided setting for -spentindex in the new database
|
||||||
|
fSpentIndex = gArgs.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX);
|
||||||
|
m_blockman.m_block_tree_db->WriteFlag("spentindex", fSpentIndex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool CChainState::AddGenesisBlock(const CBlock& block, BlockValidationState& state)
|
bool CChainState::AddGenesisBlock(const CBlock& block, BlockValidationState& state)
|
||||||
{
|
{
|
||||||
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0, m_chain, m_params, nullptr)};
|
FlatFilePos blockPos{m_blockman.SaveBlockToDisk(block, 0, m_chain, m_params, nullptr)};
|
||||||
|
@ -1044,6 +1044,8 @@ public:
|
|||||||
|
|
||||||
//! Load the block tree and coins database from disk, initializing state if we're running with -reindex
|
//! Load the block tree and coins database from disk, initializing state if we're running with -reindex
|
||||||
bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
//! Initialize additional indexes and store their flags to disk
|
||||||
|
void InitAdditionalIndexes() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
//! Check to see if caches are out of balance and if so, call
|
//! Check to see if caches are out of balance and if so, call
|
||||||
//! ResizeCoinsCaches() as needed.
|
//! ResizeCoinsCaches() as needed.
|
||||||
|
@ -38,14 +38,13 @@ class AddressIndexTest(BitcoinTestFramework):
|
|||||||
self.import_deterministic_coinbase_privkeys()
|
self.import_deterministic_coinbase_privkeys()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.log.info("Test that settings can't be changed without -reindex...")
|
self.log.info("Test that settings can be disabled without -reindex...")
|
||||||
self.stop_node(1)
|
self.restart_node(1, ["-addressindex=0"])
|
||||||
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.connect_nodes(0, 1)
|
self.connect_nodes(0, 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
self.log.info("Test that settings can't be enabled without -reindex...")
|
||||||
self.stop_node(1)
|
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.start_node(1, ["-addressindex", "-reindex"])
|
||||||
self.connect_nodes(0, 1)
|
self.connect_nodes(0, 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
@ -40,14 +40,13 @@ class SpentIndexTest(BitcoinTestFramework):
|
|||||||
self.import_deterministic_coinbase_privkeys()
|
self.import_deterministic_coinbase_privkeys()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.log.info("Test that settings can't be changed without -reindex...")
|
self.log.info("Test that settings can be disabled without -reindex...")
|
||||||
self.stop_node(1)
|
self.restart_node(1, ["-spentindex=0"])
|
||||||
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.connect_nodes(0, 1)
|
self.connect_nodes(0, 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
self.log.info("Test that settings can't be enabled without -reindex...")
|
||||||
self.stop_node(1)
|
self.stop_node(1)
|
||||||
self.nodes[1].assert_start_raises_init_error(["-spentindex"], "You need to rebuild the database using -reindex to change -spentindex", match=ErrorMatch.PARTIAL_REGEX)
|
self.nodes[1].assert_start_raises_init_error(["-spentindex"], "You need to rebuild the database using -reindex to enable -spentindex", match=ErrorMatch.PARTIAL_REGEX)
|
||||||
self.start_node(1, ["-spentindex", "-reindex"])
|
self.start_node(1, ["-spentindex", "-reindex"])
|
||||||
self.connect_nodes(0, 1)
|
self.connect_nodes(0, 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
@ -33,14 +33,13 @@ class TimestampIndexTest(BitcoinTestFramework):
|
|||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.log.info("Test that settings can't be changed without -reindex...")
|
self.log.info("Test that settings can be disabled without -reindex...")
|
||||||
self.stop_node(1)
|
self.restart_node(1, ["-timestampindex=0"])
|
||||||
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.connect_nodes(0, 1)
|
self.connect_nodes(0, 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
self.log.info("Test that settings can't be enabled without -reindex...")
|
||||||
self.stop_node(1)
|
self.stop_node(1)
|
||||||
self.nodes[1].assert_start_raises_init_error(["-timestampindex"], "You need to rebuild the database using -reindex to change -timestampindex", match=ErrorMatch.PARTIAL_REGEX)
|
self.nodes[1].assert_start_raises_init_error(["-timestampindex"], "You need to rebuild the database using -reindex to enable -timestampindex", match=ErrorMatch.PARTIAL_REGEX)
|
||||||
self.start_node(1, ["-timestampindex", "-reindex"])
|
self.start_node(1, ["-timestampindex", "-reindex"])
|
||||||
self.connect_nodes(0, 1)
|
self.connect_nodes(0, 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
Loading…
Reference in New Issue
Block a user