mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add clone into consensus (#12999)
This commit is contained in:
@ -602,7 +602,7 @@ where
|
||||
.into_iter()
|
||||
.map(|tx| {
|
||||
let recovered: TransactionSignedEcRecovered =
|
||||
tx.transaction.clone().into_consensus().into();
|
||||
tx.transaction.clone_into_consensus().into();
|
||||
recovered.into_signed()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@ -979,6 +979,13 @@ pub trait PoolTransaction: fmt::Debug + Send + Sync + Clone {
|
||||
tx.try_into()
|
||||
}
|
||||
|
||||
/// Clone the transaction into a consensus variant.
|
||||
///
|
||||
/// This method is preferred when the [`PoolTransaction`] already wraps the consensus variant.
|
||||
fn clone_into_consensus(&self) -> Self::Consensus {
|
||||
self.clone().into_consensus()
|
||||
}
|
||||
|
||||
/// Define a method to convert from the `Self` type to `Consensus`
|
||||
fn into_consensus(self) -> Self::Consensus {
|
||||
self.into()
|
||||
@ -1237,6 +1244,10 @@ impl PoolTransaction for EthPooledTransaction {
|
||||
|
||||
type Pooled = PooledTransactionsElementEcRecovered;
|
||||
|
||||
fn clone_into_consensus(&self) -> Self::Consensus {
|
||||
self.transaction().clone()
|
||||
}
|
||||
|
||||
fn try_consensus_into_pooled(
|
||||
tx: Self::Consensus,
|
||||
) -> Result<Self::Pooled, Self::TryFromConsensusError> {
|
||||
|
||||
@ -375,6 +375,13 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
|
||||
self.is_eip4844() != other.is_eip4844()
|
||||
}
|
||||
|
||||
/// Converts to this type into the consensus transaction of the pooled transaction.
|
||||
///
|
||||
/// Note: this takes `&self` since indented usage is via `Arc<Self>`.
|
||||
pub fn to_consensus(&self) -> T::Consensus {
|
||||
self.transaction.clone_into_consensus()
|
||||
}
|
||||
|
||||
/// Determines whether a candidate transaction (`maybe_replacement`) is underpriced compared to
|
||||
/// an existing transaction in the pool.
|
||||
///
|
||||
@ -433,7 +440,7 @@ impl<T: PoolTransaction<Consensus: Into<TransactionSignedEcRecovered>>> ValidPoo
|
||||
///
|
||||
/// Note: this takes `&self` since indented usage is via `Arc<Self>`.
|
||||
pub fn to_recovered_transaction(&self) -> TransactionSignedEcRecovered {
|
||||
self.transaction.clone().into_consensus().into()
|
||||
self.to_consensus().into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user