Add (untested) parallelization for att validation

This commit is contained in:
Paul Hauner 2018-09-28 15:38:51 +09:30
parent 05fe231e41
commit b92d88d42b
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
2 changed files with 16 additions and 1 deletions

View File

@ -17,6 +17,7 @@ ethereum-types = "0.4.0"
futures = "0.1.23"
network-libp2p = { path = "network-libp2p" }
rand = "0.3"
rayon = "1.0.2"
rocksdb = "0.10.1"
rlp = { git = "https://github.com/paritytech/parity-common" }
slog = "^2.2.3"

View File

@ -1,3 +1,6 @@
extern crate rayon;
use self::rayon::prelude::*;
use std::sync::{
Arc,
RwLock,
@ -48,6 +51,7 @@ pub enum SszBlockValidationError {
FirstAttestationSignatureFailed,
NoProposerSignature,
BadProposerMap,
RwLockPoisoned,
DatabaseError(String),
}
@ -175,7 +179,7 @@ pub fn validate_ssz_block<T>(b: &SszBlock,
*/
let failure: Option<SszBlockValidationError> = None;
let failure = RwLock::new(failure);
other_attestations.iter()
other_attestations.par_iter()
.for_each(|attestation| {
if let Some(_) = *failure.read().unwrap() {
()
@ -210,6 +214,16 @@ pub fn validate_ssz_block<T>(b: &SszBlock,
};
});
match failure.into_inner() {
Err(_) => return Err(SszBlockValidationError::RwLockPoisoned),
Ok(failure) => {
match failure {
Some(error) => return Err(error),
_ => ()
}
}
}
// TODO: handle validation failure. Presently, it will just pass everything
/*