-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(payload): abstract payload builder in trait #10965
feat(payload): abstract payload builder in trait #10965
Conversation
crates/payload/builder/src/traits.rs
Outdated
Pin<Box<dyn Future<Output = Result<P, PayloadBuilderError>> + Send + Sync>>; | ||
|
||
/// A type that can request, subscribe to and resolve payloads. | ||
#[async_trait::async_trait] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure about this, are you ok with using the async_trait
macro or would you rather explicitly returning a future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async_trait is fine here, then we could use this as dyn trait as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, some nits
crates/payload/builder/src/traits.rs
Outdated
Pin<Box<dyn Future<Output = Result<P, PayloadBuilderError>> + Send + Sync>>; | ||
|
||
/// A type that can request, subscribe to and resolve payloads. | ||
#[async_trait::async_trait] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async_trait is fine here, then we could use this as dyn trait as well.
crates/payload/builder/src/traits.rs
Outdated
|
||
/// A type that can request, subscribe to and resolve payloads. | ||
#[async_trait::async_trait] | ||
pub trait PayloadBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this to payload-primitives perhaps?
crates/payload/builder/src/traits.rs
Outdated
|
||
/// A type that can request, subscribe to and resolve payloads. | ||
#[async_trait::async_trait] | ||
pub trait PayloadBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be Send + Unpin
let (tx, rx) = oneshot::channel(); | ||
let _ = self.to_service.send(PayloadServiceCommand::Subscribe(tx)); | ||
Ok(PayloadEvents { receiver: rx.await? }) | ||
} | ||
} | ||
|
||
impl<T> PayloadBuilderHandle<T> | ||
where | ||
T: PayloadTypes + 'static, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also make PayloadTypes
'static
eb123d2
to
07b720a
Compare
07b720a
to
9c469d0
Compare
I noticed there were 2 |
9c469d0
to
d5c6ea1
Compare
d5c6ea1
to
aa161a2
Compare
aa161a2
to
c16ec18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice, one pedantic nit about re-exports
crates/payload/builder/src/lib.rs
Outdated
@@ -28,7 +28,7 @@ | |||
//! use std::pin::Pin; | |||
//! use std::task::{Context, Poll}; | |||
//! use reth_payload_builder::{EthBuiltPayload, KeepPayloadJobAlive, EthPayloadBuilderAttributes, PayloadJob, PayloadJobGenerator}; | |||
//! use reth_payload_builder::error::PayloadBuilderError; | |||
//! use reth_payload_primitives::PayloadBuilderError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should re-export the PayloadBuilderError in L125 then this wouldn't break too much and some crates don't require an additional dep
Abstracts the current
PayloadBuilderHandle
behind aPayloadBuilder
trait. First step towards being able to have thePayloadBuilder
be a GAT on theNodeComponents
trait.Resolves #10956.