Files
serai/processor/scanner/src/report/db.rs

30 lines
783 B
Rust
Raw Normal View History

2024-08-28 20:16:06 -04:00
use serai_db::{Get, DbTxn, create_db};
2024-08-28 19:58:28 -04:00
create_db!(
ScannerReport {
// The next block to potentially report
NextToPotentiallyReportBlock: () -> u64,
2024-08-28 23:31:31 -04:00
// The next Batch ID to use
NextBatchId: () -> u32,
2024-08-28 19:58:28 -04:00
}
);
pub(crate) struct ReportDb;
impl ReportDb {
pub(crate) fn set_next_to_potentially_report_block(
txn: &mut impl DbTxn,
next_to_potentially_report_block: u64,
) {
NextToPotentiallyReportBlock::set(txn, &next_to_potentially_report_block);
}
pub(crate) fn next_to_potentially_report_block(getter: &impl Get) -> Option<u64> {
NextToPotentiallyReportBlock::get(getter)
}
pub(crate) fn acquire_batch_id(txn: &mut impl DbTxn) -> u32 {
2024-08-28 23:31:31 -04:00
let id = NextBatchId::get(txn).unwrap_or(0);
NextBatchId::set(txn, &(id + 1));
id
2024-08-28 19:58:28 -04:00
}
}