Rename to bandwidth_limiter

This commit is contained in:
Piotr Wójcik 2024-09-09 20:48:23 +02:00
commit 7eb72ccd46
4 changed files with 12 additions and 12 deletions

View file

@ -2,17 +2,17 @@
#include <nano/node/bandwidth_limiter.hpp> #include <nano/node/bandwidth_limiter.hpp>
/* /*
* outbound_bandwidth_limiter * bandwidth_limiter
*/ */
nano::outbound_bandwidth_limiter::outbound_bandwidth_limiter (nano::outbound_bandwidth_limiter::config config_a) : nano::bandwidth_limiter::bandwidth_limiter (nano::bandwidth_limiter::config config_a) :
config_m{ config_a }, config_m{ config_a },
limiter_standard (config_m.standard_limit, config_m.standard_burst_ratio), limiter_standard (config_m.standard_limit, config_m.standard_burst_ratio),
limiter_bootstrap{ config_m.bootstrap_limit, config_m.bootstrap_burst_ratio } limiter_bootstrap{ config_m.bootstrap_limit, config_m.bootstrap_burst_ratio }
{ {
} }
nano::rate_limiter & nano::outbound_bandwidth_limiter::select_limiter (nano::bandwidth_limit_type type) nano::rate_limiter & nano::bandwidth_limiter::select_limiter (nano::bandwidth_limit_type type)
{ {
switch (type) switch (type)
{ {
@ -27,13 +27,13 @@ nano::rate_limiter & nano::outbound_bandwidth_limiter::select_limiter (nano::ban
return limiter_standard; return limiter_standard;
} }
bool nano::outbound_bandwidth_limiter::should_pass (std::size_t buffer_size, nano::bandwidth_limit_type type) bool nano::bandwidth_limiter::should_pass (std::size_t buffer_size, nano::bandwidth_limit_type type)
{ {
auto & limiter = select_limiter (type); auto & limiter = select_limiter (type);
return limiter.should_pass (buffer_size); return limiter.should_pass (buffer_size);
} }
void nano::outbound_bandwidth_limiter::reset (std::size_t limit, double burst_ratio, nano::bandwidth_limit_type type) void nano::bandwidth_limiter::reset (std::size_t limit, double burst_ratio, nano::bandwidth_limit_type type)
{ {
auto & limiter = select_limiter (type); auto & limiter = select_limiter (type);
limiter.reset (limit, burst_ratio); limiter.reset (limit, burst_ratio);

View file

@ -21,7 +21,7 @@ nano::bandwidth_limit_type to_bandwidth_limit_type (nano::transport::traffic_typ
/** /**
* Class that tracks and manages bandwidth limits for IO operations * Class that tracks and manages bandwidth limits for IO operations
*/ */
class outbound_bandwidth_limiter final class bandwidth_limiter final
{ {
public: // Config public: // Config
struct config struct config
@ -35,7 +35,7 @@ public: // Config
}; };
public: public:
explicit outbound_bandwidth_limiter (config); explicit bandwidth_limiter (config);
/** /**
* Check whether packet falls withing bandwidth limits and should be allowed * Check whether packet falls withing bandwidth limits and should be allowed

View file

@ -58,9 +58,9 @@ extern std::size_t nano_bootstrap_weights_beta_size;
* configs * configs
*/ */
nano::outbound_bandwidth_limiter::config nano::outbound_bandwidth_limiter_config (const nano::node_config & config) nano::bandwidth_limiter::config nano::bandwidth_limiter_config (const nano::node_config & config)
{ {
outbound_bandwidth_limiter::config cfg{}; bandwidth_limiter::config cfg{};
cfg.standard_limit = config.bandwidth_limit; cfg.standard_limit = config.bandwidth_limit;
cfg.standard_burst_ratio = config.bandwidth_limit_burst_ratio; cfg.standard_burst_ratio = config.bandwidth_limit_burst_ratio;
cfg.bootstrap_limit = config.bootstrap_bandwidth_limit; cfg.bootstrap_limit = config.bootstrap_bandwidth_limit;
@ -159,7 +159,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
wallets_store (*wallets_store_impl), wallets_store (*wallets_store_impl),
ledger_impl{ std::make_unique<nano::ledger> (store, stats, network_params.ledger, flags_a.generate_cache, config_a.representative_vote_weight_minimum.number ()) }, ledger_impl{ std::make_unique<nano::ledger> (store, stats, network_params.ledger, flags_a.generate_cache, config_a.representative_vote_weight_minimum.number ()) },
ledger{ *ledger_impl }, ledger{ *ledger_impl },
outbound_limiter{ outbound_bandwidth_limiter_config (config) }, outbound_limiter{ bandwidth_limiter_config (config) },
message_processor_impl{ std::make_unique<nano::message_processor> (config.message_processor, *this) }, message_processor_impl{ std::make_unique<nano::message_processor> (config.message_processor, *this) },
message_processor{ *message_processor_impl }, message_processor{ *message_processor_impl },
// empty `config.peering_port` means the user made no port choice at all; // empty `config.peering_port` means the user made no port choice at all;

View file

@ -73,7 +73,7 @@ namespace rocksdb
namespace nano namespace nano
{ {
// Configs // Configs
outbound_bandwidth_limiter::config outbound_bandwidth_limiter_config (node_config const &); bandwidth_limiter::config bandwidth_limiter_config (node_config const &);
class node final : public std::enable_shared_from_this<node> class node final : public std::enable_shared_from_this<node>
{ {
@ -169,7 +169,7 @@ public:
nano::wallets_store & wallets_store; nano::wallets_store & wallets_store;
std::unique_ptr<nano::ledger> ledger_impl; std::unique_ptr<nano::ledger> ledger_impl;
nano::ledger & ledger; nano::ledger & ledger;
nano::outbound_bandwidth_limiter outbound_limiter; nano::bandwidth_limiter outbound_limiter;
std::unique_ptr<nano::message_processor> message_processor_impl; std::unique_ptr<nano::message_processor> message_processor_impl;
nano::message_processor & message_processor; nano::message_processor & message_processor;
nano::network network; nano::network network;