mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Replace scanner's BatchPublisher with a pair of DB channels
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use core::marker::PhantomData;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use group::GroupEncoding;
|
||||
|
||||
use scale::{Encode, Decode, IoReader};
|
||||
use serai_db::{Get, DbTxn, create_db};
|
||||
|
||||
@@ -8,7 +10,7 @@ use serai_primitives::Balance;
|
||||
|
||||
use primitives::Address;
|
||||
|
||||
use crate::{ScannerFeed, AddressFor};
|
||||
use crate::{ScannerFeed, KeyFor, AddressFor};
|
||||
|
||||
create_db!(
|
||||
ScannerReport {
|
||||
@@ -20,6 +22,9 @@ create_db!(
|
||||
// The block number which caused a batch
|
||||
BlockNumberForBatch: (batch: u32) -> u64,
|
||||
|
||||
// The external key for the session which should sign a batch
|
||||
ExternalKeyForSessionToSignBatch: (batch: u32) -> Vec<u8>,
|
||||
|
||||
// The return addresses for the InInstructions within a Batch
|
||||
SerializedReturnAddresses: (batch: u32) -> Vec<u8>,
|
||||
}
|
||||
@@ -55,6 +60,29 @@ impl<S: ScannerFeed> ReportDb<S> {
|
||||
Some(block_number)
|
||||
}
|
||||
|
||||
pub(crate) fn save_external_key_for_session_to_sign_batch(
|
||||
txn: &mut impl DbTxn,
|
||||
id: u32,
|
||||
external_key_for_session_to_sign_batch: &KeyFor<S>,
|
||||
) {
|
||||
ExternalKeyForSessionToSignBatch::set(
|
||||
txn,
|
||||
id,
|
||||
&external_key_for_session_to_sign_batch.to_bytes().as_ref().to_vec(),
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn take_external_key_for_session_to_sign_batch(
|
||||
txn: &mut impl DbTxn,
|
||||
id: u32,
|
||||
) -> Option<KeyFor<S>> {
|
||||
ExternalKeyForSessionToSignBatch::get(txn, id).map(|key_vec| {
|
||||
let mut key = <KeyFor<S> as GroupEncoding>::Repr::default();
|
||||
key.as_mut().copy_from_slice(&key_vec);
|
||||
KeyFor::<S>::from_bytes(&key).unwrap()
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn save_return_information(
|
||||
txn: &mut impl DbTxn,
|
||||
id: u32,
|
||||
|
||||
Reference in New Issue
Block a user