Move validation submissions into its own fn (#4528)

automerge
This commit is contained in:
Sagar Dhawan
2019-06-03 18:27:06 -07:00
committed by Grimes
parent 167e15a5ae
commit a77775cb58

View File

@ -483,6 +483,23 @@ impl StorageStage {
slot,
instruction_sender,
)?;
Self::submit_verifications(
&storage_state,
&storage_keypair,
instruction_sender,
)?
}
}
}
}
Ok(())
}
fn submit_verifications(
storage_state: &Arc<RwLock<StorageStateInner>>,
storage_keypair: &Arc<Keypair>,
ix_sender: &Sender<Instruction>,
) -> Result<()> {
// bundle up mining submissions from replicators
// and submit them in a tx to the leader to get rewarded.
let mut w_state = storage_state.write().unwrap();
@ -507,11 +524,8 @@ impl StorageStage {
})
.collect::<HashMap<_, _>>();
if !checked_proofs.is_empty() {
let ix = proof_validation(
&storage_keypair.pubkey(),
segment as u64,
checked_proofs,
);
let ix =
proof_validation(&storage_keypair.pubkey(), segment as u64, checked_proofs);
Some(ix)
} else {
None
@ -521,13 +535,9 @@ impl StorageStage {
// TODO Avoid AccountInUse errors in this loop
let res: std::result::Result<_, _> = instructions
.into_iter()
.map(|ix| instruction_sender.send(ix))
.map(|ix| ix_sender.send(ix))
.collect();
res?
}
}
}
}
res?;
Ok(())
}
}