Struct sn_client::client::SafeTransferActor [−][src]
pub struct SafeTransferActor<S> where
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<S> Actor<S> where
S: Signing,
[src]
impl<S> Actor<S> where
S: Signing,
[src]Actual Transfer Actor
pub fn new(signing: S, replicas: SectionElders) -> Actor<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),
pub fn from_info(signing: S, info: WalletHistory) -> Result<Actor<S>, Error>
[src]
pub fn from_snapshot(
wallet: Wallet,
signing: S,
replicas: SectionElders
) -> Actor<S>
[src]
wallet: Wallet,
signing: S,
replicas: SectionElders
) -> Actor<S>
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(&self) -> SectionElders
[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]
&self,
amount: Token,
recipient: PublicKey,
msg: String
) -> Result<Option<TransferInitiated>, Error>
pub fn receive(
&self,
validation: TransferValidated
) -> Result<Option<TransferValidationReceived>, Error>
[src]
&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>
[src]
&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.)
pub fn synch(
&self,
balance: Token,
debit_version: u64,
credit_ids: HashSet<[u8; 32], RandomState>
) -> Result<Option<StateSynched>, Error>
[src]
&self,
balance: Token,
debit_version: u64,
credit_ids: HashSet<[u8; 32], RandomState>
) -> Result<Option<StateSynched>, Error>
pub fn from_history(
&self,
history: ActorHistory
) -> Result<Option<TransfersSynched>, Error>
[src]
&self,
history: ActorHistory
) -> Result<Option<TransfersSynched>, Error>
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.)
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
Auto Trait Implementations
impl<S> RefUnwindSafe for Actor<S> where
S: RefUnwindSafe,
impl<S> RefUnwindSafe for Actor<S> where
S: RefUnwindSafe,
impl<S> UnwindSafe for Actor<S> where
S: UnwindSafe,
impl<S> UnwindSafe for Actor<S> where
S: UnwindSafe,
Blanket Implementations
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,