Merge pull request #305 from poanetwork/afck-fix-sbv-bc

Fix SbvBroadcast observer issue.
This commit is contained in:
Vladimir Komendantskiy 2018-10-28 18:01:01 +00:00 committed by GitHub
commit 52d48675f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -145,7 +145,7 @@ impl<N: NodeIdT> SbvBroadcast<N> {
/// Multicasts and handles a message. Does nothing if we are only an observer.
fn send(&mut self, msg: Message) -> Result<Step<N>> {
if !self.netinfo.is_validator() {
return Ok(Step::default());
return self.try_output();
}
let step: Step<_> = Target::All.message(msg.clone()).into();
let our_id = &self.our_id().clone();

View File

@ -94,6 +94,10 @@ impl<N: NodeIdT> ThresholdDecryption<N> {
if self.ciphertext.is_some() {
return Err(Error::MultipleInputs(Box::new(ct)));
}
if !self.netinfo.is_validator() {
self.ciphertext = Some(ct);
return Ok(self.try_output()?);
}
let share = match self.netinfo.secret_key_share().decrypt_share(&ct) {
None => return Err(Error::InvalidCiphertext(Box::new(ct))),
Some(share) => share,
@ -102,11 +106,9 @@ impl<N: NodeIdT> ThresholdDecryption<N> {
let our_id = self.our_id().clone();
let mut step = Step::default();
step.fault_log.extend(self.remove_invalid_shares());
if self.netinfo.is_validator() {
let msg = Target::All.message(Message(share.clone()));
step.messages.push(msg);
self.shares.insert(our_id, share);
}
let msg = Target::All.message(Message(share.clone()));
step.messages.push(msg);
self.shares.insert(our_id, share);
step.extend(self.try_output()?);
Ok(step)
}