From c3a49aea727e269af63a9ae71fd49374c64dbbd5 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 14 Mar 2023 11:01:18 +0100 Subject: [PATCH] style: resort trait impl order (#1749) --- crates/primitives/src/transaction/mod.rs | 38 +++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index f9d43f6a30..41668749ba 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -176,6 +176,8 @@ pub enum Transaction { Eip1559(TxEip1559), } +// === impl Transaction === + impl Transaction { /// Heavy operation that return signature hash over rlp encoded transaction. /// It is only for signature signing or signer recovery. @@ -856,6 +858,8 @@ pub struct TransactionSignedEcRecovered { signed_transaction: TransactionSigned, } +// === impl TransactionSignedEcRecovered === + impl TransactionSignedEcRecovered { /// Signer of transaction recovered from signature pub fn signer(&self) -> Address { @@ -874,23 +878,6 @@ impl TransactionSignedEcRecovered { } } -/// A transaction type that can be created from a [`TransactionSignedEcRecovered`] transaction. -/// -/// This is a conversion trait that'll ensure transactions received via P2P can be converted to the -/// transaction type that the transaction pool uses. -pub trait FromRecoveredTransaction { - /// Converts to this type from the given [`TransactionSignedEcRecovered`]. - fn from_recovered_transaction(tx: TransactionSignedEcRecovered) -> Self; -} - -// Noop conversion -impl FromRecoveredTransaction for TransactionSignedEcRecovered { - #[inline] - fn from_recovered_transaction(tx: TransactionSignedEcRecovered) -> Self { - tx - } -} - impl Encodable for TransactionSignedEcRecovered { fn encode(&self, out: &mut dyn bytes::BufMut) { self.signed_transaction.encode(out) @@ -911,6 +898,23 @@ impl Decodable for TransactionSignedEcRecovered { } } +/// A transaction type that can be created from a [`TransactionSignedEcRecovered`] transaction. +/// +/// This is a conversion trait that'll ensure transactions received via P2P can be converted to the +/// transaction type that the transaction pool uses. +pub trait FromRecoveredTransaction { + /// Converts to this type from the given [`TransactionSignedEcRecovered`]. + fn from_recovered_transaction(tx: TransactionSignedEcRecovered) -> Self; +} + +// Noop conversion +impl FromRecoveredTransaction for TransactionSignedEcRecovered { + #[inline] + fn from_recovered_transaction(tx: TransactionSignedEcRecovered) -> Self { + tx + } +} + /// The inverse of [`FromRecoveredTransaction`] that ensure the transaction can be sent over the /// network pub trait IntoRecoveredTransaction {