Rename to rate_limiter
This commit is contained in:
parent
96f8a30846
commit
07637c8953
4 changed files with 12 additions and 12 deletions
|
|
@ -2,20 +2,20 @@
|
|||
#include <nano/node/bandwidth_limiter.hpp>
|
||||
|
||||
/*
|
||||
* bandwidth_limiter
|
||||
* rate_limiter
|
||||
*/
|
||||
|
||||
nano::bandwidth_limiter::bandwidth_limiter (std::size_t limit_a, double burst_ratio_a) :
|
||||
nano::rate_limiter::rate_limiter (std::size_t limit_a, double burst_ratio_a) :
|
||||
bucket (static_cast<std::size_t> (limit_a * burst_ratio_a), limit_a)
|
||||
{
|
||||
}
|
||||
|
||||
bool nano::bandwidth_limiter::should_pass (std::size_t message_size_a)
|
||||
bool nano::rate_limiter::should_pass (std::size_t message_size_a)
|
||||
{
|
||||
return bucket.try_consume (nano::narrow_cast<unsigned int> (message_size_a));
|
||||
}
|
||||
|
||||
void nano::bandwidth_limiter::reset (std::size_t limit_a, double burst_ratio_a)
|
||||
void nano::rate_limiter::reset (std::size_t limit_a, double burst_ratio_a)
|
||||
{
|
||||
bucket.reset (static_cast<std::size_t> (limit_a * burst_ratio_a), limit_a);
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ nano::outbound_bandwidth_limiter::outbound_bandwidth_limiter (nano::outbound_ban
|
|||
{
|
||||
}
|
||||
|
||||
nano::bandwidth_limiter & nano::outbound_bandwidth_limiter::select_limiter (nano::bandwidth_limit_type type)
|
||||
nano::rate_limiter & nano::outbound_bandwidth_limiter::select_limiter (nano::bandwidth_limit_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ nano::bandwidth_limit_type to_bandwidth_limit_type (nano::transport::traffic_typ
|
|||
/**
|
||||
* Class that tracks and manages bandwidth limits for IO operations
|
||||
*/
|
||||
class bandwidth_limiter final
|
||||
class rate_limiter final
|
||||
{
|
||||
public:
|
||||
// initialize with limit 0 = unbounded
|
||||
bandwidth_limiter (std::size_t limit, double burst_ratio);
|
||||
rate_limiter (std::size_t limit, double burst_ratio);
|
||||
|
||||
bool should_pass (std::size_t buffer_size);
|
||||
void reset (std::size_t limit, double burst_ratio);
|
||||
|
|
@ -64,13 +64,13 @@ private:
|
|||
/**
|
||||
* Returns reference to limiter corresponding to the limit type
|
||||
*/
|
||||
bandwidth_limiter & select_limiter (bandwidth_limit_type);
|
||||
nano::rate_limiter & select_limiter (bandwidth_limit_type);
|
||||
|
||||
private:
|
||||
const config config_m;
|
||||
|
||||
private:
|
||||
bandwidth_limiter limiter_standard;
|
||||
bandwidth_limiter limiter_bootstrap;
|
||||
nano::rate_limiter limiter_standard;
|
||||
nano::rate_limiter limiter_bootstrap;
|
||||
};
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ namespace bootstrap_ascending
|
|||
|
||||
// Requests for accounts from database have much lower hitrate and could introduce strain on the network
|
||||
// A separate (lower) limiter ensures that we always reserve resources for querying accounts from priority queue
|
||||
nano::bandwidth_limiter database_limiter;
|
||||
nano::rate_limiter database_limiter;
|
||||
|
||||
nano::interval sync_dependencies_interval;
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ private:
|
|||
|
||||
private:
|
||||
bool enabled{ false };
|
||||
nano::bandwidth_limiter limiter;
|
||||
nano::rate_limiter limiter;
|
||||
nano::interval cleanup_interval;
|
||||
|
||||
std::atomic<bool> stopped{ false };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue