chore(consensus): Cut down on reth-primitives::TransactionSigned usage (#13659)

This commit is contained in:
DevOrbitlabs
2025-01-06 21:34:31 +07:00
committed by GitHub
parent 20d3fa6bbb
commit 923a805e1e
4 changed files with 13 additions and 1 deletions

1
Cargo.lock generated
View File

@ -6923,6 +6923,7 @@ dependencies = [
"rand 0.8.5",
"reth-chainspec",
"reth-consensus",
"reth-ethereum-primitives",
"reth-primitives",
"reth-primitives-traits",
"reth-storage-api",

View File

@ -25,6 +25,7 @@ alloy-eips.workspace = true
[dev-dependencies]
alloy-consensus.workspace = true
reth-storage-api.workspace = true
reth-ethereum-primitives.workspace = true
rand.workspace = true
mockall = "0.13"

View File

@ -347,7 +347,8 @@ mod tests {
use mockall::mock;
use rand::Rng;
use reth_chainspec::ChainSpecBuilder;
use reth_primitives::{proofs, Account, BlockBody, Transaction, TransactionSigned};
use reth_ethereum_primitives::{Transaction, TransactionSigned};
use reth_primitives::{proofs, Account, BlockBody};
use reth_storage_api::{
errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider,
};

View File

@ -290,6 +290,15 @@ impl PartialEq for TransactionSigned {
}
}
impl TransactionSigned {
/// 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.
pub fn new_unhashed(transaction: Transaction, signature: Signature) -> Self {
Self { hash: Default::default(), signature, transaction }
}
}
impl Typed2718 for TransactionSigned {
fn ty(&self) -> u8 {
self.transaction.ty()