@@ -2137,17 +2137,13 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
2137
2137
2138
2138
// Mark the block itself as invalid.
2139
2139
pindex->nStatus |= BLOCK_FAILED_VALID;
2140
- if (!pblocktree->WriteBlockIndex (CDiskBlockIndex (pindex))) {
2141
- return state.Abort (" Failed to update block index" );
2142
- }
2140
+ setDirtyBlockIndex.insert (pindex);
2143
2141
setBlockIndexCandidates.erase (pindex);
2144
2142
2145
2143
while (chainActive.Contains (pindex)) {
2146
2144
CBlockIndex *pindexWalk = chainActive.Tip ();
2147
2145
pindexWalk->nStatus |= BLOCK_FAILED_CHILD;
2148
- if (!pblocktree->WriteBlockIndex (CDiskBlockIndex (pindexWalk))) {
2149
- return state.Abort (" Failed to update block index" );
2150
- }
2146
+ setDirtyBlockIndex.insert (pindexWalk);
2151
2147
setBlockIndexCandidates.erase (pindexWalk);
2152
2148
// ActivateBestChain considers blocks already in chainActive
2153
2149
// unconditionally valid already, so force disconnect away from it.
@@ -2180,9 +2176,7 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) {
2180
2176
while (it != mapBlockIndex.end ()) {
2181
2177
if (!it->second ->IsValid () && it->second ->GetAncestor (nHeight) == pindex) {
2182
2178
it->second ->nStatus &= ~BLOCK_FAILED_MASK;
2183
- if (!pblocktree->WriteBlockIndex (CDiskBlockIndex (pindex))) {
2184
- return state.Abort (" Failed to update block index" );
2185
- }
2179
+ setDirtyBlockIndex.insert (it->second );
2186
2180
if (it->second ->IsValid (BLOCK_VALID_TRANSACTIONS) && it->second ->nChainTx && setBlockIndexCandidates.value_comp ()(chainActive.Tip (), it->second )) {
2187
2181
setBlockIndexCandidates.insert (it->second );
2188
2182
}
@@ -2196,9 +2190,9 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) {
2196
2190
2197
2191
// Remove the invalidity flag from all ancestors too.
2198
2192
while (pindex != NULL ) {
2199
- pindex->nStatus &= ~ BLOCK_FAILED_MASK;
2200
- if (!pblocktree-> WriteBlockIndex ( CDiskBlockIndex (pindex))) {
2201
- return state. Abort ( " Failed to update block index " );
2193
+ if ( pindex->nStatus & BLOCK_FAILED_MASK) {
2194
+ pindex-> nStatus &= ~BLOCK_FAILED_MASK;
2195
+ setDirtyBlockIndex. insert (pindex );
2202
2196
}
2203
2197
pindex = pindex->pprev ;
2204
2198
}
0 commit comments