serai-processor-bin

Moves the coordinator loop out of serai-bitcoin-processor, completing it.

Fixes a potential race condition in the message-queue regarding multiple
sockets sending messages at once.
This commit is contained in:
Luke Parker
2024-09-11 18:56:23 -04:00
parent fcd5fb85df
commit b6811f9015
22 changed files with 705 additions and 594 deletions

View File

@@ -70,6 +70,8 @@ impl<S: ScannerFeed> OutputWithInInstruction<S> {
create_db!(
ScannerGlobal {
StartBlock: () -> u64,
QueuedKey: <K: Encode>(key: K) -> (),
ActiveKeys: <K: Borshy>() -> Vec<SeraiKeyDbEntry<K>>,
@@ -106,8 +108,11 @@ create_db!(
pub(crate) struct ScannerGlobalDb<S: ScannerFeed>(PhantomData<S>);
impl<S: ScannerFeed> ScannerGlobalDb<S> {
pub(crate) fn has_any_key_been_queued(getter: &impl Get) -> bool {
ActiveKeys::<EncodableG<KeyFor<S>>>::get(getter).is_some()
pub(crate) fn start_block(getter: &impl Get) -> Option<u64> {
StartBlock::get(getter)
}
pub(crate) fn set_start_block(txn: &mut impl DbTxn, block: u64) {
StartBlock::set(txn, &block)
}
/// Queue a key.