Fix clippy lints
This commit is contained in:
parent
c3d88a7e80
commit
fa705229aa
@ -80,8 +80,6 @@ impl Decodable for SpecialRecord {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -186,7 +186,7 @@ impl<T> BeaconBlockValidationContext<T>
|
||||
* The presence of oblique hashes in the first attestation would indicate that the proposer
|
||||
* of the previous block is attesting to some other block than the one they produced.
|
||||
*/
|
||||
if first_attestation.oblique_parent_hashes.len() > 0 {
|
||||
if !first_attestation.oblique_parent_hashes.is_empty() {
|
||||
return Err(SszBeaconBlockValidationError::ProposerAttestationHasObliqueHashes);
|
||||
}
|
||||
|
||||
@ -274,10 +274,12 @@ impl<T> BeaconBlockValidationContext<T>
|
||||
.filter_map(|attestation_ssz| {
|
||||
/*
|
||||
* If some thread has set the `failure` variable to `Some(error)` the abandon
|
||||
* attestation serialization and validation.
|
||||
* attestation serialization and validation. Also, fail early if the lock has been
|
||||
* poisoned.
|
||||
*/
|
||||
if let Some(_) = *failure.read().unwrap() {
|
||||
return None;
|
||||
match failure.read() {
|
||||
Ok(ref option) if option.is_none() => (),
|
||||
_ => return None
|
||||
}
|
||||
/*
|
||||
* If there has not been a failure yet, attempt to serialize and validate the
|
||||
@ -288,8 +290,12 @@ impl<T> BeaconBlockValidationContext<T>
|
||||
* Deserialization failed, therefore the block is invalid.
|
||||
*/
|
||||
Err(e) => {
|
||||
let mut failure = failure.write().unwrap();
|
||||
*failure = Some(SszBeaconBlockValidationError::from(e));
|
||||
/*
|
||||
* If the failure lock isn't poisoned, set it to some error.
|
||||
*/
|
||||
if let Ok(mut f) = failure.write() {
|
||||
*f = Some(SszBeaconBlockValidationError::from(e));
|
||||
}
|
||||
None
|
||||
}
|
||||
/*
|
||||
@ -301,8 +307,12 @@ impl<T> BeaconBlockValidationContext<T>
|
||||
* Attestation validation failed with some error.
|
||||
*/
|
||||
Err(e) => {
|
||||
let mut failure = failure.write().unwrap();
|
||||
*failure = Some(SszBeaconBlockValidationError::from(e));
|
||||
/*
|
||||
* If the failure lock isn't poisoned, set it to some error.
|
||||
*/
|
||||
if let Ok(mut f) = failure.write() {
|
||||
*f = Some(SszBeaconBlockValidationError::from(e));
|
||||
}
|
||||
None
|
||||
}
|
||||
/*
|
||||
|
@ -10,6 +10,9 @@ use super::{
|
||||
};
|
||||
use super::BLOCKS_DB_COLUMN as DB_COLUMN;
|
||||
|
||||
type BeaconBlockHash = Vec<u8>;
|
||||
type BeaconBlockSsz = Vec<u8>;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum BeaconBlockAtSlotError {
|
||||
UnknownBeaconBlock,
|
||||
@ -65,7 +68,7 @@ impl<T: ClientDB> BeaconBlockStore<T> {
|
||||
///
|
||||
/// If a block is found, a tuple of (block_hash, serialized_block) is returned.
|
||||
pub fn block_at_slot(&self, head_hash: &[u8], slot: u64)
|
||||
-> Result<Option<(Vec<u8>, Vec<u8>)>, BeaconBlockAtSlotError>
|
||||
-> Result<Option<(BeaconBlockHash, BeaconBlockSsz)>, BeaconBlockAtSlotError>
|
||||
{
|
||||
match self.get_serialized_block(head_hash)? {
|
||||
None => Err(BeaconBlockAtSlotError::UnknownBeaconBlock),
|
||||
|
Loading…
Reference in New Issue
Block a user