use fuel_core_services::stream::BoxStream;
use fuel_core_types::{
blockchain::{
primitives::{
BlockHeight,
BlockId,
DaBlockHeight,
},
SealedBlock,
SealedBlockHeader,
},
fuel_tx::Transaction,
services::p2p::SourcePeer,
};
#[cfg_attr(test, mockall::automock)]
#[async_trait::async_trait]
pub trait PeerToPeerPort {
fn height_stream(&self) -> BoxStream<BlockHeight>;
async fn get_sealed_block_header(
&self,
height: BlockHeight,
) -> anyhow::Result<Option<SourcePeer<SealedBlockHeader>>>;
async fn get_transactions(
&self,
block_id: SourcePeer<BlockId>,
) -> anyhow::Result<Option<Vec<Transaction>>>;
}
#[cfg_attr(test, mockall::automock)]
#[async_trait::async_trait]
pub trait ConsensusPort {
fn check_sealed_header(&self, header: &SealedBlockHeader) -> anyhow::Result<bool>;
async fn await_da_height(&self, da_height: &DaBlockHeight) -> anyhow::Result<()>;
}
#[cfg_attr(test, mockall::automock)]
#[async_trait::async_trait]
pub trait BlockImporterPort {
fn committed_height_stream(&self) -> BoxStream<BlockHeight>;
async fn execute_and_commit(&self, block: SealedBlock) -> anyhow::Result<()>;
}