[][src]Struct sn_transfers::TransferReplica

pub struct TransferReplica { /* fields omitted */ }

The Replica is the part of an AT2 system that forms validating groups, and signs individual transfers between wallets. Replicas validate requests to debit an wallet, and apply operations that has a valid "debit agreement proof" from the group, i.e. signatures from a quorum of its peers. Replicas don't initiate transfers or drive the algo - only Actors do.

Implementations

impl Replica[src]

pub fn from_history(
    secret_key: SecretKeyShare,
    key_index: usize,
    peer_replicas: PublicKeySet,
    events: Vec<ReplicaEvent>
) -> Result<Replica>
[src]

A new Replica instance from a history of events.

pub fn from_snapshot(
    secret_key: SecretKeyShare,
    key_index: usize,
    peer_replicas: PublicKeySet,
    other_groups: HashSet<PublicKeySet>,
    wallets: HashMap<PublicKey, Wallet>,
    pending_debits: HashMap<PublicKey, u64>
) -> Replica
[src]

A new Replica instance from current state.

pub fn credits_since(
    &self,
    wallet_id: &PublicKey,
    index: usize
) -> Option<Vec<Transfer>>
[src]


---------------------- Queries ----------------------------------

Query for new credits since specified index. NB: This is not guaranteed to give you all unknown to you, since there is no absolute order on the credits! Includes the credit at specified index (which may, or may not, be the same as the one that the Actor has at the same index).

pub fn debits_since(
    &self,
    wallet_id: &PublicKey,
    index: usize
) -> Option<Vec<Transfer>>
[src]

Query for new debits transfers since specified index. Includes the debit at specified index.

pub fn balance(&self, wallet_id: &PublicKey) -> Option<Money>[src]

pub fn replicas_pk_set(&self) -> Option<PublicKeySet>[src]

Get the replica's PK set

pub fn genesis<F: FnOnce() -> Option<PublicKey>>(
    &self,
    debit_proof: &DebitAgreementProof,
    f: F
) -> Result<Option<TransferPropagated>>
[src]


---------------------- Cmds -------------------------------------

This is the one and only infusion of money to the system. Ever. It is carried out by the first node in the network.

pub fn add_known_group(
    &self,
    group: PublicKeySet
) -> Result<Option<KnownGroupAdded>>
[src]

Adds a PK set for a a new group that we learn of.

pub fn test_validate_transfer(
    &self,
    signed_transfer: SignedTransfer
) -> Result<Option<TransferValidated>>
[src]

For now, with test money there is no from wallet.., money is created from thin air.

pub fn validate(
    &self,
    signed_transfer: SignedTransfer
) -> Result<Option<TransferValidated>>
[src]

Step 1. Main business logic validation of a debit.

pub fn register<F: FnOnce() -> bool>(
    &self,
    debit_proof: &DebitAgreementProof,
    f: F
) -> Result<Option<TransferRegistered>>
[src]

Step 2. Validation of agreement, and order at debit source.

pub fn receive_propagated<F: FnOnce() -> Option<PublicKey>>(
    &self,
    debit_proof: &DebitAgreementProof,
    f: F
) -> Result<Option<TransferPropagated>>
[src]

Step 3. Validation of DebitAgreementProof, and credit idempotency at credit destination. (Since this leads to a credit, there is no requirement on order.)

pub fn apply(&mut self, event: ReplicaEvent) -> Result<()>[src]


---------------------- Mutation ---------------------------------

Mutation of state. There is no validation of an event, it (the cmd) is assumed to have been properly validated before the fact is established (event raised), and thus anything that breaks here, is a bug in the validation..

Trait Implementations

impl Clone for Replica[src]

impl Debug for Replica[src]

impl Eq for Replica[src]

impl PartialEq<Replica> for Replica[src]

impl StructuralEq for Replica[src]

impl StructuralPartialEq for Replica[src]

Auto Trait Implementations

impl RefUnwindSafe for Replica

impl Send for Replica

impl Sync for Replica

impl Unpin for Replica

impl UnwindSafe for Replica

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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>,