From d7e87e460131b3b8405b602889088d1a34160817 Mon Sep 17 00:00:00 2001 From: c0gent Date: Thu, 4 Oct 2018 10:08:52 -0700 Subject: [PATCH] Add `Sync` req. on boxed rngs. --- src/coin.rs | 4 ++-- src/dynamic_honey_badger/dynamic_honey_badger.rs | 2 +- src/honey_badger/honey_badger.rs | 2 +- src/messaging.rs | 2 +- src/util.rs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coin.rs b/src/coin.rs index 5dc92d4..8c0eb24 100644 --- a/src/coin.rs +++ b/src/coin.rs @@ -78,7 +78,7 @@ pub type Step = messaging::Step>; impl DistAlgorithm for Coin where N: NodeIdT, - T: Clone + AsRef<[u8]> + Send, + T: Clone + AsRef<[u8]> + Send + Sync, { type NodeId = N; type Input = (); @@ -123,7 +123,7 @@ where impl Coin where N: NodeIdT, - T: Clone + AsRef<[u8]> + Send, + T: Clone + AsRef<[u8]> + Send + Sync, { pub fn new(netinfo: Arc>, nonce: T) -> Self { Coin { diff --git a/src/dynamic_honey_badger/dynamic_honey_badger.rs b/src/dynamic_honey_badger/dynamic_honey_badger.rs index abbf67f..9151dad 100644 --- a/src/dynamic_honey_badger/dynamic_honey_badger.rs +++ b/src/dynamic_honey_badger/dynamic_honey_badger.rs @@ -39,7 +39,7 @@ pub struct DynamicHoneyBadger { pub(super) incoming_queue: Vec<(N, Message)>, /// A random number generator used for secret key generation. // Boxed to avoid overloading the algorithm's type with more generics. - pub(super) rng: Box, + pub(super) rng: Box, } impl fmt::Debug for DynamicHoneyBadger diff --git a/src/honey_badger/honey_badger.rs b/src/honey_badger/honey_badger.rs index 02fa3f7..ff237af 100644 --- a/src/honey_badger/honey_badger.rs +++ b/src/honey_badger/honey_badger.rs @@ -32,7 +32,7 @@ pub struct HoneyBadger { pub(super) remote_epochs: BTreeMap, /// A random number generator used for secret key generation. // Boxed to avoid overloading the algorithm's type with more generics. - pub(super) rng: Box, + pub(super) rng: Box, /// Represents the optimization strategy to use for output of the `Subset` algorithm. pub(super) subset_handling_strategy: SubsetHandlingStrategy, } diff --git a/src/messaging.rs b/src/messaging.rs index cbe1bc1..562ccfa 100644 --- a/src/messaging.rs +++ b/src/messaging.rs @@ -185,7 +185,7 @@ impl From> for Step } /// A distributed algorithm that defines a message flow. -pub trait DistAlgorithm: Send { +pub trait DistAlgorithm: Send + Sync { /// Unique node identifier. type NodeId: NodeIdT; /// The input provided by the user. diff --git a/src/util.rs b/src/util.rs index d42539c..c038376 100644 --- a/src/util.rs +++ b/src/util.rs @@ -7,14 +7,14 @@ use rand; /// Workaround trait for creating new random number generators pub trait SubRng { - fn sub_rng(&mut self) -> Box; + fn sub_rng(&mut self) -> Box; } impl SubRng for R where R: rand::Rng, { - fn sub_rng(&mut self) -> Box { + fn sub_rng(&mut self) -> Box { // Currently hard-coded to be an `Isaac64Rng`, until better options emerge. This is either // dependant on `rand` 0.5 support or an API re-design of parts of `threshold_crypto` and // `hbbft`.