pub struct GossipProtocol {
pub nodes: HashMap<NodeId, TernaryNode>,
pub round: u64,
}Expand description
Gossip protocol for propagating ternary state across a cluster.
Each round, nodes share their state with random peers. State converges using a “dominant trit” rule: if any peer has a non-zero state, the receiving node adopts the most common non-zero value (with ties broken toward Pos).
Fields§
§nodes: HashMap<NodeId, TernaryNode>§round: u64Implementations§
Source§impl GossipProtocol
impl GossipProtocol
pub fn new() -> Self
pub fn add_node(&mut self, node: TernaryNode)
pub fn run_round(&mut self) -> u32
pub fn run_until_converged(&mut self, max_rounds: u64) -> u64
pub fn is_converged(&self) -> bool
Trait Implementations§
Source§impl Clone for GossipProtocol
impl Clone for GossipProtocol
Source§fn clone(&self) -> GossipProtocol
fn clone(&self) -> GossipProtocol
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GossipProtocol
impl RefUnwindSafe for GossipProtocol
impl Send for GossipProtocol
impl Sync for GossipProtocol
impl Unpin for GossipProtocol
impl UnsafeUnpin for GossipProtocol
impl UnwindSafe for GossipProtocol
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
Mutably borrows from an owned value. Read more