pub struct NetworkInfo<N> { /* private fields */ }Expand description
Common data shared between algorithms: the nodes’ IDs and key shares.
Implementations§
Source§impl<N: NodeIdT> NetworkInfo<N>
impl<N: NodeIdT> NetworkInfo<N>
Sourcepub fn new<SKS: Into<Option<SecretKeyShare>>, V: Into<ValidatorSet<N>>>(
our_id: N,
secret_key_share: SKS,
public_key_set: PublicKeySet,
val_set: V,
) -> Self
pub fn new<SKS: Into<Option<SecretKeyShare>>, V: Into<ValidatorSet<N>>>( our_id: N, secret_key_share: SKS, public_key_set: PublicKeySet, val_set: V, ) -> Self
Creates a new NetworkInfo with the given ID and keys.
All nodes in the network must share the same public information. Validators’ IDs must be
keys in the public_keys map, and their secret key share must match their share in the
public_key_set.
§Panics
Panics if public_keys is empty or the requirement above is not satisfied, i.e. if the
secret key doesn’t match the public key or is missing.
Sourcepub fn other_ids(&self) -> impl Iterator<Item = &N> + Clone
pub fn other_ids(&self) -> impl Iterator<Item = &N> + Clone
ID of all nodes in the network except this one.
Sourcepub fn num_faulty(&self) -> usize
pub fn num_faulty(&self) -> usize
The maximum number f of faulty, Byzantine nodes up to which Honey Badger is guaranteed to be correct.
Sourcepub fn num_correct(&self) -> usize
pub fn num_correct(&self) -> usize
The minimum number N - f of correct nodes with which Honey Badger is guaranteed to be correct.
Returns our secret key share for threshold cryptography, or None if not a validator.
Sourcepub fn public_key_set(&self) -> &PublicKeySet
pub fn public_key_set(&self) -> &PublicKeySet
Returns the public key set for threshold cryptography.
Returns the public key share if a node with that ID exists, otherwise None.
Returns a map of all node IDs to their public key shares.
Sourcepub fn node_index(&self, id: &N) -> Option<usize>
pub fn node_index(&self, id: &N) -> Option<usize>
The index of a node in a canonical numbering of all nodes. This is the index where the
node appears in all_ids.
Sourcepub fn is_validator(&self) -> bool
pub fn is_validator(&self) -> bool
Returns true if this node takes part in the consensus itself. If not, it is only an
observer.
Sourcepub fn is_node_validator(&self, id: &N) -> bool
pub fn is_node_validator(&self, id: &N) -> bool
Returns true if the given node takes part in the consensus itself. If not, it is only an
observer.
Sourcepub fn validator_set(&self) -> &Arc<ValidatorSet<N>>
pub fn validator_set(&self) -> &Arc<ValidatorSet<N>>
Returns the set of validator IDs.
Sourcepub fn generate_map<I, R>(
ids: I,
rng: &mut R,
) -> Result<BTreeMap<N, NetworkInfo<N>>, Error>where
I: IntoIterator<Item = N>,
R: Rng,
pub fn generate_map<I, R>(
ids: I,
rng: &mut R,
) -> Result<BTreeMap<N, NetworkInfo<N>>, Error>where
I: IntoIterator<Item = N>,
R: Rng,
Generates a map of matching NetworkInfos for testing.
Trait Implementations§
Source§impl<N: Clone> Clone for NetworkInfo<N>
impl<N: Clone> Clone for NetworkInfo<N>
Source§fn clone(&self) -> NetworkInfo<N>
fn clone(&self) -> NetworkInfo<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<N> Freeze for NetworkInfo<N>where
N: Freeze,
impl<N> RefUnwindSafe for NetworkInfo<N>where
N: RefUnwindSafe,
impl<N> Send for NetworkInfo<N>
impl<N> Sync for NetworkInfo<N>
impl<N> Unpin for NetworkInfo<N>where
N: Unpin,
impl<N> UnwindSafe for NetworkInfo<N>where
N: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.