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