Skip to content

Commit 55588dc

Browse files
committed
Refactor: move tipIndex/blockcache update at the end of DisconnectTip
1 parent 906e7cd commit 55588dc

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/validation.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,15 +1932,6 @@ bool static DisconnectTip(CValidationState& state, const CChainParams& chainpara
19321932
}
19331933
}
19341934

1935-
// Update MN manager cache
1936-
deterministicMNManager->SetTipIndex(pindexDelete->pprev);
1937-
// replace the cached hash of pindexDelete with the hash of the block
1938-
// at depth CACHED_BLOCK_HASHES if it exists, or empty hash otherwise.
1939-
if ((unsigned) pindexDelete->nHeight >= CACHED_BLOCK_HASHES) {
1940-
mnodeman.CacheBlockHash(chainActive[pindexDelete->nHeight - CACHED_BLOCK_HASHES]);
1941-
} else {
1942-
mnodeman.UncacheBlockHash(pindexDelete);
1943-
}
19441935
// Evict from mempool if the anchor changes
19451936
if (saplingAnchorBeforeDisconnect != saplingAnchorAfterDisconnect) {
19461937
// The anchor may not change between block disconnects,
@@ -1953,6 +1944,16 @@ bool static DisconnectTip(CValidationState& state, const CChainParams& chainpara
19531944
// 0-confirmed or conflicted:
19541945
GetMainSignals().BlockDisconnected(pblock, pindexDelete->GetBlockHash(), pindexDelete->nHeight, pindexDelete->GetBlockTime());
19551946

1947+
// Update MN manager cache
1948+
deterministicMNManager->SetTipIndex(pindexDelete->pprev);
1949+
// replace the cached hash of pindexDelete with the hash of the block
1950+
// at depth CACHED_BLOCK_HASHES if it exists, or empty hash otherwise.
1951+
if ((unsigned) pindexDelete->nHeight >= CACHED_BLOCK_HASHES) {
1952+
mnodeman.CacheBlockHash(chainActive[pindexDelete->nHeight - CACHED_BLOCK_HASHES]);
1953+
} else {
1954+
mnodeman.UncacheBlockHash(pindexDelete);
1955+
}
1956+
19561957
return true;
19571958
}
19581959

0 commit comments

Comments
 (0)