[−][src]Struct sn_transfers::TransferActor
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> Actor<V>
[src]
pub fn new(
keypair: Arc<Keypair>,
replicas: PublicKeySet,
replica_validator: V
) -> Actor<V>
[src]
keypair: Arc<Keypair>,
replicas: PublicKeySet,
replica_validator: V
) -> Actor<V>
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_snapshot(
wallet: Wallet,
keypair: Arc<Keypair>,
replicas: PublicKeySet,
replica_validator: V
) -> Actor<V>
[src]
wallet: Wallet,
keypair: Arc<Keypair>,
replicas: PublicKeySet,
replica_validator: V
) -> Actor<V>
Temp, for test purposes
pub fn id(&self) -> PublicKey
[src]
pub fn credits_since(&self, index: usize) -> Vec<Transfer>
[src]
Query for new credits since specified index.
pub fn debits_since(&self, index: usize) -> Vec<Transfer>
[src]
Query for new debits since specified index.
pub fn balance(&self) -> Money
[src]
Query for the balance of the Actor.
pub fn transfer(
&self,
amount: Money,
to: PublicKey
) -> Result<Option<TransferInitiated>>
[src]
&self,
amount: Money,
to: PublicKey
) -> Result<Option<TransferInitiated>>
---------------------- Cmds -------------------------------------
Step 1. Build a valid cmd for validation of a debit.
pub fn receive(
&self,
validation: TransferValidated
) -> Result<Option<TransferValidationReceived>>
[src]
&self,
validation: TransferValidated
) -> Result<Option<TransferValidationReceived>>
Step 2. Receive validations from Replicas, aggregate the signatures.
pub fn register(
&self,
debit_proof: DebitAgreementProof
) -> Result<Option<TransferRegistrationSent>>
[src]
&self,
debit_proof: DebitAgreementProof
) -> Result<Option<TransferRegistrationSent>>
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,
events: Vec<ReplicaEvent>
) -> Result<Option<TransfersSynched>>
[src]
&self,
events: Vec<ReplicaEvent>
) -> Result<Option<TransfersSynched>>
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.
pub fn apply(&mut self, event: ActorEvent) -> Result<()>
[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> Clone for Actor<V>
[src]
impl<V: Debug + ReplicaValidator> Debug for Actor<V>
[src]
impl<V: Eq + ReplicaValidator> Eq for Actor<V>
[src]
impl<V: PartialEq + ReplicaValidator> PartialEq<Actor<V>> for Actor<V>
[src]
impl<V: ReplicaValidator> StructuralEq for Actor<V>
[src]
impl<V: ReplicaValidator> StructuralPartialEq for Actor<V>
[src]
Auto Trait Implementations
impl<V> RefUnwindSafe for Actor<V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<V> Send for Actor<V> where
V: Send,
V: Send,
impl<V> Sync for Actor<V> where
V: Sync,
V: Sync,
impl<V> Unpin for Actor<V> where
V: Unpin,
V: Unpin,
impl<V> UnwindSafe for Actor<V> where
V: UnwindSafe,
V: 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>,