Config serialization
This commit is contained in:
parent
11675c2e0e
commit
41977106a2
3 changed files with 41 additions and 2 deletions
|
|
@ -246,6 +246,10 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const
|
|||
peer_history.serialize (peer_history_l);
|
||||
toml.put_child ("peer_history", peer_history_l);
|
||||
|
||||
nano::tomlconfig tcp_l;
|
||||
tcp.serialize (tcp_l);
|
||||
toml.put_child ("tcp", tcp_l);
|
||||
|
||||
nano::tomlconfig request_aggregator_l;
|
||||
request_aggregator.serialize (request_aggregator_l);
|
||||
toml.put_child ("request_aggregator", request_aggregator_l);
|
||||
|
|
@ -381,6 +385,12 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
|
|||
peer_history.deserialize (config_l);
|
||||
}
|
||||
|
||||
if (toml.has_key ("tcp"))
|
||||
{
|
||||
auto config_l = toml.get_required_child ("tcp");
|
||||
tcp.deserialize (config_l);
|
||||
}
|
||||
|
||||
if (toml.has_key ("request_aggregator"))
|
||||
{
|
||||
auto config_l = toml.get_required_child ("request_aggregator");
|
||||
|
|
|
|||
|
|
@ -1 +1,29 @@
|
|||
#include <nano/node/transport/tcp_config.hpp>
|
||||
#include <nano/node/transport/tcp_config.hpp>
|
||||
|
||||
nano::error nano::transport::tcp_config::serialize (nano::tomlconfig & toml) const
|
||||
{
|
||||
toml.put ("max_inbound_connections", max_inbound_connections, "Maximum number of incoming TCP connections. \ntype:uint64");
|
||||
toml.put ("max_outbound_connections", max_outbound_connections, "Maximum number of outgoing TCP connections. \ntype:uint64");
|
||||
toml.put ("max_attempts", max_attempts, "Maximum connection attempts. \ntype:uint64");
|
||||
toml.put ("max_attempts_per_ip", max_attempts_per_ip, "Maximum connection attempts per IP. \ntype:uint64");
|
||||
|
||||
toml.put ("connect_timeout", connect_timeout.count (), "Timeout for establishing TCP connection in seconds. \ntype:uint64");
|
||||
toml.put ("handshake_timeout", handshake_timeout.count (), "Timeout for completing handshake in seconds. \ntype:uint64");
|
||||
toml.put ("io_timeout", io_timeout.count (), "Timeout for TCP I/O operations in seconds. \ntype:uint64");
|
||||
|
||||
return toml.get_error ();
|
||||
}
|
||||
|
||||
nano::error nano::transport::tcp_config::deserialize (nano::tomlconfig & toml)
|
||||
{
|
||||
toml.get ("max_inbound_connections", max_inbound_connections);
|
||||
toml.get ("max_outbound_connections", max_outbound_connections);
|
||||
toml.get ("max_attempts", max_attempts);
|
||||
toml.get ("max_attempts_per_ip", max_attempts_per_ip);
|
||||
|
||||
toml.get_duration ("connect_timeout", connect_timeout);
|
||||
toml.get_duration ("handshake_timeout", handshake_timeout);
|
||||
toml.get_duration ("io_timeout", io_timeout);
|
||||
|
||||
return toml.get_error ();
|
||||
}
|
||||
|
|
@ -23,7 +23,8 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
// TODO: Serialize/deserialize
|
||||
nano::error deserialize (nano::tomlconfig &);
|
||||
nano::error serialize (nano::tomlconfig &) const;
|
||||
|
||||
public:
|
||||
size_t max_inbound_connections{ 2048 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue