Struct sn_transfers::TransferActor[][src]

pub struct TransferActor<V: ReplicaValidator, S: Signing> { /* fields omitted */ }

The Actor is the part of an AT2 system that initiates transfers, by requesting Replicas to validate them, and then receive the proof of agreement. It also syncs transfers from the Replicas.

Implementations

impl<V: ReplicaValidator, S: Signing> Actor<V, S>[src]

pub fn new(
    signing: S,
    replicas: PublicKeySet,
    replica_validator: V
) -> Actor<V, S>
[src]

Use this ctor for a new instance, or to rehydrate from events (see the synch method). Pass in the key set of the replicas of this actor, i.e. our replicas. Credits to our wallet are most likely debited at other replicas than our own (the sender’s replicas), The replica_validator lets upper layer decide how to validate those remote replicas (i.e. not our replicas). If upper layer trusts them, the validator might do nothing but return “true”. If it wants to execute some logic for verifying that the remote replicas are in fact part of the system, before accepting credits, it then implements that in the replica_validator.

pub fn from_info(
    signing: S,
    info: WalletInfo,
    replica_validator: V
) -> Result<Actor<V, S>, Error>
[src]

pub fn from_snapshot(
    wallet: Wallet,
    signing: S,
    replicas: PublicKeySet,
    replica_validator: V
) -> Actor<V, S>
[src]

Temp, for test purposes

pub fn id(&self) -> PublicKey[src]

pub fn owner(&self) -> &OwnerType[src]

Query for the id of the Actor.

pub fn balance(&self) -> Token[src]

Query for the balance of the Actor.

pub fn replicas_public_key(&self) -> PublicKey[src]

pub fn replicas_key_set(&self) -> PublicKeySet[src]

pub fn history(&self) -> ActorHistory[src]

History of credits and debits

pub fn transfer(
    &self,
    amount: Token,
    recipient: PublicKey,
    msg: String
) -> Result<Option<TransferInitiated>, Error>
[src]


––––––––––– Cmds ———————————––

Step 1. Build a valid cmd for validation of a debit.

pub fn receive(
    &self,
    validation: TransferValidated
) -> Result<Option<TransferValidationReceived>, Error>
[src]

Step 2. Receive validations from Replicas, aggregate the signatures.

pub fn register(
    &self,
    transfer_proof: TransferAgreementProof
) -> Result<Option<TransferRegistrationSent>, Error>
[src]

Step 3. Registration of an agreed transfer. (The actual sending of the registration over the wire is done by upper layer, only after that, the event is applied to the actor instance.)

pub fn synch(
    &self,
    balance: Token,
    debit_version: u64,
    credit_ids: HashSet<CreditId>
) -> Result<Option<StateSynched>, Error>
[src]

pub fn from_history(
    &self,
    history: ActorHistory
) -> Result<Option<TransfersSynched>, Error>
[src]

Step xx. Continuously receiving credits from Replicas via push or pull model, decided by upper layer. The credits are most likely originating at an Actor whose Replicas are not the same as our Replicas. That means that the signature on the DebitAgreementProof, is that of some Replicas we don’t know. What we do here is to use the passed in replica_validator, that injects the logic from upper layers for determining if this remote group of Replicas is indeed valid. It should consider our Replicas valid as well, for the rare cases when sender replicate to the same group.

This also ensures that we receive transfers initiated at other Actor instances (same id or other, i.e. with multiple instances of same Actor we can also sync debits made on other isntances). Todo: This looks to be handling the case when there is a transfer in flight from this client (i.e. self.next_expected_debit has been incremented, but transfer not yet accumulated). Just make sure this is 100% the case as well.

NB: If a non-complete* set of debits has been provided, this Actor instance will still apply any credits, and thus be out of synch with its Replicas, as it will have a balance that is higher than at the Replicas. (*Non-complete means non-contiguous set or not starting immediately after current debit version.)

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


––––––––––– Mutation ———————————

Mutation of state. There is no validation of an event, it is assumed to have been properly validated before raised, and thus anything that breaks is a bug.

Trait Implementations

impl<V: Clone + ReplicaValidator, S: Clone + Signing> Clone for Actor<V, S>[src]

impl<V: ReplicaValidator + Debug, S: Signing + Debug> Debug for Actor<V, S>[src]

Auto Trait Implementations

impl<V, S> RefUnwindSafe for Actor<V, S> where
    S: RefUnwindSafe,
    V: RefUnwindSafe

impl<V, S> Send for Actor<V, S> where
    S: Send,
    V: Send

impl<V, S> Sync for Actor<V, S> where
    S: Sync,
    V: Sync

impl<V, S> Unpin for Actor<V, S> where
    S: Unpin,
    V: Unpin

impl<V, S> UnwindSafe for Actor<V, S> where
    S: UnwindSafe,
    V: 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> 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>,