Struct sn_transfers::TransferActor [−][src]
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: Signing> Actor<S>
[src]
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<CreditId>
) -> Result<Option<StateSynched>, Error>
[src]
&self,
balance: Token,
debit_version: u64,
credit_ids: HashSet<CreditId>
) -> 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,
S: RefUnwindSafe,
impl<S> Send for Actor<S> where
S: Send,
S: Send,
impl<S> Sync for Actor<S> where
S: Sync,
S: Sync,
impl<S> Unpin for Actor<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for Actor<S> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,