Skip to content

Commit

Permalink
Update generic name in payload crate (#10669)
Browse files Browse the repository at this point in the history
  • Loading branch information
malik672 authored Sep 3, 2024
1 parent 5fc7755 commit 020597d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 87 deletions.
20 changes: 10 additions & 10 deletions crates/payload/builder/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@ use tracing::debug;

/// Payload builder events.
#[derive(Clone, Debug)]
pub enum Events<Engine: PayloadTypes> {
pub enum Events<T: PayloadTypes> {
/// The payload attributes as
/// they are received from the CL through the engine api.
Attributes(Engine::PayloadBuilderAttributes),
Attributes(T::PayloadBuilderAttributes),
/// The built payload that has been just built.
/// Triggered by the CL whenever it asks for an execution payload.
/// This event is only thrown if the CL is a validator.
BuiltPayload(Engine::BuiltPayload),
BuiltPayload(T::BuiltPayload),
}

/// Represents a receiver for various payload events.
#[derive(Debug)]
pub struct PayloadEvents<Engine: PayloadTypes> {
pub struct PayloadEvents<T: PayloadTypes> {
/// The receiver for the payload events.
pub receiver: broadcast::Receiver<Events<Engine>>,
pub receiver: broadcast::Receiver<Events<T>>,
}

impl<Engine: PayloadTypes + 'static> PayloadEvents<Engine> {
impl<T: PayloadTypes + 'static> PayloadEvents<T> {
/// Convert this receiver into a stream of `PayloadEvents`.
pub fn into_stream(self) -> BroadcastStream<Events<Engine>> {
pub fn into_stream(self) -> BroadcastStream<Events<T>> {
BroadcastStream::new(self.receiver)
}
/// Asynchronously receives the next payload event.
pub async fn recv(self) -> Option<Result<Events<Engine>, BroadcastStreamRecvError>> {
pub async fn recv(self) -> Option<Result<Events<T>, BroadcastStreamRecvError>> {
let mut event_stream = self.into_stream();
event_stream.next().await
}

/// Returns a new stream that yields all built payloads.
pub fn into_built_payload_stream(self) -> BuiltPayloadStream<Engine> {
pub fn into_built_payload_stream(self) -> BuiltPayloadStream<T> {
BuiltPayloadStream { st: self.into_stream() }
}

/// Returns a new stream that yields received payload attributes
pub fn into_attributes_stream(self) -> PayloadAttributeStream<Engine> {
pub fn into_attributes_stream(self) -> PayloadAttributeStream<T> {
PayloadAttributeStream { st: self.into_stream() }
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/payload/builder/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ use tokio_stream::wrappers::UnboundedReceiverStream;

/// A service task that does not build any payloads.
#[derive(Debug)]
pub struct NoopPayloadBuilderService<Engine: PayloadTypes> {
pub struct NoopPayloadBuilderService<T: PayloadTypes> {
/// Receiver half of the command channel.
command_rx: UnboundedReceiverStream<PayloadServiceCommand<Engine>>,
command_rx: UnboundedReceiverStream<PayloadServiceCommand<T>>,
}

impl<Engine> NoopPayloadBuilderService<Engine>
impl<T> NoopPayloadBuilderService<T>
where
Engine: PayloadTypes + 'static,
T: PayloadTypes + 'static,
{
/// Creates a new [`NoopPayloadBuilderService`].
pub fn new() -> (Self, PayloadBuilderHandle<Engine>) {
pub fn new() -> (Self, PayloadBuilderHandle<T>) {
let (service_tx, command_rx) = mpsc::unbounded_channel();
(
Self { command_rx: UnboundedReceiverStream::new(command_rx) },
Expand All @@ -32,9 +32,9 @@ where
}
}

impl<Engine> Future for NoopPayloadBuilderService<Engine>
impl<T> Future for NoopPayloadBuilderService<T>
where
Engine: PayloadTypes,
T: PayloadTypes,
{
type Output = ();

Expand Down
Loading

0 comments on commit 020597d

Please sign in to comment.