reth_primitives_traits/transaction/
recover.rs1#[cfg(feature = "rayon")]
4pub use rayon::*;
5
6#[cfg(not(feature = "rayon"))]
7pub use iter::*;
8
9#[cfg(feature = "rayon")]
10mod rayon {
11 use crate::{transaction::signed::RecoveryError, SignedTransaction};
12 use alloc::vec::Vec;
13 use alloy_primitives::Address;
14 use rayon::prelude::{IntoParallelIterator, ParallelIterator};
15
16 pub fn recover_signers<'a, I, T>(txes: I) -> Result<Vec<Address>, RecoveryError>
20 where
21 T: SignedTransaction,
22 I: IntoParallelIterator<Item = &'a T> + IntoIterator<Item = &'a T> + Send,
23 {
24 txes.into_par_iter().map(|tx| tx.recover_signer()).collect()
25 }
26
27 pub fn recover_signers_unchecked<'a, I, T>(txes: I) -> Result<Vec<Address>, RecoveryError>
32 where
33 T: SignedTransaction,
34 I: IntoParallelIterator<Item = &'a T> + IntoIterator<Item = &'a T> + Send,
35 {
36 txes.into_par_iter().map(|tx| tx.recover_signer_unchecked()).collect()
37 }
38}
39
40#[cfg(not(feature = "rayon"))]
41mod iter {
42 use crate::{transaction::signed::RecoveryError, SignedTransaction};
43 use alloc::vec::Vec;
44 use alloy_primitives::Address;
45
46 pub fn recover_signers<'a, I, T>(txes: I) -> Result<Vec<Address>, RecoveryError>
50 where
51 T: SignedTransaction,
52 I: IntoIterator<Item = &'a T>,
53 {
54 txes.into_iter().map(|tx| tx.recover_signer()).collect()
55 }
56
57 pub fn recover_signers_unchecked<'a, I, T>(txes: I) -> Result<Vec<Address>, RecoveryError>
62 where
63 T: SignedTransaction,
64 I: IntoIterator<Item = &'a T>,
65 {
66 txes.into_iter().map(|tx| tx.recover_signer_unchecked()).collect()
67 }
68}