Network class config
This commit is contained in:
parent
3d8338763f
commit
95838fa7af
3 changed files with 28 additions and 9 deletions
|
@ -18,6 +18,7 @@ using namespace std::chrono_literals;
|
|||
*/
|
||||
|
||||
nano::network::network (nano::node & node, uint16_t port) :
|
||||
config{ node.config.network },
|
||||
node{ node },
|
||||
id{ nano::network_constants::active_network },
|
||||
syn_cookies{ node.network_params.network.max_peers_per_ip, node.logger },
|
||||
|
@ -49,15 +50,20 @@ void nano::network::start ()
|
|||
run_keepalive ();
|
||||
});
|
||||
|
||||
reachout_thread = std::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::network_reachout);
|
||||
run_reachout ();
|
||||
});
|
||||
|
||||
reachout_cached_thread = std::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::network_reachout);
|
||||
run_reachout_cached ();
|
||||
});
|
||||
if (config.peer_reachout.count () > 0)
|
||||
{
|
||||
reachout_thread = std::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::network_reachout);
|
||||
run_reachout ();
|
||||
});
|
||||
}
|
||||
if (config.cached_peer_reachout.count () > 0)
|
||||
{
|
||||
reachout_cached_thread = std::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::network_reachout);
|
||||
run_reachout_cached ();
|
||||
});
|
||||
}
|
||||
|
||||
if (!node.flags.disable_tcp_realtime)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,16 @@ private:
|
|||
std::size_t max_cookies_per_ip;
|
||||
};
|
||||
|
||||
class network_config final
|
||||
{
|
||||
public:
|
||||
// TODO: Serialization & deserialization
|
||||
|
||||
public:
|
||||
std::chrono::milliseconds peer_reachout{ 250ms };
|
||||
std::chrono::milliseconds cached_peer_reachout{ 1s };
|
||||
};
|
||||
|
||||
class network final
|
||||
{
|
||||
public:
|
||||
|
@ -112,6 +122,7 @@ private:
|
|||
void run_reachout_cached ();
|
||||
|
||||
private: // Dependencies
|
||||
network_config const & config;
|
||||
nano::node & node;
|
||||
|
||||
public:
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <nano/node/bootstrap/bootstrap_server.hpp>
|
||||
#include <nano/node/ipc/ipc_config.hpp>
|
||||
#include <nano/node/message_processor.hpp>
|
||||
#include <nano/node/network.hpp>
|
||||
#include <nano/node/peer_history.hpp>
|
||||
#include <nano/node/repcrawler.hpp>
|
||||
#include <nano/node/request_aggregator.hpp>
|
||||
|
@ -148,6 +149,7 @@ public:
|
|||
nano::transport::tcp_config tcp;
|
||||
nano::request_aggregator_config request_aggregator;
|
||||
nano::message_processor_config message_processor;
|
||||
nano::network_config network;
|
||||
|
||||
public:
|
||||
std::string serialize_frontiers_confirmation (nano::frontiers_confirmation_mode) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue