Struct vapcore_light::net::request_credits::FlowParams[][src]

pub struct FlowParams { /* fields omitted */ }

Handles costs, recharge, limits of request credits.

Implementations

impl FlowParams[src]

pub fn new(limit: U256, costs: CostTable, recharge: U256) -> Self[src]

Create new flow parameters from a request cost table, credit limit, and (minimum) rate of recharge.

pub fn from_request_times<F: Fn(Kind) -> Duration>(
    request_time: F,
    load_share: f64,
    max_stored: Duration
) -> Self
[src]

Create new flow parameters from , proportion of total capacity which should be given to a peer, and stored capacity a peer can accumulate.

pub fn free() -> Self[src]

Create effectively infinite flow params.

pub fn limit(&self) -> &U256[src]

Get a reference to the credit limit.

pub fn cost_table(&self) -> &CostTable[src]

Get a reference to the cost table.

pub fn base_cost(&self) -> U256[src]

Get the base cost of a request.

pub fn recharge_rate(&self) -> &U256[src]

Get a reference to the recharge rate.

pub fn compute_cost(&self, request: &Request) -> Option<U256>[src]

Compute the actual cost of a request, given the kind of request and number of requests made.

pub fn compute_cost_multi(&self, requests: &[Request]) -> Option<U256>[src]

Compute the cost of a set of requests. This is the base cost plus the cost of each individual request.

pub fn create_credits(&self) -> Credits[src]

Create initial credits.

pub fn recharge(&self, credits: &mut Credits)[src]

Recharge the given credits based on time passed since last update.

pub fn refund(&self, credits: &mut Credits, refund_amount: U256)[src]

Refund some credits which were previously deducted. Does not update the recharge timestamp.

Trait Implementations

impl Clone for FlowParams[src]

impl Debug for FlowParams[src]

impl Default for FlowParams[src]

impl PartialEq<FlowParams> for FlowParams[src]

impl StructuralPartialEq for FlowParams[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeDebug for T where
    T: Debug
[src]

impl<T> MaybeDebug for T where
    T: Debug
[src]

impl<T> MaybeDebug for T where
    T: Debug
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,