[][src]Trait interledger::service::IncomingService

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

Core service trait for handling IncomingRequests that asynchronously returns an ILP Fulfill or Reject packet.

Associated Types

type Future: 'static + Send + Future

Loading content...

Required methods

fn handle_request(&mut self, request: IncomingRequest<A>) -> Self::Future

Loading content...

Provided methods

fn wrap<F, R>(self, f: F) -> WrappedService<F, Self, A> where
    F: Fn(IncomingRequest<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> IncomingService<A> for Instrumented<IO> where
    A: Account,
    IO: IncomingService<A> + Clone
[src]

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

Loading content...

Implementors

impl<F, A, B> IncomingService<A> for ServiceFn<F, A> where
    A: Account,
    B: IntoFuture<Item = Fulfill, Error = Reject>,
    F: FnMut(IncomingRequest<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> IncomingService<A> for WrappedService<F, IO, A> where
    A: Account,
    F: Fn(IncomingRequest<A>, IO) -> R,
    IO: IncomingService<A> + Clone,
    R: Future<Item = Fulfill, Error = Reject> + Send + 'static, 
[src]

type Future = R

impl<I, A> IncomingService<A> for IldcpService<I, A> where
    A: Account,
    I: IncomingService<A>, 
[src]

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

impl<I, A> IncomingService<A> for SettlementMessageService<I, A> where
    A: SettlementAccount + Account,
    I: IncomingService<A> + Send
[src]

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

impl<I, O, S, A> IncomingService<A> for CcpRouteManager<I, O, S, A> where
    A: CcpRoutingAccount + Send + Sync + 'static,
    I: IncomingService<A> + Clone + Send + Sync + 'static,
    O: OutgoingService<A> + Clone + Send + Sync + 'static,
    S: AddressStore + RouteManagerStore<Account = A> + Clone + Send + Sync + 'static, 
[src]

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

fn handle_request(
    &mut self,
    request: IncomingRequest<A>
) -> <CcpRouteManager<I, O, S, A> as IncomingService<A>>::Future
[src]

Handle the IncomingRequest if it is a CCP protocol message or pass it on to the next handler if not

impl<I, S, A> IncomingService<A> for EchoService<I, S, A> where
    A: Account,
    I: IncomingService<A>,
    S: AddressStore
[src]

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

impl<I, S, A> IncomingService<A> for MaxPacketAmountService<I, S> where
    A: MaxPacketAmountAccount,
    I: IncomingService<A>,
    S: AddressStore
[src]

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

fn handle_request(
    &mut self,
    request: IncomingRequest<A>
) -> <MaxPacketAmountService<I, S> as IncomingService<A>>::Future
[src]

On receive request:

  1. if request.prepare.amount <= request.from.max_packet_amount forward the request, else error

impl<I, S, A> IncomingService<A> for ValidatorService<I, S, A> where
    A: Account,
    I: IncomingService<A>,
    S: AddressStore
[src]

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

fn handle_request(
    &mut self,
    request: IncomingRequest<A>
) -> <ValidatorService<I, S, A> as IncomingService<A>>::Future
[src]

On receiving a request:

  1. If the prepare packet in the request is not expired, forward it, otherwise return a reject

impl<S, I, A> IncomingService<A> for RateLimitService<S, I, A> where
    A: RateLimitAccount + Sync + 'static,
    I: IncomingService<A> + Clone + Send + Sync + 'static,
    S: AddressStore + RateLimitStore<Account = A> + Clone + Send + Sync + 'static, 
[src]

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

fn handle_request(
    &mut self,
    request: IncomingRequest<A>
) -> <RateLimitService<S, I, A> as IncomingService<A>>::Future
[src]

On receiving a request:

  1. Apply rate limit based on the sender of the request and the amount in the prepare packet in the request
  2. If no limits were hit forward the request
    • If it succeeds, OK
    • If the request forwarding failed, the client should not be charged towards their throughput limit, so they are refunded, and return a reject
  3. If the limit was hit, return a reject with the appropriate ErrorCode.

impl<S, O> IncomingService<<S as AccountStore>::Account> for Router<S, O> where
    O: OutgoingService<<S as AccountStore>::Account> + Clone + Send + 'static,
    S: AddressStore + RouterStore
[src]

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

fn handle_request(
    &mut self,
    request: IncomingRequest<<S as AccountStore>::Account>
) -> <Router<S, O> as IncomingService<<S as AccountStore>::Account>>::Future
[src]

Figures out the next node to pass the received Prepare packet to.

Firstly, it checks if there is a direct path for that account and uses that. If not it scans through the routing table and checks if the route prefix matches the prepare packet's destination or if it's a catch-all address (i.e. empty prefix)

Loading content...