fuel_core_txpool/
ports.rsuse std::sync::Arc;
use fuel_core_services::stream::BoxStream;
use fuel_core_storage::{
PredicateStorageRequirements,
Result as StorageResult,
};
use fuel_core_types::{
blockchain::header::ConsensusParametersVersion,
entities::{
coins::coin::CompressedCoin,
relayer::message::Message,
},
fuel_tx::{
BlobId,
Bytes32,
ConsensusParameters,
ContractId,
Transaction,
TxId,
UtxoId,
},
fuel_types::Nonce,
services::{
block_importer::SharedImportResult,
p2p::{
GossipsubMessageAcceptance,
GossipsubMessageInfo,
NetworkData,
PeerId,
},
},
};
use crate::GasPrice;
pub use fuel_core_storage::transactional::AtomicView;
pub trait BlockImporter {
fn block_events(&self) -> BoxStream<SharedImportResult>;
}
pub trait ConsensusParametersProvider: Send + Sync + 'static {
fn latest_consensus_parameters(
&self,
) -> (ConsensusParametersVersion, Arc<ConsensusParameters>);
}
pub trait TxPoolPersistentStorage:
Clone + PredicateStorageRequirements + Send + Sync + 'static
{
fn utxo(&self, utxo_id: &UtxoId) -> StorageResult<Option<CompressedCoin>>;
fn contract_exist(&self, contract_id: &ContractId) -> StorageResult<bool>;
fn blob_exist(&self, blob_id: &BlobId) -> StorageResult<bool>;
fn message(&self, message_id: &Nonce) -> StorageResult<Option<Message>>;
}
pub trait GasPriceProvider: Send + Sync + 'static {
fn next_gas_price(&self) -> GasPrice;
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum WasmValidityError {
NotEnabled,
NotFound,
NotValid,
}
pub trait WasmChecker: Send + Sync + 'static {
fn validate_uploaded_wasm(
&self,
wasm_root: &Bytes32,
) -> Result<(), WasmValidityError>;
}
pub trait P2PSubscriptions {
type GossipedTransaction: NetworkData<Transaction>;
fn subscribe_new_peers(&self) -> BoxStream<PeerId>;
fn gossiped_transaction_events(&self) -> BoxStream<Self::GossipedTransaction>;
}
pub trait NotifyP2P {
fn broadcast_transaction(&self, transaction: Arc<Transaction>) -> anyhow::Result<()>;
fn notify_gossip_transaction_validity(
&self,
message_info: GossipsubMessageInfo,
validity: GossipsubMessageAcceptance,
) -> anyhow::Result<()>;
}
#[async_trait::async_trait]
pub trait P2PRequests: NotifyP2P + Send + Sync + 'static {
async fn request_tx_ids(&self, peer_id: PeerId) -> anyhow::Result<Vec<TxId>>;
async fn request_txs(
&self,
peer_id: PeerId,
tx_ids: Vec<TxId>,
) -> anyhow::Result<Vec<Option<Transaction>>>;
}