Skip to content

Commit

Permalink
flush more often on ibd (#291)
Browse files Browse the repository at this point in the history
If we die (or get stopped) while on IBD, we might lose all our work.
This commit tries to fix this by flushing more often during IBD, so our
work gets persisted.
  • Loading branch information
Davidson-Souza authored Nov 29, 2024
1 parent 8ede062 commit a909627
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/floresta-chain/src/pruned_utreexo/chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ impl<PersistedState: ChainStore> UpdatableChainstate for ChainState<PersistedSta
block.txdata.len()
);

if !self.is_in_idb() {
if !self.is_in_idb() || height % 10_000 == 0 {
self.flush()?;
}

Expand Down
1 change: 1 addition & 0 deletions crates/floresta-wire/src/p2p_wire/chain_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ where
// We downloaded all headers in the most-pow chain, and all our peers agree
// this is the most-pow chain, we're done!
if self.1.state == ChainSelectorState::Done {
try_and_log!(self.chain.flush());
break;
}

Expand Down

0 comments on commit a909627

Please sign in to comment.