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

@@ -5,6 +5,7 @@ use parking_lot::{RwLock, RwLockReadGuard};
use ssz::{Decode, Encode};
use ssz_derive::{Decode, Encode};
use std::collections::HashMap;
use std::ptr;
use types::{Epoch, Hash256, Slot};
pub const DEFAULT_PRUNE_THRESHOLD: usize = 256;
@@ -51,6 +52,9 @@ pub struct ProtoArrayForkChoice {
impl PartialEq for ProtoArrayForkChoice {
fn eq(&self, other: &Self) -> bool {
if ptr::eq(self, other) {
return true;
}
*self.proto_array.read() == *other.proto_array.read()
&& *self.votes.read() == *other.votes.read()
&& *self.balances.read() == *other.balances.read()