feat: add try_into_pooled_eip4844 (#12792)

This commit is contained in:
Matthias Seitz
2024-11-22 20:41:11 +01:00
committed by GitHub
parent 2d5256cb05
commit 71fd63d9ac
2 changed files with 23 additions and 0 deletions

View File

@ -770,6 +770,14 @@ impl EthPoolTransaction for MockTransaction {
}
}
fn try_into_pooled_eip4844(self, sidecar: Arc<BlobTransactionSidecar>) -> Option<Self::Pooled> {
Self::Pooled::try_from_blob_transaction(
self.into_consensus(),
Arc::unwrap_or_clone(sidecar),
)
.ok()
}
fn validate_blob(
&self,
_blob: &BlobTransactionSidecar,

View File

@ -1093,6 +1093,13 @@ pub trait EthPoolTransaction:
/// Returns the number of blobs this transaction has.
fn blob_count(&self) -> usize;
/// A specialization for the EIP-4844 transaction type.
/// Tries to reattach the blob sidecar to the transaction.
///
/// This returns an option, but callers should ensure that the transaction is an EIP-4844
/// transaction: [`PoolTransaction::is_eip4844`].
fn try_into_pooled_eip4844(self, sidecar: Arc<BlobTransactionSidecar>) -> Option<Self::Pooled>;
/// Validates the blob sidecar of the transaction with the given settings.
fn validate_blob(
&self,
@ -1324,6 +1331,14 @@ impl EthPoolTransaction for EthPooledTransaction {
}
}
fn try_into_pooled_eip4844(self, sidecar: Arc<BlobTransactionSidecar>) -> Option<Self::Pooled> {
PooledTransactionsElementEcRecovered::try_from_blob_transaction(
self.into_consensus(),
Arc::unwrap_or_clone(sidecar),
)
.ok()
}
fn validate_blob(
&self,
sidecar: &BlobTransactionSidecar,