Skip to content

Commit

Permalink
feat: add RecoveredTx::try_map_transaction (#1885)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 4, 2025
1 parent fa109e3 commit 3539a02
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/consensus/src/transaction/recovered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ impl<T> Recovered<T> {
pub fn map_transaction<Tx>(self, f: impl FnOnce(T) -> Tx) -> Recovered<Tx> {
Recovered::new_unchecked(f(self.tx), self.signer)
}

/// Applies the given fallible closure to the inner transactions.
pub fn try_map_transaction<Tx, E>(
self,
f: impl FnOnce(T) -> Result<Tx, E>,
) -> Result<Recovered<Tx>, E> {
Ok(Recovered::new_unchecked(f(self.tx)?, self.signer))
}
}

impl<T: Encodable> Encodable for Recovered<T> {
Expand Down

0 comments on commit 3539a02

Please sign in to comment.