Process transfers in parallel.

This commit is contained in:
Paul Hauner 2019-03-10 08:36:49 +11:00
parent 1ca99b8c4c
commit e7fba3a473
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 9 additions and 2 deletions

View File

@ -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))?;
}

View File

@ -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,