mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix(engine): attempt to advance persistence after it finished (#13928)
This commit is contained in:
@ -1184,28 +1184,6 @@ where
|
|||||||
/// If we're currently awaiting a response this will try to receive the response (non-blocking)
|
/// If we're currently awaiting a response this will try to receive the response (non-blocking)
|
||||||
/// or send a new persistence action if necessary.
|
/// or send a new persistence action if necessary.
|
||||||
fn advance_persistence(&mut self) -> Result<(), AdvancePersistenceError> {
|
fn advance_persistence(&mut self) -> Result<(), AdvancePersistenceError> {
|
||||||
if !self.persistence_state.in_progress() {
|
|
||||||
if let Some(new_tip_num) = self.persistence_state.remove_above_state.pop_front() {
|
|
||||||
debug!(target: "engine::tree", ?new_tip_num, remove_state=?self.persistence_state.remove_above_state, last_persisted_block_number=?self.persistence_state.last_persisted_block.number, "Removing blocks using persistence task");
|
|
||||||
if new_tip_num < self.persistence_state.last_persisted_block.number {
|
|
||||||
debug!(target: "engine::tree", ?new_tip_num, "Starting remove blocks job");
|
|
||||||
let (tx, rx) = oneshot::channel();
|
|
||||||
let _ = self.persistence.remove_blocks_above(new_tip_num, tx);
|
|
||||||
self.persistence_state.start(rx);
|
|
||||||
}
|
|
||||||
} else if self.should_persist() {
|
|
||||||
let blocks_to_persist = self.get_canonical_blocks_to_persist();
|
|
||||||
if blocks_to_persist.is_empty() {
|
|
||||||
debug!(target: "engine::tree", "Returned empty set of blocks to persist");
|
|
||||||
} else {
|
|
||||||
debug!(target: "engine::tree", blocks = ?blocks_to_persist.iter().map(|block| block.recovered_block().num_hash()).collect::<Vec<_>>(), "Persisting blocks");
|
|
||||||
let (tx, rx) = oneshot::channel();
|
|
||||||
let _ = self.persistence.save_blocks(blocks_to_persist, tx);
|
|
||||||
self.persistence_state.start(rx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.persistence_state.in_progress() {
|
if self.persistence_state.in_progress() {
|
||||||
let (mut rx, start_time) = self
|
let (mut rx, start_time) = self
|
||||||
.persistence_state
|
.persistence_state
|
||||||
@ -1236,6 +1214,29 @@ where
|
|||||||
Err(TryRecvError::Empty) => self.persistence_state.rx = Some((rx, start_time)),
|
Err(TryRecvError::Empty) => self.persistence_state.rx = Some((rx, start_time)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.persistence_state.in_progress() {
|
||||||
|
if let Some(new_tip_num) = self.persistence_state.remove_above_state.pop_front() {
|
||||||
|
debug!(target: "engine::tree", ?new_tip_num, remove_state=?self.persistence_state.remove_above_state, last_persisted_block_number=?self.persistence_state.last_persisted_block.number, "Removing blocks using persistence task");
|
||||||
|
if new_tip_num < self.persistence_state.last_persisted_block.number {
|
||||||
|
debug!(target: "engine::tree", ?new_tip_num, "Starting remove blocks job");
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
let _ = self.persistence.remove_blocks_above(new_tip_num, tx);
|
||||||
|
self.persistence_state.start(rx);
|
||||||
|
}
|
||||||
|
} else if self.should_persist() {
|
||||||
|
let blocks_to_persist = self.get_canonical_blocks_to_persist();
|
||||||
|
if blocks_to_persist.is_empty() {
|
||||||
|
debug!(target: "engine::tree", "Returned empty set of blocks to persist");
|
||||||
|
} else {
|
||||||
|
debug!(target: "engine::tree", blocks = ?blocks_to_persist.iter().map(|block| block.recovered_block().num_hash()).collect::<Vec<_>>(), "Persisting blocks");
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
let _ = self.persistence.save_blocks(blocks_to_persist, tx);
|
||||||
|
self.persistence_state.start(rx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user