Skip to main content

PayloadProvider

Trait PayloadProvider 

Source
pub trait PayloadProvider:
    Send
    + Sync
    + 'static {
    type ExecutionData: ExecutionPayload;

    // Required methods
    fn subscribe_payloads(
        &self,
        tx: Sender<Self::ExecutionData>,
    ) -> impl Future<Output = ()> + Send;
    fn get_payload(
        &self,
        block_number: u64,
    ) -> impl Future<Output = Result<Self::ExecutionData>> + Send;

    // Provided method
    fn get_or_fetch_previous_block(
        &self,
        previous_block_hashes: &AllocRingBuffer<B256>,
        current_block_number: u64,
        offset: usize,
    ) -> impl Future<Output = Result<B256>> + Send { ... }
}
Expand description

Supplies consensus client with new execution payloads sent in tx and a callback to find specific payloads by number to fetch past finalized and safe block hashes.

Required Associated Types§

Source

type ExecutionData: ExecutionPayload

The execution payload data type.

Required Methods§

Source

fn subscribe_payloads( &self, tx: Sender<Self::ExecutionData>, ) -> impl Future<Output = ()> + Send

Runs a provider to send new execution payloads to the given sender.

Note: This is expected to be spawned in a separate task, and as such it should ignore errors.

Source

fn get_payload( &self, block_number: u64, ) -> impl Future<Output = Result<Self::ExecutionData>> + Send

Get a past execution payload by block number.

Provided Methods§

Source

fn get_or_fetch_previous_block( &self, previous_block_hashes: &AllocRingBuffer<B256>, current_block_number: u64, offset: usize, ) -> impl Future<Output = Result<B256>> + Send

Get previous block hash using previous block hash buffer. If it isn’t available (buffer started more recently than offset), fetch it using get_payload.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + PayloadProvider + ?Sized> PayloadProvider for &'a T
where &'a T: Send + Sync + 'static,

Source§

type ExecutionData = <T as PayloadProvider>::ExecutionData

Source§

fn subscribe_payloads( &self, tx: Sender<Self::ExecutionData>, ) -> impl Future<Output = ()> + Send

Source§

fn get_payload( &self, block_number: u64, ) -> impl Future<Output = Result<Self::ExecutionData>> + Send

Source§

fn get_or_fetch_previous_block( &self, previous_block_hashes: &AllocRingBuffer<B256>, current_block_number: u64, offset: usize, ) -> impl Future<Output = Result<B256>> + Send

Source§

impl<T: PayloadProvider + ?Sized> PayloadProvider for Box<T>
where Box<T>: Send + Sync + 'static,

Source§

type ExecutionData = <T as PayloadProvider>::ExecutionData

Source§

fn subscribe_payloads( &self, tx: Sender<Self::ExecutionData>, ) -> impl Future<Output = ()> + Send

Source§

fn get_payload( &self, block_number: u64, ) -> impl Future<Output = Result<Self::ExecutionData>> + Send

Source§

fn get_or_fetch_previous_block( &self, previous_block_hashes: &AllocRingBuffer<B256>, current_block_number: u64, offset: usize, ) -> impl Future<Output = Result<B256>> + Send

Source§

impl<T: PayloadProvider + ?Sized> PayloadProvider for Arc<T>
where Arc<T>: Send + Sync + 'static,

Source§

type ExecutionData = <T as PayloadProvider>::ExecutionData

Source§

fn subscribe_payloads( &self, tx: Sender<Self::ExecutionData>, ) -> impl Future<Output = ()> + Send

Source§

fn get_payload( &self, block_number: u64, ) -> impl Future<Output = Result<Self::ExecutionData>> + Send

Source§

fn get_or_fetch_previous_block( &self, previous_block_hashes: &AllocRingBuffer<B256>, current_block_number: u64, offset: usize, ) -> impl Future<Output = Result<B256>> + Send

Implementors§

Source§

impl<N: Network, ExecutionData> PayloadProvider for RpcBlockProvider<N, ExecutionData>
where ExecutionData: ExecutionPayload,

Source§

type ExecutionData = ExecutionData

Source§

impl<RpcBlock, ExecutionData> PayloadProvider for EtherscanBlockProvider<RpcBlock, ExecutionData>
where RpcBlock: Serialize + DeserializeOwned + 'static, ExecutionData: ExecutionPayload,

Source§

type ExecutionData = ExecutionData