mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-09 22:45:57 -05:00
chore: touchups PayloadOrAttributes (#11749)
This commit is contained in:
@@ -3,8 +3,10 @@ use alloy_primitives::B256;
|
||||
use alloy_rpc_types::engine::ExecutionPayload;
|
||||
|
||||
/// Either an [`ExecutionPayload`] or a types that implements the [`PayloadAttributes`] trait.
|
||||
///
|
||||
/// This is a helper type to unify pre-validation of version specific fields of the engine API.
|
||||
#[derive(Debug)]
|
||||
pub enum PayloadOrAttributes<'a, AttributesType> {
|
||||
pub enum PayloadOrAttributes<'a, Attributes> {
|
||||
/// An [`ExecutionPayload`] and optional parent beacon block root.
|
||||
ExecutionPayload {
|
||||
/// The inner execution payload
|
||||
@@ -13,13 +15,10 @@ pub enum PayloadOrAttributes<'a, AttributesType> {
|
||||
parent_beacon_block_root: Option<B256>,
|
||||
},
|
||||
/// A payload attributes type.
|
||||
PayloadAttributes(&'a AttributesType),
|
||||
PayloadAttributes(&'a Attributes),
|
||||
}
|
||||
|
||||
impl<'a, AttributesType> PayloadOrAttributes<'a, AttributesType>
|
||||
where
|
||||
AttributesType: PayloadAttributes,
|
||||
{
|
||||
impl<'a, Attributes> PayloadOrAttributes<'a, Attributes> {
|
||||
/// Construct a [`PayloadOrAttributes`] from an [`ExecutionPayload`] and optional parent beacon
|
||||
/// block root.
|
||||
pub const fn from_execution_payload(
|
||||
@@ -29,6 +28,16 @@ where
|
||||
Self::ExecutionPayload { payload, parent_beacon_block_root }
|
||||
}
|
||||
|
||||
/// Construct a [`PayloadOrAttributes::PayloadAttributes`] variant
|
||||
pub const fn from_attributes(attributes: &'a Attributes) -> Self {
|
||||
Self::PayloadAttributes(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Attributes> PayloadOrAttributes<'_, Attributes>
|
||||
where
|
||||
Attributes: PayloadAttributes,
|
||||
{
|
||||
/// Return the withdrawals for the payload or attributes.
|
||||
pub fn withdrawals(&self) -> Option<&Vec<alloy_rpc_types::Withdrawal>> {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user