use fuel_core_services::stream::BoxStream;
use fuel_core_storage::Result as StorageResult;
use fuel_core_types::{
blockchain::primitives::BlockHeight,
entities::{
coin::CompressedCoin,
message::CompressedMessage,
},
fuel_tx::{
Transaction,
UtxoId,
},
fuel_types::{
ContractId,
MessageId,
},
services::{
block_importer::ImportResult,
p2p::{
GossipsubMessageAcceptance,
GossipsubMessageInfo,
NetworkData,
},
},
};
use std::sync::Arc;
pub trait PeerToPeer: Send + Sync {
type GossipedTransaction: NetworkData<Transaction>;
fn broadcast_transaction(&self, transaction: Arc<Transaction>) -> anyhow::Result<()>;
fn gossiped_transaction_events(&self) -> BoxStream<Self::GossipedTransaction>;
fn notify_gossip_transaction_validity(
&self,
message_info: GossipsubMessageInfo,
validity: GossipsubMessageAcceptance,
) -> anyhow::Result<()>;
}
pub trait BlockImporter: Send + Sync {
fn block_events(&self) -> BoxStream<Arc<ImportResult>>;
}
pub trait TxPoolDb: Send + Sync {
fn utxo(&self, utxo_id: &UtxoId) -> StorageResult<Option<CompressedCoin>>;
fn contract_exist(&self, contract_id: &ContractId) -> StorageResult<bool>;
fn message(&self, message_id: &MessageId)
-> StorageResult<Option<CompressedMessage>>;
fn is_message_spent(&self, message_id: &MessageId) -> StorageResult<bool>;
fn current_block_height(&self) -> StorageResult<BlockHeight>;
}