feat(p2p): integrate txpool in p2p (#208)

This commit is contained in:
Matthias Seitz
2022-11-15 22:27:41 +01:00
committed by GitHub
parent f0388e4032
commit f8fddcdfa4
11 changed files with 305 additions and 61 deletions

View File

@@ -42,8 +42,8 @@ pub use log::Log;
pub use receipt::Receipt;
pub use storage::StorageEntry;
pub use transaction::{
AccessList, AccessListItem, FromRecoveredTransaction, Signature, Transaction, TransactionKind,
TransactionSigned, TransactionSignedEcRecovered, TxType,
AccessList, AccessListItem, FromRecoveredTransaction, IntoRecoveredTransaction, Signature,
Transaction, TransactionKind, TransactionSigned, TransactionSignedEcRecovered, TxType,
};
/// A block hash.

View File

@@ -571,6 +571,8 @@ impl TransactionSigned {
}
/// Recover signer from signature and hash.
///
/// Returns `None` if the transaction's signature is invalid.
pub fn recover_signer(&self) -> Option<Address> {
let signature_hash = self.signature_hash();
self.signature.recover_signer(signature_hash)
@@ -724,6 +726,22 @@ impl FromRecoveredTransaction for TransactionSignedEcRecovered {
}
}
/// The inverse of [`FromRecoveredTransaction`] that ensure the transaction can be sent over the
/// network
pub trait IntoRecoveredTransaction {
/// Converts to this type into a [`TransactionSignedEcRecovered`].
///
/// Note: this takes `&self` since indented usage is via `Arc<Self>`.
fn to_recovered_transaction(&self) -> TransactionSignedEcRecovered;
}
impl IntoRecoveredTransaction for TransactionSignedEcRecovered {
#[inline]
fn to_recovered_transaction(&self) -> TransactionSignedEcRecovered {
self.clone()
}
}
#[cfg(test)]
mod tests {
use crate::{