Skip to content

Commit

Permalink
Add config option for vote hinting limit
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jun 2, 2022
1 parent 405e0e0 commit d5a9fd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nano/core_test/toml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ TEST (toml, daemon_config_deserialize_defaults)
ASSERT_EQ (conf.rpc.child_process.rpc_path, defaults.rpc.child_process.rpc_path);

ASSERT_EQ (conf.node.active_elections_size, defaults.node.active_elections_size);
ASSERT_EQ (conf.node.active_elections_hinted_limit, defaults.node.active_elections_hinted_limit);
ASSERT_EQ (conf.node.allow_local_peers, defaults.node.allow_local_peers);
ASSERT_EQ (conf.node.backup_before_upgrade, defaults.node.backup_before_upgrade);
ASSERT_EQ (conf.node.bandwidth_limit, defaults.node.bandwidth_limit);
Expand Down Expand Up @@ -388,6 +389,7 @@ TEST (toml, daemon_config_deserialize_no_defaults)
ss << R"toml(
[node]
active_elections_size = 999
active_elections_hinted_limit = 999
allow_local_peers = false
backup_before_upgrade = true
bandwidth_limit = 999
Expand Down Expand Up @@ -552,6 +554,7 @@ TEST (toml, daemon_config_deserialize_no_defaults)
ASSERT_NE (conf.rpc.child_process.rpc_path, defaults.rpc.child_process.rpc_path);

ASSERT_NE (conf.node.active_elections_size, defaults.node.active_elections_size);
ASSERT_NE (conf.node.active_elections_hinted_limit, defaults.node.active_elections_hinted_limit);
ASSERT_NE (conf.node.allow_local_peers, defaults.node.allow_local_peers);
ASSERT_NE (conf.node.backup_before_upgrade, defaults.node.backup_before_upgrade);
ASSERT_NE (conf.node.bandwidth_limit, defaults.node.bandwidth_limit);
Expand Down
7 changes: 7 additions & 0 deletions nano/node/nodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const
toml.put ("use_memory_pools", use_memory_pools, "If true, allocate memory from memory pools. Enabling this may improve performance. Memory is never released to the OS.\ntype:bool");
toml.put ("confirmation_history_size", confirmation_history_size, "Maximum confirmation history size. If tracking the rate of block confirmations, the websocket feature is recommended instead.\ntype:uint64");
toml.put ("active_elections_size", active_elections_size, "Number of active elections. Elections beyond this limit have limited survival time.\nWarning: modifying this value may result in a lower confirmation rate.\ntype:uint64,[250..]");
toml.put ("active_elections_hinted_limit", active_elections_hinted_limit, "Limit of active hinted elections. No more hinted elections will be started beyond this limit.\nWarning: modifying this value may result in a lower confirmation rate.\ntype:uint64");
toml.put ("bandwidth_limit", bandwidth_limit, "Outbound traffic limit in bytes/sec after which messages will be dropped.\nNote: changing to unlimited bandwidth (0) is not recommended for limited connections.\ntype:uint64");
toml.put ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio, "Burst ratio for outbound traffic shaping.\ntype:double");
toml.put ("conf_height_processor_batch_min_time", conf_height_processor_batch_min_time.count (), "Minimum write batching time when there are blocks pending confirmation height.\ntype:milliseconds");
Expand Down Expand Up @@ -344,6 +345,7 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
toml.get<bool> ("use_memory_pools", use_memory_pools);
toml.get<std::size_t> ("confirmation_history_size", confirmation_history_size);
toml.get<std::size_t> ("active_elections_size", active_elections_size);
toml.get<std::size_t> ("active_elections_hinted_limit", active_elections_hinted_limit);
toml.get<std::size_t> ("bandwidth_limit", bandwidth_limit);
toml.get<double> ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio);
toml.get<bool> ("backup_before_upgrade", backup_before_upgrade);
Expand Down Expand Up @@ -406,6 +408,10 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
{
toml.get_error ().set ("active_elections_size must be greater than 250");
}
if (active_elections_hinted_limit > active_elections_size)
{
toml.get_error ().set ("active_elections_hinted_limit cannot be greater than active_elections_size");
}
if (bandwidth_limit > std::numeric_limits<std::size_t>::max ())
{
toml.get_error ().set ("bandwidth_limit unbounded = 0, default = 10485760, max = 18446744073709551615");
Expand Down Expand Up @@ -514,6 +520,7 @@ nano::error nano::node_config::serialize_json (nano::jsonconfig & json) const
json.put_child ("diagnostics", diagnostics_l);
json.put ("confirmation_history_size", confirmation_history_size);
json.put ("active_elections_size", active_elections_size);
json.put ("active_elections_hinted_limit", active_elections_hinted_limit);
json.put ("bandwidth_limit", bandwidth_limit);
json.put ("backup_before_upgrade", backup_before_upgrade);
json.put ("work_watcher_period", 5);
Expand Down

0 comments on commit d5a9fd5

Please sign in to comment.