Skip to content

Commit

Permalink
rework reset_chain_head - rewind txhashset then header MMR
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Apr 7, 2021
1 parent e692f0d commit d4f06f8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions chain/src/chain.rs
Expand Up @@ -248,13 +248,6 @@ impl Chain {

let header = batch.get_block_header(&head.hash())?;

// Rewind and reapply headers to reset the header MMR
txhashset::header_extending(&mut header_pmmr, &mut batch, |ext, batch| {
self.rewind_and_apply_header_fork(&header, ext, batch)?;
batch.save_header_head(&head)?;
Ok(())
})?;

// Rewind and reapply blocks to reset the output/rangeproof/kernel MMR.
txhashset::extending(
&mut header_pmmr,
Expand All @@ -267,6 +260,14 @@ impl Chain {
},
)?;

// If the rewind of full blocks was successful then we can rewind the header MMR.
// Rewind and reapply headers to reset the header MMR.
txhashset::header_extending(&mut header_pmmr, &mut batch, |ext, batch| {
self.rewind_and_apply_header_fork(&header, ext, batch)?;
batch.save_header_head(&head)?;
Ok(())
})?;

batch.commit()?;

Ok(())
Expand Down

0 comments on commit d4f06f8

Please sign in to comment.