diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index 8e3350c83..a022953de 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -279,6 +279,10 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const fork_cache.serialize (fork_cache_l); toml.put_child ("fork_cache", fork_cache_l); + nano::tomlconfig vote_rebroadcaster_l; + vote_rebroadcaster.serialize (vote_rebroadcaster_l); + toml.put_child ("vote_rebroadcaster", vote_rebroadcaster_l); + return toml.get_error (); } @@ -442,6 +446,12 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml) fork_cache.deserialize (config_l); } + if (toml.has_key ("vote_rebroadcaster")) + { + auto config_l = toml.get_required_child ("vote_rebroadcaster"); + vote_rebroadcaster.deserialize (config_l); + } + /* * Values */ diff --git a/nano/node/vote_rebroadcaster.cpp b/nano/node/vote_rebroadcaster.cpp index 60c241b1b..79f103368 100644 --- a/nano/node/vote_rebroadcaster.cpp +++ b/nano/node/vote_rebroadcaster.cpp @@ -456,4 +456,32 @@ size_t nano::vote_rebroadcaster_index::total_hashes () const return std::accumulate (index.begin (), index.end (), size_t{ 0 }, [] (auto total, auto const & entry) { return total + entry.hashes.size (); }); +} + +/* + * vote_rebroadcaster_config + */ + +nano::error nano::vote_rebroadcaster_config::deserialize (nano::tomlconfig & toml) +{ + toml.get ("enable", enable); + toml.get ("max_queue", max_queue); + toml.get ("max_history", max_history); + toml.get ("max_representatives", max_representatives); + toml.get_duration ("rebroadcast_threshold", rebroadcast_threshold); + toml.get ("priority_coefficient", priority_coefficient); + + return toml.get_error (); +} + +nano::error nano::vote_rebroadcaster_config::serialize (nano::tomlconfig & toml) const +{ + toml.put ("enable", enable, "Enable or disable vote rebroadcasting. Disabling it will reduce bandwidth usage but should be done with understanding that the node will not participate fully in network consensus.\ntype:bool"); + toml.put ("max_queue", max_queue, "Maximum number of votes to keep in queue for processing.\ntype:uint64"); + toml.put ("max_history", max_history, "Maximum number of recently broadcast hashes to keep per representative.\ntype:uint64"); + toml.put ("max_representatives", max_representatives, "Maximum number of representatives to track rebroadcasts for.\ntype:uint64"); + toml.put ("rebroadcast_threshold", rebroadcast_threshold.count (), "Minimum amount of time between rebroadcasts for the same hash from the same representative.\ntype:milliseconds"); + toml.put ("priority_coefficient", priority_coefficient, "Priority coefficient for prioritizing votes from representative tiers.\ntype:uint64"); + + return toml.get_error (); } \ No newline at end of file diff --git a/nano/node/vote_rebroadcaster.hpp b/nano/node/vote_rebroadcaster.hpp index 548093af1..61b512eef 100644 --- a/nano/node/vote_rebroadcaster.hpp +++ b/nano/node/vote_rebroadcaster.hpp @@ -28,7 +28,8 @@ namespace nano class vote_rebroadcaster_config final { public: - // TODO: Serde + nano::error deserialize (nano::tomlconfig &); + nano::error serialize (nano::tomlconfig &) const; public: bool enable{ true };