Skip to content

Commit

Permalink
Tidy the BlockHasEvents cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Mar 11, 2024
1 parent f7d16b3 commit ace41c7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions coordinator/src/substrate/cosign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ create_db!(
SubstrateCosignDb {
ScanCosignFrom: () -> u64,
IntendedCosign: () -> (u64, Option<u64>),
BlockHasEvents: (block: u64) -> HasEvents,
BlockHasEventsCache: (block: u64) -> HasEvents,
LatestCosignedBlock: () -> u64,
}
);
Expand Down Expand Up @@ -86,7 +86,7 @@ async fn block_has_events(
serai: &Serai,
block: u64,
) -> Result<HasEvents, SeraiError> {
let cached = BlockHasEvents::get(txn, block);
let cached = BlockHasEventsCache::get(txn, block);
match cached {
None => {
let serai = serai.as_of(
Expand All @@ -108,7 +108,7 @@ async fn block_has_events(

let has_events = if has_no_events { HasEvents::No } else { HasEvents::Yes };

BlockHasEvents::set(txn, block, &has_events);
BlockHasEventsCache::set(txn, block, &has_events);
Ok(has_events)
}
Some(code) => Ok(code),
Expand Down Expand Up @@ -288,6 +288,8 @@ async fn advance_cosign_protocol_inner(

// If this TX is committed, always start future scanning from the next block
ScanCosignFrom::set(&mut txn, &(block + 1));
// Since we're scanning *from* the next block, tidy the cache
BlockHasEventsCache::del(&mut txn, &block);
}

if let Some((number, hash)) = to_cosign {
Expand Down

0 comments on commit ace41c7

Please sign in to comment.