mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make transaction type fields private (#13915)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -258,7 +258,7 @@ where
|
||||
// invalid, which removes its dependent transactions from
|
||||
// the iterator. This is similar to the gas limit condition
|
||||
// for regular transactions above.
|
||||
trace!(target: "payload_builder", tx=?tx.hash, ?sum_blob_gas_used, ?tx_blob_gas, "skipping blob transaction because it would exceed the max data gas per block");
|
||||
trace!(target: "payload_builder", tx=?tx.hash(), ?sum_blob_gas_used, ?tx_blob_gas, "skipping blob transaction because it would exceed the max data gas per block");
|
||||
best_txs.mark_invalid(
|
||||
&pool_tx,
|
||||
InvalidPoolTransactionError::ExceedsGasLimit(
|
||||
|
||||
@ -51,6 +51,10 @@ alloy-consensus = { workspace = true, features = ["serde", "arbitrary"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
test-utils = [
|
||||
"reth-codecs?/test-utils",
|
||||
"reth-primitives-traits/test-utils",
|
||||
]
|
||||
alloy-compat = ["dep:alloy-network", "dep:alloy-serde", "dep:alloy-rpc-types"]
|
||||
std = [
|
||||
"alloy-consensus/std",
|
||||
|
||||
@ -282,17 +282,19 @@ impl From<TypedTransaction> for Transaction {
|
||||
/// Signed Ethereum transaction.
|
||||
#[derive(Debug, Clone, Eq, Serialize, Deserialize, derive_more::AsRef, derive_more::Deref)]
|
||||
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(rlp))]
|
||||
#[cfg_attr(feature = "test-utils", derive(derive_more::DerefMut))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TransactionSigned {
|
||||
/// Transaction hash
|
||||
#[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: Transaction,
|
||||
#[cfg_attr(feature = "test-utils", deref_mut)]
|
||||
transaction: Transaction,
|
||||
}
|
||||
|
||||
impl Default for TransactionSigned {
|
||||
@ -328,6 +330,30 @@ impl TransactionSigned {
|
||||
Self { hash: hash.into(), signature, transaction }
|
||||
}
|
||||
|
||||
/// Consumes the type and returns the transaction.
|
||||
#[inline]
|
||||
pub fn into_transaction(self) -> Transaction {
|
||||
self.transaction
|
||||
}
|
||||
|
||||
/// Returns the transaction.
|
||||
#[inline]
|
||||
pub const fn transaction(&self) -> &Transaction {
|
||||
&self.transaction
|
||||
}
|
||||
|
||||
/// Returns the transaction hash.
|
||||
#[inline]
|
||||
pub fn hash(&self) -> &B256 {
|
||||
self.hash.get_or_init(|| self.recalculate_hash())
|
||||
}
|
||||
|
||||
/// Returns the transaction signature.
|
||||
#[inline]
|
||||
pub const fn signature(&self) -> &Signature {
|
||||
&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 [`TransactionSigned::hash`] call.
|
||||
@ -335,6 +361,11 @@ impl TransactionSigned {
|
||||
Self { hash: Default::default(), signature, transaction }
|
||||
}
|
||||
|
||||
/// Splits the `TransactionSigned` into its transaction and signature.
|
||||
pub fn split(self) -> (Transaction, Signature) {
|
||||
(self.transaction, self.signature)
|
||||
}
|
||||
|
||||
/// Converts from an EIP-4844 transaction to a [`PooledTransaction`] with the given sidecar.
|
||||
///
|
||||
/// Returns an `Err` containing the original `TransactionSigned` if the transaction is not
|
||||
@ -367,6 +398,12 @@ impl TransactionSigned {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides mutable access to the transaction.
|
||||
#[cfg(feature = "test-utils")]
|
||||
pub fn transaction_mut(&mut self) -> &mut Transaction {
|
||||
&mut self.transaction
|
||||
}
|
||||
}
|
||||
|
||||
impl Typed2718 for TransactionSigned {
|
||||
@ -534,13 +571,13 @@ impl Decodable2718 for TransactionSigned {
|
||||
}
|
||||
|
||||
impl Encodable for TransactionSigned {
|
||||
fn length(&self) -> usize {
|
||||
self.network_len()
|
||||
}
|
||||
|
||||
fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
|
||||
self.network_encode(out);
|
||||
}
|
||||
|
||||
fn length(&self) -> usize {
|
||||
self.network_len()
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for TransactionSigned {
|
||||
|
||||
Reference in New Issue
Block a user