Add a few doc comments, make `SubsetHandler` and `SubsetHandleData` private.

This commit is contained in:
Erich Gubler 2018-10-03 09:04:27 -06:00
parent 13162a2e64
commit 2e188ca257
3 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@ pub struct DynamicHoneyBadgerBuilder<C, N> {
/// Random number generator passed on to algorithm instance for key generation. Also used to
/// instantiate `HoneyBadger`.
rng: Box<dyn rand::Rng>,
/// Strategy used to handle the output of the `Subset` algorithm.
subset_handling_strategy: SubsetHandlingStrategy,
_phantom: PhantomData<(C, N)>,
}
@ -60,6 +61,7 @@ where
self
}
/// Sets the strategy to use when handling `Subset` output.
pub fn subset_handling_strategy(
&mut self,
subset_handling_strategy: SubsetHandlingStrategy,

View File

@ -22,6 +22,7 @@ where
max_future_epochs: usize,
/// Random number generator passed on to algorithm instance for signing and encrypting.
rng: Box<dyn Rng>,
/// Strategy used to handle the output of the `Subset` algorithm.
subset_handling_strategy: SubsetHandlingStrategy,
_phantom: PhantomData<C>,
}
@ -55,6 +56,7 @@ where
self
}
/// Sets the strategy to use when handling `Subset` output.
pub fn subset_handling_strategy(
&mut self,
subset_handling_strategy: SubsetHandlingStrategy,

View File

@ -110,20 +110,26 @@ where
/// proposals from a `Subset` instance.
#[derive(Debug, Clone)]
pub enum SubsetHandlingStrategy {
/// Sets the `EpochState` to return proposals as they are contributed.
Incremental,
/// Sets the `EpochState` to return all received proposals once consensus has been finalized.
AllAtEnd,
}
/// Used in an `EpochState` to encapsulate the state necessary to maintain each
/// `SubsetHandlingStrategy`.
#[derive(Debug, Clone)]
pub enum SubsetHandler<N> {
enum SubsetHandler<N> {
Incremental,
AllAtEnd(Vec<(N, Vec<u8>)>),
}
pub struct SubsetHandleData<N> {
/// The result of a call to `SubsetHandler::handle(...)`.
struct SubsetHandleData<N> {
/// The number of contributions propagated from the handler.
contributions: Vec<(N, Vec<u8>)>,
/// Indicates whether the underlying `Subset` algorithm has achieved consensus and whether
/// there may be more contributions or not.
is_done: bool,
}