MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / add

Method add

ipld/resolver/src/limiter.rs:32–34  ·  view source on GitHub ↗

Try to add a certain amount of resources consumed to a key. Return `true` if the key was within limits, `false` if it needs to wait. The [`RateLimit`] is passed in so that we can update it dynamically based on how much data we anticipate we will have to serve.

(&mut self, limit: &RateLimit, key: K, cost: u32)

Source from the content-addressed store, hash-verified

30 /// The [`RateLimit`] is passed in so that we can update it dynamically
31 /// based on how much data we anticipate we will have to serve.
32 pub fn add(&mut self, limit: &RateLimit, key: K, cost: u32) -> bool {
33 self.add_at(limit, key, cost, Instant::now())
34 }
35
36 /// Same as [`RateLimiter::add`] but allows passing in the time, for testing.
37 pub fn add_at(&mut self, limit: &RateLimit, key: K, cost: u32, at: Instant) -> bool {

Callers 2

check_rate_limitMethod · 0.45
rate_limit_usedMethod · 0.45

Calls 1

add_atMethod · 0.80

Tested by

no test coverage detected