Implement vote rebroadcaster config serde (#4886)
This commit is contained in:
parent
c0b39ec44f
commit
3894dbc289
3 changed files with 40 additions and 1 deletions
|
|
@ -279,6 +279,10 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const
|
||||||
fork_cache.serialize (fork_cache_l);
|
fork_cache.serialize (fork_cache_l);
|
||||||
toml.put_child ("fork_cache", 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 ();
|
return toml.get_error ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,6 +446,12 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
|
||||||
fork_cache.deserialize (config_l);
|
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
|
* Values
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -457,3 +457,31 @@ size_t nano::vote_rebroadcaster_index::total_hashes () const
|
||||||
return total + entry.hashes.size ();
|
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 ();
|
||||||
|
}
|
||||||
|
|
@ -28,7 +28,8 @@ namespace nano
|
||||||
class vote_rebroadcaster_config final
|
class vote_rebroadcaster_config final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: Serde
|
nano::error deserialize (nano::tomlconfig &);
|
||||||
|
nano::error serialize (nano::tomlconfig &) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool enable{ true };
|
bool enable{ true };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue