order invariant seal equality

This commit is contained in:
keorn 2016-11-29 11:18:40 +00:00
parent d0eab4a0d8
commit 49b953a9f4
1 changed files with 10 additions and 1 deletions

View File

@ -26,12 +26,21 @@ pub struct VoteCollector {
votes: RwLock<BTreeMap<ConsensusMessage, Address>>
}
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
pub struct SealSignatures {
pub proposal: H520,
pub votes: Vec<H520>
}
impl PartialEq for SealSignatures {
fn eq(&self, other: &SealSignatures) -> bool {
self.proposal == other.proposal
&& self.votes.iter().collect::<HashSet<_>>() == other.votes.iter().collect::<HashSet<_>>()
}
}
impl Eq for SealSignatures {}
impl VoteCollector {
pub fn new() -> VoteCollector {
let mut collector = BTreeMap::new();