beacon_node, consensus: fix possible deadlocks when comparing with itself (#1241)

This commit is contained in:
Boqin Qin
2020-06-09 05:08:54 +08:00
committed by GitHub
parent 208f1da81b
commit 7baac70056
2 changed files with 8 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ use state_processing::per_block_processing::{
};
use std::collections::{hash_map, HashMap, HashSet};
use std::marker::PhantomData;
use std::ptr;
use types::{
typenum::Unsigned, Attestation, AttesterSlashing, BeaconState, BeaconStateError, ChainSpec,
EthSpec, Fork, Hash256, ProposerSlashing, RelativeEpoch, SignedVoluntaryExit, Validator,
@@ -408,6 +409,9 @@ fn prune_validator_hash_map<T, F, E: EthSpec>(
/// Compare two operation pools.
impl<T: EthSpec + Default> PartialEq for OperationPool<T> {
fn eq(&self, other: &Self) -> bool {
if ptr::eq(self, other) {
return true;
}
*self.attestations.read() == *other.attestations.read()
&& *self.attester_slashings.read() == *other.attester_slashings.read()
&& *self.proposer_slashings.read() == *other.proposer_slashings.read()