mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #276 from poanetwork/afck-perf
Avoid BTreeMap in EpochState.
This commit is contained in:
commit
c5ebdb5347
|
@ -48,14 +48,6 @@ where
|
||||||
DecryptionState::Complete(_) => Ok(td::Step::default()),
|
DecryptionState::Complete(_) => Ok(td::Step::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the plaintext, if it has already been decrypted.
|
|
||||||
fn plaintext(&self) -> Option<&[u8]> {
|
|
||||||
match self {
|
|
||||||
DecryptionState::Ongoing(_) => None,
|
|
||||||
DecryptionState::Complete(ref plaintext) => Some(&plaintext[..]),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The status of the subset algorithm.
|
/// The status of the subset algorithm.
|
||||||
|
@ -265,13 +257,13 @@ where
|
||||||
/// epoch, moves those contributions into a batch, outputs the batch and updates the epoch.
|
/// epoch, moves those contributions into a batch, outputs the batch and updates the epoch.
|
||||||
pub fn try_output_batch(&self) -> Option<(Batch<C, N>, FaultLog<N>)> {
|
pub fn try_output_batch(&self) -> Option<(Batch<C, N>, FaultLog<N>)> {
|
||||||
let proposer_ids = self.subset.accepted_ids()?;
|
let proposer_ids = self.subset.accepted_ids()?;
|
||||||
let plaintexts: BTreeMap<N, &[u8]> = self
|
let mut plaintexts = Vec::new();
|
||||||
.decryption
|
// Collect accepted plaintexts. Return if some are not decrypted yet.
|
||||||
.iter()
|
for id in proposer_ids {
|
||||||
.flat_map(|(id, dec_state)| dec_state.plaintext().map(|pt| (id.clone(), pt)))
|
match self.decryption.get(id) {
|
||||||
.collect();
|
None | Some(DecryptionState::Ongoing(_)) => return None,
|
||||||
if !proposer_ids.iter().eq(plaintexts.keys()) {
|
Some(DecryptionState::Complete(ref pt)) => plaintexts.push((id.clone(), pt)),
|
||||||
return None; // Not all accepted contributions are decrypted yet.
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut fault_log = FaultLog::default();
|
let mut fault_log = FaultLog::default();
|
||||||
|
|
Loading…
Reference in New Issue