chore: make optypedtx fields private (#14065)

This commit is contained in:
Matthias Seitz
2025-01-29 18:49:09 +01:00
committed by GitHub
parent 9001cc2cec
commit 376a5ddf55
4 changed files with 38 additions and 21 deletions

View File

@ -37,13 +37,13 @@ use reth_primitives_traits::{
pub struct OpTransactionSigned {
/// Transaction hash
#[cfg_attr(feature = "serde", serde(skip))]
pub hash: OnceLock<TxHash>,
hash: OnceLock<TxHash>,
/// The transaction signature values
pub signature: Signature,
signature: Signature,
/// Raw transaction info
#[deref]
#[as_ref]
pub transaction: OpTypedTransaction,
transaction: OpTypedTransaction,
}
impl OpTransactionSigned {
@ -57,6 +57,23 @@ impl OpTransactionSigned {
signed_tx
}
/// Consumes the type and returns the transaction.
#[inline]
pub fn into_transaction(self) -> OpTypedTransaction {
self.transaction
}
/// Returns the transaction.
#[inline]
pub const fn transaction(&self) -> &OpTypedTransaction {
&self.transaction
}
/// Splits the `OpTransactionSigned` into its transaction and signature.
pub fn split(self) -> (OpTypedTransaction, Signature) {
(self.transaction, self.signature)
}
/// Creates a new signed transaction from the given transaction and signature without the hash.
///
/// Note: this only calculates the hash on the first [`OpTransactionSigned::hash`] call.
@ -379,6 +396,18 @@ impl Transaction for OpTransactionSigned {
self.deref().priority_fee_or_price()
}
fn effective_gas_price(&self, base_fee: Option<u64>) -> u128 {
self.deref().effective_gas_price(base_fee)
}
fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128> {
self.deref().effective_tip_per_gas(base_fee)
}
fn is_dynamic_fee(&self) -> bool {
self.deref().is_dynamic_fee()
}
fn kind(&self) -> TxKind {
self.deref().kind()
}
@ -406,18 +435,6 @@ impl Transaction for OpTransactionSigned {
fn authorization_list(&self) -> Option<&[SignedAuthorization]> {
self.deref().authorization_list()
}
fn is_dynamic_fee(&self) -> bool {
self.deref().is_dynamic_fee()
}
fn effective_gas_price(&self, base_fee: Option<u64>) -> u128 {
self.deref().effective_gas_price(base_fee)
}
fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128> {
self.deref().effective_tip_per_gas(base_fee)
}
}
impl Typed2718 for OpTransactionSigned {