mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: add a way to convert consensus to pooled variant (#12734)
This commit is contained in:
@ -608,6 +608,12 @@ impl PoolTransaction for MockTransaction {
|
||||
pooled.into()
|
||||
}
|
||||
|
||||
fn try_consensus_into_pooled(
|
||||
tx: Self::Consensus,
|
||||
) -> Result<Self::Pooled, Self::TryFromConsensusError> {
|
||||
Self::Pooled::try_from(tx).map_err(|_| TryFromRecoveredTransactionError::BlobSidecarMissing)
|
||||
}
|
||||
|
||||
fn hash(&self) -> &TxHash {
|
||||
self.get_hash()
|
||||
}
|
||||
|
||||
@ -946,6 +946,11 @@ pub trait PoolTransaction: fmt::Debug + Send + Sync + Clone {
|
||||
pooled.into()
|
||||
}
|
||||
|
||||
/// Tries to convert the `Consensus` type into the `Pooled` type.
|
||||
fn try_consensus_into_pooled(
|
||||
tx: Self::Consensus,
|
||||
) -> Result<Self::Pooled, Self::TryFromConsensusError>;
|
||||
|
||||
/// Hash of the transaction.
|
||||
fn hash(&self) -> &TxHash;
|
||||
|
||||
@ -1207,6 +1212,12 @@ impl PoolTransaction for EthPooledTransaction {
|
||||
|
||||
type Pooled = PooledTransactionsElementEcRecovered;
|
||||
|
||||
fn try_consensus_into_pooled(
|
||||
tx: Self::Consensus,
|
||||
) -> Result<Self::Pooled, Self::TryFromConsensusError> {
|
||||
Self::Pooled::try_from(tx).map_err(|_| TryFromRecoveredTransactionError::BlobSidecarMissing)
|
||||
}
|
||||
|
||||
/// Returns hash of the transaction.
|
||||
fn hash(&self) -> &TxHash {
|
||||
self.transaction.hash_ref()
|
||||
|
||||
Reference in New Issue
Block a user