chore: move extradata bytes to function (#3085)

This commit is contained in:
Matthias Seitz
2023-06-09 19:32:35 +02:00
committed by GitHub
parent 0608726865
commit 452ea43997
2 changed files with 12 additions and 7 deletions

View File

@ -3,7 +3,8 @@ use clap::{
builder::{RangedU64ValueParser, TypedValueParser},
Arg, Args, Command,
};
use reth_primitives::constants::MAXIMUM_EXTRA_DATA_SIZE;
use reth_primitives::{bytes::BytesMut, constants::MAXIMUM_EXTRA_DATA_SIZE};
use reth_rlp::Encodable;
use std::{ffi::OsStr, time::Duration};
/// Parameters for configuring the Payload Builder
@ -35,6 +36,15 @@ pub struct PayloadBuilderArgs {
pub max_payload_tasks: usize,
}
impl PayloadBuilderArgs {
/// Returns the rlp-encoded extradata bytes.
pub fn extradata_bytes(&self) -> reth_primitives::bytes::Bytes {
let mut extradata = BytesMut::new();
self.extradata.as_bytes().encode(&mut extradata);
extradata.freeze()
}
}
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
struct ExtradataValueParser;

View File

@ -80,9 +80,7 @@ use crate::{
};
use reth_interfaces::p2p::headers::client::HeadersClient;
use reth_payload_builder::PayloadBuilderService;
use reth_primitives::bytes::BytesMut;
use reth_provider::providers::BlockchainProvider;
use reth_rlp::Encodable;
pub mod cl_events;
pub mod events;
@ -256,9 +254,6 @@ impl Command {
let (consensus_engine_tx, consensus_engine_rx) = unbounded_channel();
// configure the payload builder
let mut extradata = BytesMut::new();
self.builder.extradata.as_bytes().encode(&mut extradata);
let payload_generator = BasicPayloadJobGenerator::new(
blockchain_db.clone(),
transaction_pool.clone(),
@ -267,7 +262,7 @@ impl Command {
.interval(self.builder.interval)
.deadline(self.builder.deadline)
.max_payload_tasks(self.builder.max_payload_tasks)
.extradata(extradata.freeze())
.extradata(self.builder.extradata_bytes())
.max_gas_limit(self.builder.max_gas_limit),
Arc::clone(&self.chain),
);