pub struct ConsensusConfig { /* private fields */ }Expand description
Per-session configuration controlling how consensus is reached.
Use ConsensusConfig::gossipsub() or ConsensusConfig::p2p() for sensible
defaults, then refine with builder methods like with_timeout
and with_threshold.
Implementations§
Source§impl ConsensusConfig
impl ConsensusConfig
Sourcepub fn p2p() -> Self
pub fn p2p() -> Self
Default configuration for P2P transport: derive round cap as ceil(2n/3). Max rounds is 0, so the round cap is calculated dynamically based on the expected voters count.
Sourcepub fn with_timeout(
self,
consensus_timeout: Duration,
) -> Result<Self, ConsensusError>
pub fn with_timeout( self, consensus_timeout: Duration, ) -> Result<Self, ConsensusError>
Set consensus timeout (validated) and return the updated config.
Sourcepub fn with_threshold(
self,
consensus_threshold: f64,
) -> Result<Self, ConsensusError>
pub fn with_threshold( self, consensus_threshold: f64, ) -> Result<Self, ConsensusError>
Set consensus threshold (validated) and return the updated config.
Sourcepub fn with_liveness_criteria(self, liveness_criteria: bool) -> Self
pub fn with_liveness_criteria(self, liveness_criteria: bool) -> Self
Set liveness criteria and return the updated config.
Sourcepub fn consensus_timeout(&self) -> Duration
pub fn consensus_timeout(&self) -> Duration
Maximum time to wait for consensus before timing out.
Sourcepub fn consensus_threshold(&self) -> f64
pub fn consensus_threshold(&self) -> f64
Fraction of expected voters required before consensus can be determined.
Sourcepub fn liveness_criteria(&self) -> bool
pub fn liveness_criteria(&self) -> bool
Whether silent peers are counted as YES (true) or NO (false).
Sourcepub fn max_rounds(&self) -> u32
pub fn max_rounds(&self) -> u32
Maximum number of voting rounds allowed.
Sourcepub fn use_gossipsub_rounds(&self) -> bool
pub fn use_gossipsub_rounds(&self) -> bool
Whether Gossipsub-style fixed 2-round semantics are in effect.
Trait Implementations§
Source§impl Clone for ConsensusConfig
impl Clone for ConsensusConfig
Source§fn clone(&self) -> ConsensusConfig
fn clone(&self) -> ConsensusConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConsensusConfig
impl Debug for ConsensusConfig
Source§impl From<NetworkType> for ConsensusConfig
impl From<NetworkType> for ConsensusConfig
Source§fn from(network_type: NetworkType) -> Self
fn from(network_type: NetworkType) -> Self
Source§impl From<ScopeConfig> for ConsensusConfig
impl From<ScopeConfig> for ConsensusConfig
Source§fn from(config: ScopeConfig) -> Self
fn from(config: ScopeConfig) -> Self
Auto Trait Implementations§
impl Freeze for ConsensusConfig
impl RefUnwindSafe for ConsensusConfig
impl Send for ConsensusConfig
impl Sync for ConsensusConfig
impl Unpin for ConsensusConfig
impl UnwindSafe for ConsensusConfig
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more