Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/payload/builder/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ impl<T: PayloadTypes> PayloadBuilderHandle<T> {
}
}

/// Same as [`Self::resolve_kind`] but returns the underlying future.
pub async fn resolve_kind_fut(
&self,
id: PayloadId,
kind: PayloadKind,
) -> Result<Option<PayloadFuture<T::BuiltPayload>>, PayloadBuilderError> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this so we can await the payload in two steps?

let (tx, rx) = oneshot::channel();
self.to_service.send(PayloadServiceCommand::Resolve(id, kind, tx))?;
rx.await.map_err(Into::into)
}

/// Sends a message to the service to subscribe to payload events.
/// Returns a receiver that will receive them.
pub async fn subscribe(&self) -> Result<PayloadEvents<T>, PayloadBuilderError> {
Expand Down
8 changes: 7 additions & 1 deletion crates/payload/primitives/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use alloy_primitives::B256;
use alloy_rpc_types_engine::{ForkchoiceUpdateError, PayloadError, PayloadStatusEnum};
use core::error;
use reth_errors::{BlockExecutionError, ProviderError, RethError};
use tokio::sync::oneshot;
use tokio::sync::{mpsc, oneshot};

/// Possible error variants during payload building.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -69,6 +69,12 @@ impl From<BlockExecutionError> for PayloadBuilderError {
}
}

impl<T> From<mpsc::error::SendError<T>> for PayloadBuilderError {
fn from(_: mpsc::error::SendError<T>) -> Self {
Self::ChannelClosed
}
}

/// Thrown when the payload or attributes are known to be invalid __before__ processing.
///
/// This is used mainly for
Expand Down
Loading