Add (untested) parallelization for att validation
This commit is contained in:
parent
05fe231e41
commit
b92d88d42b
@ -17,6 +17,7 @@ ethereum-types = "0.4.0"
|
|||||||
futures = "0.1.23"
|
futures = "0.1.23"
|
||||||
network-libp2p = { path = "network-libp2p" }
|
network-libp2p = { path = "network-libp2p" }
|
||||||
rand = "0.3"
|
rand = "0.3"
|
||||||
|
rayon = "1.0.2"
|
||||||
rocksdb = "0.10.1"
|
rocksdb = "0.10.1"
|
||||||
rlp = { git = "https://github.com/paritytech/parity-common" }
|
rlp = { git = "https://github.com/paritytech/parity-common" }
|
||||||
slog = "^2.2.3"
|
slog = "^2.2.3"
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
extern crate rayon;
|
||||||
|
use self::rayon::prelude::*;
|
||||||
|
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
Arc,
|
Arc,
|
||||||
RwLock,
|
RwLock,
|
||||||
@ -48,6 +51,7 @@ pub enum SszBlockValidationError {
|
|||||||
FirstAttestationSignatureFailed,
|
FirstAttestationSignatureFailed,
|
||||||
NoProposerSignature,
|
NoProposerSignature,
|
||||||
BadProposerMap,
|
BadProposerMap,
|
||||||
|
RwLockPoisoned,
|
||||||
DatabaseError(String),
|
DatabaseError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +179,7 @@ pub fn validate_ssz_block<T>(b: &SszBlock,
|
|||||||
*/
|
*/
|
||||||
let failure: Option<SszBlockValidationError> = None;
|
let failure: Option<SszBlockValidationError> = None;
|
||||||
let failure = RwLock::new(failure);
|
let failure = RwLock::new(failure);
|
||||||
other_attestations.iter()
|
other_attestations.par_iter()
|
||||||
.for_each(|attestation| {
|
.for_each(|attestation| {
|
||||||
if let Some(_) = *failure.read().unwrap() {
|
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
|
// TODO: handle validation failure. Presently, it will just pass everything
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user