[][src]Trait interledger::service::OutgoingService

pub trait OutgoingService<A> where
    A: Account,
    <Self::Future as Future>::Item == Fulfill,
    <Self::Future as Future>::Error == Reject
{ type Future: 'static + Send + Future; fn send_request(&mut self, request: OutgoingRequest<A>) -> Self::Future; fn wrap<F, R>(self, f: F) -> WrappedService<F, Self, A>
    where
        F: Fn(OutgoingRequest<A>, Self) -> R,
        R: Future<Item = Fulfill, Error = Reject> + Send + 'static,
        Self: Clone
, { ... } }

Core service trait for sending OutgoingRequests that asynchronously returns an ILP Fulfill or Reject packet.

Associated Types

type Future: 'static + Send + Future

Loading content...

Required methods

fn send_request(&mut self, request: OutgoingRequest<A>) -> Self::Future

Loading content...

Provided methods

fn wrap<F, R>(self, f: F) -> WrappedService<F, Self, A> where
    F: Fn(OutgoingRequest<A>, Self) -> R,
    R: Future<Item = Fulfill, Error = Reject> + Send + 'static,
    Self: Clone

Wrap the given service such that the provided function will be called to handle each request. That function can return immediately, modify the request before passing it on, and/or handle the result of calling the inner service.

Loading content...

Implementations on Foreign Types

impl<IO, A> OutgoingService<A> for Instrumented<IO> where
    A: Account,
    IO: OutgoingService<A> + Clone
[src]

type Future = Instrumented<<IO as OutgoingService<A>>::Future>

Loading content...

Implementors

impl<F, A, B> OutgoingService<A> for ServiceFn<F, A> where
    A: Account,
    B: IntoFuture<Item = Fulfill, Error = Reject>,
    F: FnMut(OutgoingRequest<A>) -> B,
    <B as IntoFuture>::Future: Send,
    <B as IntoFuture>::Future: 'static, 
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

impl<F, IO, A, R> OutgoingService<A> for WrappedService<F, IO, A> where
    A: Account,
    F: Fn(OutgoingRequest<A>, IO) -> R,
    IO: OutgoingService<A> + Clone,
    R: Future<Item = Fulfill, Error = Reject> + Send + 'static, 
[src]

type Future = R

impl<I, O, A> OutgoingService<A> for BtpService<I, O, A> where
    A: BtpAccount + 'static,
    O: OutgoingService<A> + Clone + Send + 'static, 
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> <BtpService<I, O, A> as OutgoingService<A>>::Future
[src]

Send an outgoing request to one of the open connections.

If there is no open connection for the Account specified in request.to, the request will be passed through to the next handler.

impl<O, A> OutgoingService<A> for BtpOutgoingService<O, A> where
    A: BtpAccount + 'static,
    O: OutgoingService<A> + Clone
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> <BtpOutgoingService<O, A> as OutgoingService<A>>::Future
[src]

Send an outgoing request to one of the open connections.

If there is no open connection for the Account specified in request.to, the request will be passed through to the next handler.

impl<O, A> OutgoingService<A> for ExpiryShortenerService<O> where
    A: RoundTripTimeAccount,
    O: OutgoingService<A>, 
[src]

type Future = <O as OutgoingService<A>>::Future

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> <ExpiryShortenerService<O> as OutgoingService<A>>::Future
[src]

On send request:

  1. Get the sender and receiver's roundtrip time (default 1000ms)
  2. Reduce the packet's expiry by that amount
  3. Ensure that the packet expiry does not exceed the maximum expiry duration
  4. Forward the request

impl<O, S, A> OutgoingService<A> for ValidatorService<O, S, A> where
    A: Account,
    O: OutgoingService<A>,
    S: AddressStore
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> <ValidatorService<O, S, A> as OutgoingService<A>>::Future
[src]

On sending a request:

  1. If the outgoing packet has expired, return a reject with the appropriate ErrorCode
  2. Tries to forward the request
    • If no response is received before the prepare packet's expiration, it assumes that the outgoing request has timed out.
    • If no timeout occurred, but still errored it will just return the reject
    • If the forwarding is successful, it should receive a fulfill packet. Depending on if the hash of the fulfillment condition inside the fulfill is a preimage of the condition of the prepare:
      • return the fulfill if it matches
      • otherwise reject

impl<S, O, A> OutgoingService<A> for HttpClientService<S, O, A> where
    A: HttpAccount,
    O: OutgoingService<A>,
    S: AddressStore + HttpStore
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> <HttpClientService<S, O, A> as OutgoingService<A>>::Future
[src]

Send an OutgoingRequest to a peer that implements the ILP-Over-HTTP.

impl<S, O, A> OutgoingService<A> for BalanceService<S, O, A> where
    A: SettlementAccount + 'static,
    O: OutgoingService<A> + Send + Clone + 'static,
    S: AddressStore + BalanceStore<Account = A> + SettlementStore<Account = A> + Clone + Send + Sync + 'static, 
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>
[src]

On send message:

  1. Calls store.update_balances_for_prepare with the prepare. If it fails, it replies with a reject
  2. Tries to forward the request:
    • If it returns a fullfil, calls store.update_balances_for_fulfill and replies with the fulfill INDEPENDENTLY of if the call suceeds or fails. This makes a sendMoney call if the fulfill puts the account's balance over the settle_threshold
    • if it returns an reject calls store.update_balances_for_reject and replies with the fulfill INDEPENDENTLY of if the call suceeds or fails

impl<S, O, A> OutgoingService<A> for ExchangeRateService<S, O, A> where
    A: Account + Sync + 'static,
    O: OutgoingService<A> + Send + Clone + 'static,
    S: AddressStore + ExchangeRateStore + Clone + Send + Sync + 'static, 
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>
[src]

On send request:

  1. If the prepare packet's amount is 0, it just forwards
  2. Retrieves the exchange rate from the store (the store independently is responsible for polling the rates)
    • return reject if the call to the store fails
  3. Calculates the exchange rate AND scales it up/down depending on how many decimals each asset requires
  4. Updates the amount in the prepare packet and forwards it

impl<S, O, A> OutgoingService<A> for StreamReceiverService<S, O, A> where
    A: Account,
    O: OutgoingService<A>,
    S: StreamNotificationsStore + Send + Sync + 'static + Clone
[src]

type Future = Box<dyn Future<Error = Reject, Item = Fulfill> + 'static + Send>

fn send_request(
    &mut self,
    request: OutgoingRequest<A>
) -> <StreamReceiverService<S, O, A> as OutgoingService<A>>::Future
[src]

Try fulfilling the request if it is for this STREAM server or pass it to the next outgoing handler if not.

Loading content...