chore: unify more tx signed fns (#12883)

This commit is contained in:
Matthias Seitz
2024-11-26 17:21:52 +01:00
committed by GitHub
parent 6bba5e6630
commit ebf837e6e8
5 changed files with 9 additions and 16 deletions

View File

@@ -2186,7 +2186,7 @@ mod tests {
.await;
assert!(!pool.is_empty());
assert!(pool.get(signed_tx.hash_ref()).is_some());
assert!(pool.get(signed_tx.tx_hash()).is_some());
handle.terminate().await;
}

View File

@@ -1035,7 +1035,7 @@ impl PartialEq for TransactionSigned {
fn eq(&self, other: &Self) -> bool {
self.signature == other.signature &&
self.transaction == other.transaction &&
self.hash_ref() == other.hash_ref()
self.tx_hash() == other.tx_hash()
}
}
@@ -1054,11 +1054,6 @@ impl TransactionSigned {
Self { hash: Default::default(), signature, transaction }
}
/// Transaction signature.
pub const fn signature(&self) -> &Signature {
&self.signature
}
/// Transaction
pub const fn transaction(&self) -> &Transaction {
&self.transaction
@@ -1066,12 +1061,7 @@ impl TransactionSigned {
/// Transaction hash. Used to identify transaction.
pub fn hash(&self) -> TxHash {
*self.hash_ref()
}
/// Reference to transaction hash. Used to identify transaction.
pub fn hash_ref(&self) -> &TxHash {
self.hash.get_or_init(|| self.recalculate_hash())
*self.tx_hash()
}
/// Recovers a list of signers from a transaction list iterator.
@@ -1237,7 +1227,7 @@ impl SignedTransaction for TransactionSigned {
type Type = TxType;
fn tx_hash(&self) -> &TxHash {
self.hash_ref()
self.hash.get_or_init(|| self.recalculate_hash())
}
fn signature(&self) -> &Signature {

View File

@@ -72,6 +72,7 @@ mod tests {
};
use alloy_eips::eip2718::Decodable2718;
use alloy_primitives::{hex, Address, PrimitiveSignature as Signature, B256, U256};
use reth_primitives_traits::SignedTransaction;
use std::str::FromStr;
#[test]

View File

@@ -21,6 +21,7 @@ use reth_primitives::{
PooledTransactionsElementEcRecovered, SealedHeader, TransactionSigned,
TransactionSignedEcRecovered,
};
use reth_primitives_traits::SignedTransaction;
use reth_storage_api::{errors::provider::ProviderError, BlockReaderIdExt, StateProviderFactory};
use reth_tasks::TaskSpawner;
use std::{
@@ -317,7 +318,7 @@ pub async fn maintain_transaction_pool<Client, P, St, Tasks>(
// find all transactions that were mined in the old chain but not in the new chain
let pruned_old_transactions = old_blocks
.transactions_ecrecovered()
.filter(|tx| !new_mined_transactions.contains(tx.hash_ref()))
.filter(|tx| !new_mined_transactions.contains(tx.tx_hash()))
.filter_map(|tx| {
if tx.is_eip4844() {
// reorged blobs no longer include the blob, which is necessary for

View File

@@ -23,6 +23,7 @@ use reth_primitives::{
PooledTransactionsElementEcRecovered, SealedBlock, Transaction, TransactionSigned,
TransactionSignedEcRecovered,
};
use reth_primitives_traits::SignedTransaction;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::{
@@ -1244,7 +1245,7 @@ impl PoolTransaction for EthPooledTransaction {
/// Returns hash of the transaction.
fn hash(&self) -> &TxHash {
self.transaction.hash_ref()
self.transaction.tx_hash()
}
/// Returns the Sender of the transaction.