mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Differentiate BlockHeader from Block
This commit is contained in:
@@ -2,7 +2,7 @@ use core::{fmt::Debug, time::Duration};
|
||||
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use primitives::{ReceivedOutput, Block};
|
||||
use primitives::{ReceivedOutput, BlockHeader, Block};
|
||||
|
||||
mod db;
|
||||
mod index;
|
||||
@@ -21,15 +21,6 @@ pub trait ScannerFeed: Send + Sync {
|
||||
/// This value must be at least `1`.
|
||||
const CONFIRMATIONS: u64;
|
||||
|
||||
/// The type of the key used to receive coins on this blockchain.
|
||||
type Key: group::Group + group::GroupEncoding;
|
||||
|
||||
/// The type of the address used to specify who to send coins to on this blockchain.
|
||||
type Address;
|
||||
|
||||
/// The type representing a received (and spendable) output.
|
||||
type Output: ReceivedOutput<Self::Key, Self::Address>;
|
||||
|
||||
/// The representation of a block for this blockchain.
|
||||
///
|
||||
/// A block is defined as a consensus event associated with a set of transactions. It is not
|
||||
@@ -58,17 +49,20 @@ pub trait ScannerFeed: Send + Sync {
|
||||
Ok(self.latest_block_number().await? - Self::CONFIRMATIONS)
|
||||
}
|
||||
|
||||
/// Fetch a block header by its number.
|
||||
async fn block_header_by_number(
|
||||
&self,
|
||||
number: u64,
|
||||
) -> Result<<Self::Block as Block>::Header, Self::EphemeralError>;
|
||||
|
||||
/// Fetch a block by its number.
|
||||
async fn block_by_number(&self, number: u64) -> Result<Self::Block, Self::EphemeralError>;
|
||||
|
||||
/// Scan a block for its outputs.
|
||||
async fn scan_for_outputs(
|
||||
&self,
|
||||
block: &Self::Block,
|
||||
key: Self::Key,
|
||||
) -> Result<Vec<Self::Output>, Self::EphemeralError>;
|
||||
}
|
||||
|
||||
type BlockIdFor<S> = <<<S as ScannerFeed>::Block as Block>::Header as BlockHeader>::Id;
|
||||
type KeyFor<S> = <<S as ScannerFeed>::Block as Block>::Key;
|
||||
type OutputFor<S> = <<S as ScannerFeed>::Block as Block>::Output;
|
||||
|
||||
/// A handle to immediately run an iteration of a task.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct RunNowHandle(mpsc::Sender<()>);
|
||||
|
||||
Reference in New Issue
Block a user