mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge #15552: 0.18: Granular invalidateblock and RewindBlockIndex
519b0bc5dcMake last disconnected block BLOCK_FAILED_VALID, even when aborted (Pieter Wuille)8d220417cdOptimization: don't add txn back to mempool after 10 invalidates (Pieter Wuille)9ce9c37004Prevent callback overruns in InvalidateBlock and RewindBlockIndex (Pieter Wuille)9bb32eb571Release cs_main during InvalidateBlock iterations (Pieter Wuille)9b1ff5c742Call InvalidateBlock without cs_main held (Pieter Wuille)241b2c74acMake RewindBlockIndex interruptible (Pieter Wuille)880ce7d46bCall RewindBlockIndex without cs_main held (Pieter Wuille)436f7d735fRelease cs_main during RewindBlockIndex operation (Pieter Wuille)1d342875c2Merge the disconnection and erasing loops in RewindBlockIndex (Pieter Wuille)32b2696ab4Move erasure of non-active blocks to a separate loop in RewindBlockIndex (Pieter Wuille)9d6dcc52c6Abstract EraseBlockData out of RewindBlockIndex (Pieter Wuille) Pull request description: Same repo and branch like "Granular invalidateblock and RewindBlockIndex #15402 ", can be merged as is. This saves us all the cherry-picks and review of the backport cherry-picks. Tree-SHA512: 20c27c5f807c3d85e0072f9e2cdefad4ad7d329d6b26658a00844d5fcf0ed729059daf765e04e6382db2b5915117b15949cd4989d864917ab105c92e2e5e9986
This commit is contained in:
commit
0fd3632868
4 changed files with 212 additions and 138 deletions
31
src/init.cpp
31
src/init.cpp
|
|
@ -1468,11 +1468,11 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
|
||||
uiInterface.InitMessage(_("Loading block index..."));
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
do {
|
||||
const int64_t load_block_index_start_time = GetTimeMillis();
|
||||
bool is_coinsview_empty;
|
||||
try {
|
||||
LOCK(cs_main);
|
||||
UnloadBlockIndex();
|
||||
pcoinsTip.reset();
|
||||
pcoinsdbview.reset();
|
||||
|
|
@ -1544,7 +1544,7 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
// The on-disk coinsdb is now in a good state, create the cache
|
||||
pcoinsTip.reset(new CCoinsViewCache(pcoinscatcher.get()));
|
||||
|
||||
bool is_coinsview_empty = fReset || fReindexChainState || pcoinsTip->GetBestBlock().IsNull();
|
||||
is_coinsview_empty = fReset || fReindexChainState || pcoinsTip->GetBestBlock().IsNull();
|
||||
if (!is_coinsview_empty) {
|
||||
// LoadChainTip sets chainActive based on pcoinsTip's best block
|
||||
if (!LoadChainTip(chainparams)) {
|
||||
|
|
@ -1553,18 +1553,25 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
}
|
||||
assert(chainActive.Tip() != nullptr);
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
LogPrintf("%s\n", e.what());
|
||||
strLoadError = _("Error opening block database");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fReset) {
|
||||
// Note that RewindBlockIndex MUST run even if we're about to -reindex-chainstate.
|
||||
// It both disconnects blocks based on chainActive, and drops block data in
|
||||
// mapBlockIndex based on lack of available witness data.
|
||||
uiInterface.InitMessage(_("Rewinding blocks..."));
|
||||
if (!RewindBlockIndex(chainparams)) {
|
||||
strLoadError = _("Unable to rewind the database to a pre-fork state. You will need to redownload the blockchain");
|
||||
break;
|
||||
}
|
||||
if (!fReset) {
|
||||
// Note that RewindBlockIndex MUST run even if we're about to -reindex-chainstate.
|
||||
// It both disconnects blocks based on chainActive, and drops block data in
|
||||
// mapBlockIndex based on lack of available witness data.
|
||||
uiInterface.InitMessage(_("Rewinding blocks..."));
|
||||
if (!RewindBlockIndex(chainparams)) {
|
||||
strLoadError = _("Unable to rewind the database to a pre-fork state. You will need to redownload the blockchain");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
LOCK(cs_main);
|
||||
if (!is_coinsview_empty) {
|
||||
uiInterface.InitMessage(_("Verifying blocks..."));
|
||||
if (fHavePruned && gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue