Struct safe_network::transfers::TransferActor [−][src]
pub struct TransferActor<S: Signing> { /* fields omitted */ }
Expand description
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
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),
Temp, for test purposes
History of credits and debits
pub fn receive(
&self,
validation: TransferValidated
) -> Result<Option<TransferValidationReceived>, Error>
pub fn receive(
&self,
validation: TransferValidated
) -> Result<Option<TransferValidationReceived>, Error>
Step 2. Receive validations from Replicas, aggregate the signatures.
pub fn register(
&self,
transfer_proof: TransferAgreementProof
) -> Result<Option<TransferRegistrationSent>, Error>
pub fn register(
&self,
transfer_proof: TransferAgreementProof
) -> Result<Option<TransferRegistrationSent>, Error>
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.)
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 validate replicas in upper layers for determining if this remote group of Replicas is indeed valid.
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.)
––––––––––– 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
Auto Trait Implementations
impl<S> RefUnwindSafe for Actor<S> where
S: RefUnwindSafe,
impl<S> UnwindSafe for Actor<S> where
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V