Add `Sync` req. on boxed rngs.

This commit is contained in:
c0gent 2018-10-04 10:08:52 -07:00 committed by Nick Sanders
parent 4b00bda555
commit 9d3e264b4f
5 changed files with 7 additions and 7 deletions

View File

@ -78,7 +78,7 @@ pub type Step<N, T> = messaging::Step<Coin<N, T>>;
impl<N, T> DistAlgorithm for Coin<N, T>
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<N, T> Coin<N, T>
where
N: NodeIdT,
T: Clone + AsRef<[u8]> + Send,
T: Clone + AsRef<[u8]> + Send + Sync,
{
pub fn new(netinfo: Arc<NetworkInfo<N>>, nonce: T) -> Self {
Coin {

View File

@ -39,7 +39,7 @@ pub struct DynamicHoneyBadger<C, N: Rand> {
pub(super) incoming_queue: Vec<(N, Message<N>)>,
/// A random number generator used for secret key generation.
// Boxed to avoid overloading the algorithm's type with more generics.
pub(super) rng: Box<dyn rand::Rng + Send>,
pub(super) rng: Box<dyn rand::Rng + Send + Sync>,
}
impl<C, N> fmt::Debug for DynamicHoneyBadger<C, N>

View File

@ -32,7 +32,7 @@ pub struct HoneyBadger<C, N: Rand> {
pub(super) remote_epochs: BTreeMap<N, u64>,
/// A random number generator used for secret key generation.
// Boxed to avoid overloading the algorithm's type with more generics.
pub(super) rng: Box<dyn Rng + Send>,
pub(super) rng: Box<dyn Rng + Send + Sync>,
/// Represents the optimization strategy to use for output of the `Subset` algorithm.
pub(super) subset_handling_strategy: SubsetHandlingStrategy,
}

View File

@ -185,7 +185,7 @@ impl<D: DistAlgorithm> From<TargetedMessage<D::Message, D::NodeId>> for Step<D>
}
/// 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.

View File

@ -7,14 +7,14 @@ use rand;
/// Workaround trait for creating new random number generators
pub trait SubRng {
fn sub_rng(&mut self) -> Box<dyn rand::Rng + Send>;
fn sub_rng(&mut self) -> Box<dyn rand::Rng + Send + Sync>;
}
impl<R> SubRng for R
where
R: rand::Rng,
{
fn sub_rng(&mut self) -> Box<dyn rand::Rng + Send> {
fn sub_rng(&mut self) -> Box<dyn rand::Rng + Send + Sync> {
// 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`.