Struct brb::deterministic_brb::DeterministicBRB[][src]

pub struct DeterministicBRB<A: Actor<S>, SA: SigningActor<A, S>, S: Sig, BRBDT: BRBDataType<A>> {
    pub membership: State<A, SA, S>,
    pub pending_proof: HashMap<Msg<A, BRBDT::Op>, BTreeMap<A, S>>,
    pub pending_delivery: HashMap<Msg<A, BRBDT::Op>, (BTreeMap<A, S>, BTreeSet<A>)>,
    pub received: VClock<A>,
    pub delivered: VClock<A>,
    pub history_from_source: BTreeMap<A, Vec<(Msg<A, BRBDT::Op>, BTreeMap<A, S>)>>,
    pub dt: BRBDT,
}

DeterministicBRB – the heart and soul of BRB.

Fields

membership: State<A, SA, S>

The identity of a process

pending_proof: HashMap<Msg<A, BRBDT::Op>, BTreeMap<A, S>>

Msgs this process has initiated and is waiting on BFT agreement for from the network.

pending_delivery: HashMap<Msg<A, BRBDT::Op>, (BTreeMap<A, S>, BTreeSet<A>)>

Msgs this process has sent ProofOfAgreement for but has not yet received a super-majority of delivery confirmations.

received: VClock<A>

The clock representing the most recently received messages from each process. These are messages that have been acknowledged but not yet This clock must at all times be greator or equal to the delivered clock.

delivered: VClock<A>

The clock representing the most recent msgs we’ve delivered to the underlying datatype dt.

history_from_source: BTreeMap<A, Vec<(Msg<A, BRBDT::Op>, BTreeMap<A, S>)>>

History is maintained to onboard new members

dt: BRBDT

The state of the datatype that we are running BFT over. This can be the causal bank described in AT2, or it can be a CRDT.

Implementations

impl<A: Actor<S>, SA: SigningActor<A, S>, S: Sig, BRBDT: BRBDataType<A>> DeterministicBRB<A, SA, S, BRBDT>[src]

pub fn new() -> Self[src]

returns a new DeterministicBRB

pub fn actor(&self) -> A[src]

returns the Actor

pub fn peers(&self) -> Result<BTreeSet<A>, Error<A, S, BRBDT::ValidationError>>[src]

returns a set of known peers

pub fn force_join(&mut self, peer: A)[src]

Locally adds a peer to voting group without going through the regular brb_membership join + voting process.

pub fn force_leave(&mut self, peer: A)[src]

Locally removes a peer from voting group without going through the regular brb_membership leave + voting process.

pub fn request_membership(
    &mut self,
    actor: A
) -> Result<Vec<Packet<A, S, BRBDT::Op>>, Error<A, S, BRBDT::ValidationError>>
[src]

Proposes membership for an Actor.

The node proposing membership must already be a voting member and thus typically will be proposing to add a different non-voting actor.

In other words, a node may not directly propose to add itself, but instead must have a sponsor.

pub fn kill_peer(
    &mut self,
    actor: A
) -> Result<Vec<Packet<A, S, BRBDT::Op>>, Error<A, S, BRBDT::ValidationError>>
[src]

Proposes that a member be removed from the voting group.

The node proposing membership must already be a voting member and may propose that self or another member be removed.

See https://github.com/maidsafe/brb/issues/18

pub fn anti_entropy(
    &self,
    peer: A
) -> Result<Packet<A, S, BRBDT::Op>, Error<A, S, BRBDT::ValidationError>>
[src]

Sends an AntiEntropy packet to the given peer, indicating the last generation we have seen.

The remote peer should respond with history since our last-seen generation to bring our peer up-to-date.

If we have not seen any generation, then this becomes a means to bootstrap our node from the “genesis” generation.

pub fn resend_pending_deliveries(
    &self
) -> Result<Vec<Packet<A, S, BRBDT::Op>>, Error<A, S, BRBDT::ValidationError>>
[src]

Resend any proof of agreements that we have not yet received delivery confirmation for.

pub fn exec_op(
    &self,
    op: BRBDT::Op
) -> Result<Vec<Packet<A, S, BRBDT::Op>>, Error<A, S, BRBDT::ValidationError>>
[src]

Initiates an operation for the BRBDataType being secured by BRB.

NOTE: Network members will refuse to sign multiple operations from a source concurrently. It’s recommended to ensure there aren’t any pending deliveries before you initiate a new operation to reduce the chance of this happening. A naive implementation of this would be:

let mut packets_to_resend = brb.resend_pending_deliveries()?;

while !packets_to_resend.is_empty() {
   // ... re-send these packets
   network.send_packets(packets_to_resend);
   sleep(TIMEOUT_SECONDS);
   packets_to_resend = brb.resend_pending_deliveries()?;
}

brb.exec_op(op)?;

pub fn handle_packet(
    &mut self,
    packet: Packet<A, S, BRBDT::Op>
) -> Result<Vec<Packet<A, S, BRBDT::Op>>, Error<A, S, BRBDT::ValidationError>>
[src]

handles an incoming BRB Packet.

Trait Implementations

impl<A: Debug + Actor<S>, SA: Debug + SigningActor<A, S>, S: Debug + Sig, BRBDT: Debug + BRBDataType<A>> Debug for DeterministicBRB<A, SA, S, BRBDT> where
    BRBDT::Op: Debug,
    BRBDT::Op: Debug,
    BRBDT::Op: Debug
[src]

impl<A: Actor<S>, SA: SigningActor<A, S>, S: Sig, BRBDT: BRBDataType<A>> Default for DeterministicBRB<A, SA, S, BRBDT>[src]

fn default() -> Self[src]

returns a default DeterministicBRB

Auto Trait Implementations

impl<A, SA, S, BRBDT> RefUnwindSafe for DeterministicBRB<A, SA, S, BRBDT> where
    A: RefUnwindSafe,
    BRBDT: RefUnwindSafe,
    S: RefUnwindSafe,
    SA: RefUnwindSafe,
    <BRBDT as BRBDataType<A>>::Op: RefUnwindSafe

impl<A, SA, S, BRBDT> Send for DeterministicBRB<A, SA, S, BRBDT> where
    A: Send,
    BRBDT: Send,
    S: Send,
    SA: Send,
    <BRBDT as BRBDataType<A>>::Op: Send

impl<A, SA, S, BRBDT> Sync for DeterministicBRB<A, SA, S, BRBDT> where
    A: Sync,
    BRBDT: Sync,
    S: Sync,
    SA: Sync,
    <BRBDT as BRBDataType<A>>::Op: Sync

impl<A, SA, S, BRBDT> Unpin for DeterministicBRB<A, SA, S, BRBDT> where
    A: Unpin,
    BRBDT: Unpin,
    SA: Unpin,
    <BRBDT as BRBDataType<A>>::Op: Unpin

impl<A, SA, S, BRBDT> UnwindSafe for DeterministicBRB<A, SA, S, BRBDT> where
    A: RefUnwindSafe + UnwindSafe,
    BRBDT: UnwindSafe,
    S: RefUnwindSafe,
    SA: UnwindSafe,
    <BRBDT as BRBDataType<A>>::Op: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,