From e7fba3a4735842b73e4c8a54e8f0119f5127ef3e Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 10 Mar 2019 08:36:49 +1100 Subject: [PATCH] Process transfers in parallel. --- eth2/state_processing/src/per_block_processing.rs | 9 ++++++++- eth2/types/src/test_utils/testing_transfer_builder.rs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/eth2/state_processing/src/per_block_processing.rs b/eth2/state_processing/src/per_block_processing.rs index c446dcd85..d871914d9 100644 --- a/eth2/state_processing/src/per_block_processing.rs +++ b/eth2/state_processing/src/per_block_processing.rs @@ -442,8 +442,15 @@ pub fn process_transfers( transfers.len() as u64 <= spec.max_transfers, Invalid::MaxTransfersExceed ); + + transfers + .par_iter() + .enumerate() + .try_for_each(|(i, transfer)| { + verify_transfer(&state, transfer, spec).map_err(|e| e.into_with_index(i)) + })?; + for (i, transfer) in transfers.iter().enumerate() { - verify_transfer(&state, transfer, spec).map_err(|e| e.into_with_index(i))?; execute_transfer(state, transfer, spec).map_err(|e| e.into_with_index(i))?; } diff --git a/eth2/types/src/test_utils/testing_transfer_builder.rs b/eth2/types/src/test_utils/testing_transfer_builder.rs index a8a6d7a17..c343e8fd2 100644 --- a/eth2/types/src/test_utils/testing_transfer_builder.rs +++ b/eth2/types/src/test_utils/testing_transfer_builder.rs @@ -9,7 +9,7 @@ impl TestingTransferBuilder { pub fn new(from: u64, to: u64, amount: u64, slot: Slot) -> Self { let keypair = Keypair::random(); - let mut transfer = Transfer { + let transfer = Transfer { from, to, amount,