pub struct RateCounter { /* private fields */ }
Expand description

A rate counter tracks the number of transfers, the amount of data exchanged and the rate of transfer (via a few timers) over the last minute. The counter does not try to be accurate and update times proactively, instead it only does so lazily. As a result, produced rates are worst-case estimates.

Implementations

Instantiate a new rate counter

Increments number of bytes transferred, updating counts and rates.

Increments number of bytes without updating the count or rate. We filter out 0 last_min_times when calculating rate. Used during txhashset.zip download to track bytes downloaded without treating a peer as abusive (too high a rate of download).

Number of bytes counted in the last minute. Includes “quiet” byte increments.

Count of increases in the last minute. Excludes “quiet” byte increments.

Elapsed time in ms since the last entry. We use this to rate limit when sending.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.