mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Tidy the BlockHasEvents cache
This commit is contained in:
@@ -43,7 +43,7 @@ create_db!(
|
|||||||
SubstrateCosignDb {
|
SubstrateCosignDb {
|
||||||
ScanCosignFrom: () -> u64,
|
ScanCosignFrom: () -> u64,
|
||||||
IntendedCosign: () -> (u64, Option<u64>),
|
IntendedCosign: () -> (u64, Option<u64>),
|
||||||
BlockHasEvents: (block: u64) -> HasEvents,
|
BlockHasEventsCache: (block: u64) -> HasEvents,
|
||||||
LatestCosignedBlock: () -> u64,
|
LatestCosignedBlock: () -> u64,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -86,7 +86,7 @@ async fn block_has_events(
|
|||||||
serai: &Serai,
|
serai: &Serai,
|
||||||
block: u64,
|
block: u64,
|
||||||
) -> Result<HasEvents, SeraiError> {
|
) -> Result<HasEvents, SeraiError> {
|
||||||
let cached = BlockHasEvents::get(txn, block);
|
let cached = BlockHasEventsCache::get(txn, block);
|
||||||
match cached {
|
match cached {
|
||||||
None => {
|
None => {
|
||||||
let serai = serai.as_of(
|
let serai = serai.as_of(
|
||||||
@@ -108,7 +108,7 @@ async fn block_has_events(
|
|||||||
|
|
||||||
let has_events = if has_no_events { HasEvents::No } else { HasEvents::Yes };
|
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)
|
Ok(has_events)
|
||||||
}
|
}
|
||||||
Some(code) => Ok(code),
|
Some(code) => Ok(code),
|
||||||
@@ -288,6 +288,8 @@ async fn advance_cosign_protocol_inner(
|
|||||||
|
|
||||||
// If this TX is committed, always start future scanning from the next block
|
// If this TX is committed, always start future scanning from the next block
|
||||||
ScanCosignFrom::set(&mut txn, &(block + 1));
|
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 {
|
if let Some((number, hash)) = to_cosign {
|
||||||
|
|||||||
Reference in New Issue
Block a user