fix(provider): update checkpoints only for known stages (#3624)

This commit is contained in:
Roman Krasiuk
2023-07-12 11:19:43 +03:00
committed by GitHub
parent 5dd4bc6bee
commit e2218bea37

View File

@@ -1227,14 +1227,15 @@ impl<'this, TX: DbTxMut<'this>> StageCheckpointWriter for DatabaseProvider<'this
) -> Result<()> {
// iterate over all existing stages in the table and update its progress.
let mut cursor = self.tx.cursor_write::<tables::SyncStage>()?;
while let Some((stage_name, checkpoint)) = cursor.next()? {
for stage_id in StageId::ALL {
let (_, checkpoint) = cursor.seek_exact(stage_id.to_string())?.unwrap_or_default();
cursor.upsert(
stage_name,
stage_id.to_string(),
StageCheckpoint {
block_number,
..if drop_stage_checkpoint { Default::default() } else { checkpoint }
},
)?
)?;
}
Ok(())