feat: support blob transactions in manager (#4294)

This commit is contained in:
Matthias Seitz
2023-08-21 17:05:11 +02:00
committed by GitHub
parent 0d47e4cf4f
commit 3b404acc7d
3 changed files with 54 additions and 14 deletions

View File

@ -46,6 +46,17 @@ pub enum PooledTransactionsElement {
}
impl PooledTransactionsElement {
/// Tries to convert a [TransactionSigned] into a [PooledTransactionsElement].
///
/// [BlobTransaction] are disallowed from being propagated, hence this returns an error if the
/// `tx` is [Transaction::Eip4844]
pub fn try_from_broadcast(tx: TransactionSigned) -> Result<Self, TransactionSigned> {
if tx.is_eip4844() {
return Err(tx)
}
Ok(tx.into())
}
/// Heavy operation that return signature hash over rlp encoded transaction.
/// It is only for signature signing or signer recovery.
pub fn signature_hash(&self) -> H256 {
@ -57,6 +68,16 @@ impl PooledTransactionsElement {
}
}
/// Reference to transaction hash. Used to identify transaction.
pub fn hash(&self) -> &TxHash {
match self {
PooledTransactionsElement::Legacy { hash, .. } => hash,
PooledTransactionsElement::Eip2930 { hash, .. } => hash,
PooledTransactionsElement::Eip1559 { hash, .. } => hash,
PooledTransactionsElement::BlobTransaction(tx) => &tx.hash,
}
}
/// Returns the signature of the transaction.
pub fn signature(&self) -> &Signature {
match self {