Hbbft updates.

This commit is contained in:
c0gent 2018-10-04 10:13:14 -07:00
parent 698bb0dffb
commit 5927daf6fa
No known key found for this signature in database
GPG Key ID: 9CC25E71A743E892
3 changed files with 11 additions and 6 deletions

View File

@ -52,9 +52,9 @@ clear_on_drop = "*"
[dependencies.hbbft]
version = "*"
git = "https://github.com/c0gent/hbbft"
# git = "https://github.com/poanetwork/hbbft"
branch = "pre-rng-change"
# git = "https://github.com/c0gent/hbbft"
git = "https://github.com/poanetwork/hbbft"
branch = "c0gent-rng-sync"
# branch = "master"
# path = "../hbbft"

View File

@ -25,6 +25,7 @@ use {
Contribution, InAddr, Input, InternalMessage, InternalMessageKind, InternalRx, Message,
NetworkNodeInfo, NetworkState, OutAddr, Step, Uid, WireMessage, WireMessageKind, BatchTx,
};
use rand;
/// Hydrabadger event (internal message) handler.
pub struct Handler<T: Contribution> {
@ -230,8 +231,9 @@ impl<T: Contribution> Handler<T> {
} => {
// TODO: Move this match block into a function somewhere for re-use:
info!("KEY GENERATION: Handling part from '{}'...", src_uid);
let mut rng = rand::OsRng::new().expect("Creating OS Rng has failed");
let mut skg = sync_key_gen.as_mut().unwrap();
let ack = match skg.handle_part(src_uid, part) {
let ack = match skg.handle_part(&mut rng, src_uid, part) {
Some(PartOutcome::Valid(ack)) => ack,
Some(PartOutcome::Invalid(faults)) => panic!(
"Invalid part \

View File

@ -16,6 +16,7 @@ use hbbft::{
};
use peer::Peers;
use std::{collections::BTreeMap, fmt};
use rand;
use {Contribution, Input, Message, NetworkNodeInfo, NetworkState, Step, Uid};
/// A `State` discriminant.
@ -179,13 +180,15 @@ impl<T: Contribution> State<T> {
let pk = local_sk.public_key();
public_keys.insert(*local_uid, pk);
let mut rng = rand::OsRng::new().expect("Creating OS Rng has failed");
let (mut sync_key_gen, opt_part) =
SyncKeyGen::new(*local_uid, local_sk, public_keys.clone(), threshold)
SyncKeyGen::new(&mut rng, *local_uid, local_sk, public_keys.clone(), threshold)
.map_err(Error::SyncKeyGenNew)?;
part = opt_part.expect("This node is not a validator (somehow)!");
info!("KEY GENERATION: Handling our own `Part`...");
ack = match sync_key_gen.handle_part(&local_uid, part.clone()) {
ack = match sync_key_gen.handle_part(&mut rng, &local_uid, part.clone()) {
Some(PartOutcome::Valid(ack)) => ack,
Some(PartOutcome::Invalid(faults)) => panic!(
"Invalid part \