Skip to content

Commit

Permalink
Wait for tx to be processed in pruner.
Browse files Browse the repository at this point in the history
  • Loading branch information
peilun-conflux committed Nov 13, 2024
1 parent f4d5228 commit bf20187
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions node/pruner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,26 @@ impl Pruner {
}

async fn prune_tx(&mut self, start_sector: u64, end_sector: u64) -> Result<()> {
while let Some(tx) = self.store.get_tx_by_seq_number(self.first_tx_seq).await? {
// If a part of the tx data is pruned, we mark the tx as pruned.
if tx.start_entry_index() >= start_sector && tx.start_entry_index() < end_sector {
self.store.prune_tx(tx.seq).await?;
} else if tx.start_entry_index() >= end_sector {
break;
loop {
if let Some(tx) = self.store.get_tx_by_seq_number(self.first_tx_seq).await? {
// If a part of the tx data is pruned, we mark the tx as pruned.
if tx.start_entry_index() >= start_sector && tx.start_entry_index() < end_sector {
self.store.prune_tx(tx.seq).await?;
} else if tx.start_entry_index() >= end_sector {
break;
} else {
bail!(
"prune tx out of range: tx={:?}, start={} end={}",
tx,
start_sector,
end_sector
);
}
self.first_tx_seq += 1;
} else {
bail!(
"prune tx out of range: tx={:?}, start={} end={}",
tx,
start_sector,
end_sector
);
// Wait for `first_tx_seq` to be processed.
tokio::time::sleep(Duration::from_secs(60)).await;
}
self.first_tx_seq += 1;
}
Ok(())
}
Expand Down

0 comments on commit bf20187

Please sign in to comment.