mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
account for the utxo rewind when attempting to fix a bad chain init (#3229)
This commit is contained in:
parent
0d2e58e90e
commit
3c040b96e1
1 changed files with 14 additions and 5 deletions
|
@ -1542,15 +1542,24 @@ fn setup_head(
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// We may have corrupted the MMR backend files last time we stopped the
|
// We may have corrupted the MMR backend files last time we stopped the
|
||||||
// node. If this appears to be the case revert the head to the previous
|
// node. If this happens we rewind to the previous header,
|
||||||
// header and try again
|
// delete the "bad" block and try again.
|
||||||
let prev_header = batch.get_block_header(&head.prev_block_h)?;
|
let prev_header = batch.get_block_header(&head.prev_block_h)?;
|
||||||
|
|
||||||
|
txhashset::extending(header_pmmr, txhashset, &mut batch, |ext, batch| {
|
||||||
|
pipe::rewind_and_apply_fork(&prev_header, ext, batch)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
// Now "undo" the latest block and forget it ever existed.
|
||||||
|
// We will request it from a peer during sync as necessary.
|
||||||
|
{
|
||||||
let _ = batch.delete_block(&header.hash());
|
let _ = batch.delete_block(&header.hash());
|
||||||
head = Tip::from_header(&prev_header);
|
head = Tip::from_header(&prev_header);
|
||||||
batch.save_body_head(&head)?;
|
batch.save_body_head(&head)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(NotFoundErr(_)) => {
|
Err(NotFoundErr(_)) => {
|
||||||
let mut sums = BlockSums::default();
|
let mut sums = BlockSums::default();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue