Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::net_plugin_impl Class Reference
Inheritance diagram for sysio::net_plugin_impl:
Collaboration diagram for sysio::net_plugin_impl:

Public Member Functions

void update_chain_info ()
 
std::tuple< uint32_t, uint32_t, uint32_t, block_id_type, block_id_type, block_id_typeget_chain_info () const
 
void start_listen_loop ()
 
void on_accepted_block (const block_state_ptr &bs)
 
void on_pre_accepted_block (const signed_block_ptr &bs)
 
void transaction_ack (const std::pair< fc::exception_ptr, packed_transaction_ptr > &)
 
void on_irreversible_block (const block_state_ptr &blk)
 
void start_conn_timer (boost::asio::steady_timer::duration du, std::weak_ptr< connection > from_connection)
 
void start_expire_timer ()
 
void start_monitors ()
 
void expire ()
 
void connection_monitor (std::weak_ptr< connection > from_connection, bool reschedule)
 
bool authenticate_peer (const handshake_message &msg) const
 Determine if a peer is allowed to connect.
 
chain::public_key_type get_authentication_key () const
 Retrieve public key used to authenticate with peers.
 
chain::signature_type sign_compact (const chain::public_key_type &signer, const fc::sha256 &digest) const
 Returns a signature of the digest using the corresponding private key of the signer.
 
connection_ptr find_connection (const string &host) const
 
string connect (const string &host)
 
Peer Timestamps

Time message handling

void ticker ()
 Peer heartbeat ticker.
 

Static Public Member Functions

static constexpr uint16_t to_protocol_version (uint16_t v)
 

Public Attributes

unique_ptr< tcp::acceptor > acceptor
 
std::atomic< uint32_tcurrent_connection_id {0}
 
unique_ptr< sync_managersync_master
 
unique_ptr< dispatch_managerdispatcher
 
std::shared_mutex connections_mtx
 
std::set< connection_ptrconnections
 
std::mutex connector_check_timer_mtx
 
unique_ptr< boost::asio::steady_timer > connector_check_timer
 
int connector_checks_in_flight {0}
 
std::mutex expire_timer_mtx
 
unique_ptr< boost::asio::steady_timer > expire_timer
 
std::mutex keepalive_timer_mtx
 
unique_ptr< boost::asio::steady_timer > keepalive_timer
 
std::atomic< bool > in_shutdown {false}
 
compat::channels::transaction_ack::channel_type::handle incoming_transaction_ack_subscription
 
uint16_t thread_pool_size = 2
 
std::optional< sysio::chain::named_thread_poolthread_pool
 
enum  possible_connections : char { None = 0 , Producers = 1 << 0 , Specified = 1 << 1 , Any = 1 << 2 }
 
string p2p_address
 
string p2p_server_address
 
vector< stringsupplied_peers
 
vector< chain::public_key_typeallowed_peers
 peer keys allowed to connect
 
std::map< chain::public_key_type, chain::private_key_typeprivate_keys
 overlapping with producer keys, also authenticating non-producing nodes
 
possible_connections allowed_connections {None}
 
boost::asio::steady_timer::duration connector_period {0}
 
boost::asio::steady_timer::duration txn_exp_period {0}
 
boost::asio::steady_timer::duration resp_expected_period {0}
 
std::chrono::milliseconds keepalive_interval {std::chrono::milliseconds{def_keepalive_interval}}
 
std::chrono::milliseconds heartbeat_timeout {keepalive_interval * 2}
 
int max_cleanup_time_ms = 0
 
uint32_t max_client_count = 0
 
uint32_t max_nodes_per_host = 1
 
bool p2p_accept_transactions = true
 
fc::microseconds p2p_dedup_cache_expire_time_us {}
 
const std::chrono::system_clock::duration peer_authentication_interval {std::chrono::seconds{1}}
 Peer clock may be no more than 1 second skewed from our clock, including network latency.
 
chain_id_type chain_id
 
fc::sha256 node_id
 
string user_agent_name
 
chain_pluginchain_plug = nullptr
 
producer_pluginproducer_plug = nullptr
 
bool use_socket_read_watermark = false
 

Detailed Description

Definition at line 218 of file net_plugin.cpp.

Member Enumeration Documentation

◆ possible_connections

Enumerator
None 
Producers 
Specified 
Any 

Definition at line 237 of file net_plugin.cpp.

237 : char {
238 None = 0,
239 Producers = 1 << 0,
240 Specified = 1 << 1,
241 Any = 1 << 2
242 };

Member Function Documentation

◆ authenticate_peer()

bool sysio::net_plugin_impl::authenticate_peer ( const handshake_message & msg) const

Checks current connection mode and key authentication.

Returns
False if the peer should not connect, true otherwise.

Definition at line 3438 of file net_plugin.cpp.

3438 {
3440 return false;
3441
3443 return true;
3444
3446 auto allowed_it = std::find(allowed_peers.begin(), allowed_peers.end(), msg.key);
3447 auto private_it = private_keys.find(msg.key);
3448 bool found_producer_key = false;
3449 if(producer_plug != nullptr)
3450 found_producer_key = producer_plug->is_producer_key(msg.key);
3451 if( allowed_it == allowed_peers.end() && private_it == private_keys.end() && !found_producer_key) {
3452 fc_elog( logger, "Peer ${peer} sent a handshake with an unauthorized key: ${key}.",
3453 ("peer", msg.p2p_address)("key", msg.key) );
3454 return false;
3455 }
3456 }
3457
3458 if(msg.sig != chain::signature_type() && msg.token != sha256()) {
3459 sha256 hash = fc::sha256::hash(msg.time);
3460 if(hash != msg.token) {
3461 fc_elog( logger, "Peer ${peer} sent a handshake with an invalid token.", ("peer", msg.p2p_address) );
3462 return false;
3463 }
3464 chain::public_key_type peer_key;
3465 try {
3466 peer_key = crypto::public_key(msg.sig, msg.token, true);
3467 }
3468 catch (const std::exception& /*e*/) {
3469 fc_elog( logger, "Peer ${peer} sent a handshake with an unrecoverable key.", ("peer", msg.p2p_address) );
3470 return false;
3471 }
3472 if((allowed_connections & (Producers | Specified)) && peer_key != msg.key) {
3473 fc_elog( logger, "Peer ${peer} sent a handshake with an unauthenticated key.", ("peer", msg.p2p_address) );
3474 return false;
3475 }
3476 }
3477 else if(allowed_connections & (Producers | Specified)) {
3478 fc_dlog( logger, "Peer sent a handshake with blank signature and token, but this node accepts only authenticated connections." );
3479 return false;
3480 }
3481 return true;
3482 }
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
std::map< chain::public_key_type, chain::private_key_type > private_keys
overlapping with producer keys, also authenticating non-producing nodes
possible_connections allowed_connections
producer_plugin * producer_plug
vector< chain::public_key_type > allowed_peers
peer keys allowed to connect
bool is_producer_key(const chain::public_key_type &key) const
#define fc_elog(LOGGER, FORMAT,...)
Definition logger.hpp:95
#define fc_dlog(LOGGER, FORMAT,...)
Definition logger.hpp:77
fc::crypto::public_key public_key_type
Definition types.hpp:76
fc::crypto::signature signature_type
Definition types.hpp:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect()

string sysio::net_plugin_impl::connect ( const string & host)

Definition at line 3856 of file net_plugin.cpp.

3856 {
3857 std::lock_guard<std::shared_mutex> g( connections_mtx );
3858 if( find_connection( host ) )
3859 return "already connected";
3860
3861 connection_ptr c = std::make_shared<connection>( host );
3862 fc_dlog( logger, "calling active connector: ${h}", ("h", host) );
3863 if( c->resolve_and_connect() ) {
3864 fc_dlog( logger, "adding new connection to the list: ${host} ${cid}", ("host", host)("cid", c->connection_id) );
3865 c->set_heartbeat_timeout( heartbeat_timeout );
3866 connections.insert( c );
3867 }
3868 return "added connection";
3869 }
connection_ptr find_connection(const string &host) const
std::shared_mutex connections_mtx
std::chrono::milliseconds heartbeat_timeout
std::set< connection_ptr > connections
client::connection_ptr connection_ptr
Here is the call graph for this function:

◆ connection_monitor()

void sysio::net_plugin_impl::connection_monitor ( std::weak_ptr< connection > from_connection,
bool reschedule )

Definition at line 3332 of file net_plugin.cpp.

3332 {
3333 auto max_time = fc::time_point::now();
3335 auto from = from_connection.lock();
3336 std::unique_lock<std::shared_mutex> g( connections_mtx );
3337 auto it = (from ? connections.find(from) : connections.begin());
3338 if (it == connections.end()) it = connections.begin();
3339 size_t num_rm = 0, num_clients = 0, num_peers = 0;
3340 while (it != connections.end()) {
3341 if (fc::time_point::now() >= max_time) {
3342 connection_wptr wit = *it;
3343 g.unlock();
3344 fc_dlog( logger, "Exiting connection monitor early, ran out of time: ${t}", ("t", max_time - fc::time_point::now()) );
3345 fc_ilog( logger, "p2p client connections: ${num}/${max}, peer connections: ${pnum}/${pmax}",
3346 ("num", num_clients)("max", max_client_count)("pnum", num_peers)("pmax", supplied_peers.size()) );
3347 if( reschedule ) {
3348 start_conn_timer( std::chrono::milliseconds( 1 ), wit ); // avoid exhausting
3349 }
3350 return;
3351 }
3352 (*it)->peer_address().empty() ? ++num_clients : ++num_peers;
3353 if( !(*it)->socket_is_open() && !(*it)->connecting) {
3354 if( !(*it)->peer_address().empty() ) {
3355 if( !(*it)->resolve_and_connect() ) {
3356 it = connections.erase(it);
3357 --num_peers; ++num_rm;
3358 continue;
3359 }
3360 } else {
3361 --num_clients; ++num_rm;
3362 it = connections.erase(it);
3363 continue;
3364 }
3365 }
3366 ++it;
3367 }
3368 g.unlock();
3369 if( num_clients > 0 || num_peers > 0 )
3370 fc_ilog( logger, "p2p client connections: ${num}/${max}, peer connections: ${pnum}/${pmax}",
3371 ("num", num_clients)("max", max_client_count)("pnum", num_peers)("pmax", supplied_peers.size()) );
3372 fc_dlog( logger, "connection monitor, removed ${n} connections", ("n", num_rm) );
3373 if( reschedule ) {
3374 start_conn_timer( connector_period, std::weak_ptr<connection>());
3375 }
3376 }
static time_point now()
Definition time.cpp:14
boost::asio::steady_timer::duration connector_period
void start_conn_timer(boost::asio::steady_timer::duration du, std::weak_ptr< connection > from_connection)
vector< string > supplied_peers
#define fc_ilog(LOGGER, FORMAT,...)
Definition logger.hpp:83
constexpr microseconds milliseconds(int64_t s)
Definition time.hpp:33
std::weak_ptr< connection > connection_wptr
Here is the call graph for this function:

◆ expire()

void sysio::net_plugin_impl::expire ( )

Definition at line 3320 of file net_plugin.cpp.

3320 {
3321 auto now = time_point::now();
3322 uint32_t lib = 0;
3323 std::tie( lib, std::ignore, std::ignore, std::ignore, std::ignore, std::ignore ) = get_chain_info();
3324 dispatcher->expire_blocks( lib );
3325 dispatcher->expire_txns();
3326 fc_dlog( logger, "expire_txns ${n}us", ("n", time_point::now() - now) );
3327
3329 }
unique_ptr< dispatch_manager > dispatcher
std::tuple< uint32_t, uint32_t, uint32_t, block_id_type, block_id_type, block_id_type > get_chain_info() const
unsigned int uint32_t
Definition stdint.h:126
Here is the call graph for this function:

◆ find_connection()

connection_ptr sysio::net_plugin_impl::find_connection ( const string & host) const

Definition at line 3903 of file net_plugin.cpp.

3903 {
3904 for( const auto& c : connections )
3905 if( c->peer_address() == host ) return c;
3906 return connection_ptr();
3907 }
std::shared_ptr< connection > connection_ptr
Here is the caller graph for this function:

◆ get_authentication_key()

chain::public_key_type sysio::net_plugin_impl::get_authentication_key ( ) const

Finds a key to use for authentication. If this node is a producer, use the front of the producer key map. If the node is not a producer but has a configured private key, use it. If the node is neither a producer nor has a private key, returns an empty key.

Note
On a node with multiple private keys configured, the key with the first numerically smaller byte will always be used.

Definition at line 3484 of file net_plugin.cpp.

3484 {
3485 if(!private_keys.empty())
3486 return private_keys.begin()->first;
3487 /*producer_plugin* pp = app().find_plugin<producer_plugin>();
3488 if(pp != nullptr && pp->get_state() == abstract_plugin::started)
3489 return pp->first_producer_public_key();*/
3490 return chain::public_key_type();
3491 }
Here is the caller graph for this function:

◆ get_chain_info()

std::tuple< uint32_t, uint32_t, uint32_t, block_id_type, block_id_type, block_id_type > sysio::net_plugin_impl::get_chain_info ( ) const

Definition at line 2713 of file net_plugin.cpp.

2713 {
2714 std::lock_guard<std::mutex> g( chain_info_mtx );
2715 return std::make_tuple(
2716 chain_lib_num, chain_head_blk_num, chain_fork_head_blk_num,
2717 chain_lib_id, chain_head_blk_id, chain_fork_head_blk_id );
2718 }
Here is the caller graph for this function:

◆ on_accepted_block()

void sysio::net_plugin_impl::on_accepted_block ( const block_state_ptr & bs)

Definition at line 3379 of file net_plugin.cpp.

3379 {
3381 dispatcher->strand.post( [this, bs]() {
3382 fc_dlog( logger, "signaled accepted_block, blk num = ${num}, id = ${id}", ("num", bs->block_num)("id", bs->id) );
3383
3384 auto blk_trace = fc_create_trace_with_id( "Block", bs->id );
3385 auto blk_span = fc_create_span( blk_trace, "Accepted" );
3386 fc_add_tag( blk_span, "block_id", bs->id );
3387 fc_add_tag( blk_span, "block_num", bs->block_num );
3388 fc_add_tag( blk_span, "block_time", bs->block->timestamp.to_time_point() );
3389
3390 dispatcher->bcast_block( bs->block, bs->id );
3391 });
3392 }
#define fc_create_span(TRACE_VARNAME, SPAN_STR)
Definition trace.hpp:24
#define fc_add_tag(SPAN_VARNAME, TAG_KEY_STR, TAG_VALUE_STR)
Definition trace.hpp:40
#define fc_create_trace_with_id(TRACE_STR, TRACE_ID)
Definition trace.hpp:16
Here is the call graph for this function:

◆ on_irreversible_block()

void sysio::net_plugin_impl::on_irreversible_block ( const block_state_ptr & blk)

Definition at line 3416 of file net_plugin.cpp.

3416 {
3417 fc_dlog( logger, "on_irreversible_block, blk num = ${num}, id = ${id}", ("num", block->block_num)("id", block->id) );
3419 }
Here is the call graph for this function:

◆ on_pre_accepted_block()

void sysio::net_plugin_impl::on_pre_accepted_block ( const signed_block_ptr & bs)

Definition at line 3395 of file net_plugin.cpp.

3395 {
3397 controller& cc = chain_plug->chain();
3398 if( cc.is_trusted_producer(block->producer) ) {
3399 dispatcher->strand.post( [this, block]() {
3400 auto id = block->calculate_id();
3401 fc_dlog( logger, "signaled pre_accepted_block, blk num = ${num}, id = ${id}", ("num", block->block_num())("id", id) );
3402
3403 auto blk_trace = fc_create_trace_with_id("Block", id);
3404 auto blk_span = fc_create_span(blk_trace, "PreAccepted");
3405 fc_add_tag(blk_span, "block_id", id);
3406 fc_add_tag(blk_span, "block_num", block->block_num());
3407 fc_add_tag(blk_span, "block_time", block->timestamp.to_time_point());
3408 fc_add_tag(blk_span, "producer", block->producer.to_string());
3409
3410 dispatcher->bcast_block( block, id );
3411 });
3412 }
3413 }
bool is_trusted_producer(const account_name &producer) const
chain_plugin * chain_plug
Here is the call graph for this function:

◆ sign_compact()

chain::signature_type sysio::net_plugin_impl::sign_compact ( const chain::public_key_type & signer,
const fc::sha256 & digest ) const

If there are no configured private keys, returns an empty signature.

Definition at line 3493 of file net_plugin.cpp.

3494 {
3495 auto private_key_itr = private_keys.find(signer);
3496 if(private_key_itr != private_keys.end())
3497 return private_key_itr->second.sign(digest);
3499 return producer_plug->sign_compact(signer, digest);
3500 return chain::signature_type();
3501 }
@ started
the plugin is actively running
Definition plugin.hpp:33
virtual state get_state() const override
chain::signature_type sign_compact(const chain::public_key_type &key, const fc::sha256 &digest) const
fc::sha256 digest(const T &value)
Definition digest.hpp:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_conn_timer()

void sysio::net_plugin_impl::start_conn_timer ( boost::asio::steady_timer::duration du,
std::weak_ptr< connection > from_connection )

Definition at line 3246 of file net_plugin.cpp.

3246 {
3247 if( in_shutdown ) return;
3248 std::lock_guard<std::mutex> g( connector_check_timer_mtx );
3250 connector_check_timer->expires_from_now( du );
3251 connector_check_timer->async_wait( [my = shared_from_this(), from_connection](boost::system::error_code ec) {
3252 std::unique_lock<std::mutex> g( my->connector_check_timer_mtx );
3253 int num_in_flight = --my->connector_checks_in_flight;
3254 g.unlock();
3255 if( !ec ) {
3256 my->connection_monitor(from_connection, num_in_flight == 0 );
3257 } else {
3258 if( num_in_flight == 0 ) {
3259 if( my->in_shutdown ) return;
3260 fc_elog( logger, "Error from connection check monitor: ${m}", ("m", ec.message()));
3261 my->start_conn_timer( my->connector_period, std::weak_ptr<connection>() );
3262 }
3263 }
3264 });
3265 }
unique_ptr< boost::asio::steady_timer > connector_check_timer
std::atomic< bool > in_shutdown
std::mutex connector_check_timer_mtx
Here is the caller graph for this function:

◆ start_expire_timer()

void sysio::net_plugin_impl::start_expire_timer ( )

Definition at line 3268 of file net_plugin.cpp.

3268 {
3269 if( in_shutdown ) return;
3270 std::lock_guard<std::mutex> g( expire_timer_mtx );
3271 expire_timer->expires_from_now( txn_exp_period);
3272 expire_timer->async_wait( [my = shared_from_this()]( boost::system::error_code ec ) {
3273 if( !ec ) {
3274 my->expire();
3275 } else {
3276 if( my->in_shutdown ) return;
3277 fc_elog( logger, "Error from transaction check monitor: ${m}", ("m", ec.message()) );
3278 my->start_expire_timer();
3279 }
3280 } );
3281 }
unique_ptr< boost::asio::steady_timer > expire_timer
boost::asio::steady_timer::duration txn_exp_period
Here is the caller graph for this function:

◆ start_listen_loop()

void sysio::net_plugin_impl::start_listen_loop ( )

Definition at line 2362 of file net_plugin.cpp.

2362 {
2363 connection_ptr new_connection = std::make_shared<connection>();
2364 new_connection->connecting = true;
2365 new_connection->strand.post( [this, new_connection = std::move( new_connection )](){
2366 acceptor->async_accept( *new_connection->socket,
2367 boost::asio::bind_executor( new_connection->strand, [new_connection, socket=new_connection->socket, this]( boost::system::error_code ec ) {
2368 if( !ec ) {
2369 uint32_t visitors = 0;
2370 uint32_t from_addr = 0;
2371 boost::system::error_code rec;
2372 const auto& paddr_add = socket->remote_endpoint( rec ).address();
2373 string paddr_str;
2374 if( rec ) {
2375 fc_elog( logger, "Error getting remote endpoint: ${m}", ("m", rec.message()));
2376 } else {
2377 paddr_str = paddr_add.to_string();
2378 for_each_connection( [&visitors, &from_addr, &paddr_str]( auto& conn ) {
2379 if( conn->socket_is_open()) {
2380 if( conn->peer_address().empty()) {
2381 ++visitors;
2382 std::lock_guard<std::mutex> g_conn( conn->conn_mtx );
2383 if( paddr_str == conn->remote_endpoint_ip ) {
2384 ++from_addr;
2385 }
2386 }
2387 }
2388 return true;
2389 } );
2390 if( from_addr < max_nodes_per_host && (max_client_count == 0 || visitors < max_client_count)) {
2391 fc_ilog( logger, "Accepted new connection: " + paddr_str );
2392 new_connection->set_heartbeat_timeout( heartbeat_timeout );
2393 if( new_connection->start_session()) {
2394 std::lock_guard<std::shared_mutex> g_unique( connections_mtx );
2395 connections.insert( new_connection );
2396 }
2397
2398 } else {
2399 if( from_addr >= max_nodes_per_host ) {
2400 fc_dlog( logger, "Number of connections (${n}) from ${ra} exceeds limit ${l}",
2401 ("n", from_addr + 1)( "ra", paddr_str )( "l", max_nodes_per_host ));
2402 } else {
2403 fc_dlog( logger, "max_client_count ${m} exceeded", ("m", max_client_count));
2404 }
2405 // new_connection never added to connections and start_session not called, lifetime will end
2406 boost::system::error_code ec;
2407 socket->shutdown( tcp::socket::shutdown_both, ec );
2408 socket->close( ec );
2409 }
2410 }
2411 } else {
2412 fc_elog( logger, "Error accepting connection: ${m}", ("m", ec.message()));
2413 // For the listed error codes below, recall start_listen_loop()
2414 switch (ec.value()) {
2415 case ECONNABORTED:
2416 case EMFILE:
2417 case ENFILE:
2418 case ENOBUFS:
2419 case ENOMEM:
2420 case EPROTO:
2421 break;
2422 default:
2423 return;
2424 }
2425 }
2427 }));
2428 } );
2429 }
unique_ptr< tcp::acceptor > acceptor
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_monitors()

void sysio::net_plugin_impl::start_monitors ( )

Definition at line 3307 of file net_plugin.cpp.

3307 {
3308 {
3309 std::lock_guard<std::mutex> g( connector_check_timer_mtx );
3310 connector_check_timer.reset(new boost::asio::steady_timer( my_impl->thread_pool->get_executor() ));
3311 }
3312 {
3313 std::lock_guard<std::mutex> g( expire_timer_mtx );
3314 expire_timer.reset( new boost::asio::steady_timer( my_impl->thread_pool->get_executor() ) );
3315 }
3316 start_conn_timer(connector_period, std::weak_ptr<connection>());
3318 }
void reset(pointer v)
std::optional< sysio::chain::named_thread_pool > thread_pool
Here is the call graph for this function:

◆ ticker()

void sysio::net_plugin_impl::ticker ( )

Definition at line 3284 of file net_plugin.cpp.

3284 {
3285 if( in_shutdown ) return;
3286 std::lock_guard<std::mutex> g( keepalive_timer_mtx );
3287 keepalive_timer->expires_from_now(keepalive_interval);
3288 keepalive_timer->async_wait( [my = shared_from_this()]( boost::system::error_code ec ) {
3289 my->ticker();
3290 if( ec ) {
3291 if( my->in_shutdown ) return;
3292 fc_wlog( logger, "Peer keepalive ticked sooner than expected: ${m}", ("m", ec.message()) );
3293 }
3294
3295 tstamp current_time = connection::get_time();
3296 for_each_connection( [current_time]( auto& c ) {
3297 if( c->socket_is_open() ) {
3298 c->strand.post([c, current_time]() {
3299 c->check_heartbeat(current_time);
3300 } );
3301 }
3302 return true;
3303 } );
3304 } );
3305 }
static tstamp get_time()
Read system time and convert to a 64 bit integer.
std::mutex keepalive_timer_mtx
std::chrono::milliseconds keepalive_interval
unique_ptr< boost::asio::steady_timer > keepalive_timer
#define fc_wlog(LOGGER, FORMAT,...)
Definition logger.hpp:89
std::chrono::system_clock::duration::rep tstamp
Definition protocol.hpp:11
void for_each_connection(Function f)
Here is the call graph for this function:

◆ to_protocol_version()

uint16_t sysio::net_plugin_impl::to_protocol_version ( uint16_t v)
staticconstexpr

Definition at line 3909 of file net_plugin.cpp.

3909 {
3910 if (v >= net_version_base) {
3911 v -= net_version_base;
3912 return (v > net_version_range) ? 0 : v;
3913 }
3914 return 0;
3915 }
constexpr uint16_t net_version_range
constexpr uint16_t net_version_base
Here is the caller graph for this function:

◆ transaction_ack()

void sysio::net_plugin_impl::transaction_ack ( const std::pair< fc::exception_ptr, packed_transaction_ptr > & results)

Definition at line 3422 of file net_plugin.cpp.

3422 {
3423 dispatcher->strand.post( [this, results]() {
3424 const auto& id = results.second->id();
3425 if (results.first) {
3426 fc_dlog( logger, "signaled NACK, trx-id = ${id} : ${why}", ("id", id)( "why", results.first->to_detail_string() ) );
3427
3428 uint32_t head_blk_num = 0;
3429 std::tie( std::ignore, head_blk_num, std::ignore, std::ignore, std::ignore, std::ignore ) = get_chain_info();
3430 dispatcher->rejected_transaction(results.second, head_blk_num);
3431 } else {
3432 fc_dlog( logger, "signaled ACK, trx-id = ${id}", ("id", id) );
3433 dispatcher->bcast_transaction(results.second);
3434 }
3435 });
3436 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_chain_info()

void sysio::net_plugin_impl::update_chain_info ( )

Definition at line 2698 of file net_plugin.cpp.

2698 {
2699 controller& cc = chain_plug->chain();
2700 std::lock_guard<std::mutex> g( chain_info_mtx );
2701 chain_lib_num = cc.last_irreversible_block_num();
2702 chain_lib_id = cc.last_irreversible_block_id();
2703 chain_head_blk_num = cc.head_block_num();
2704 chain_head_blk_id = cc.head_block_id();
2705 chain_fork_head_blk_num = cc.fork_db_pending_head_block_num();
2706 chain_fork_head_blk_id = cc.fork_db_pending_head_block_id();
2707 fc_dlog( logger, "updating chain info lib ${lib}, head ${head}, fork ${fork}",
2708 ("lib", chain_lib_num)("head", chain_head_blk_num)("fork", chain_fork_head_blk_num) );
2709 }
block_id_type fork_db_pending_head_block_id() const
uint32_t head_block_num() const
block_id_type head_block_id() const
uint32_t last_irreversible_block_num() const
uint32_t fork_db_pending_head_block_num() const
block_id_type last_irreversible_block_id() const
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ acceptor

unique_ptr<tcp::acceptor> sysio::net_plugin_impl::acceptor

Definition at line 220 of file net_plugin.cpp.

◆ allowed_connections

possible_connections sysio::net_plugin_impl::allowed_connections {None}

Definition at line 243 of file net_plugin.cpp.

243{None};

◆ allowed_peers

vector<chain::public_key_type> sysio::net_plugin_impl::allowed_peers

Definition at line 234 of file net_plugin.cpp.

◆ chain_id

chain_id_type sysio::net_plugin_impl::chain_id

Definition at line 260 of file net_plugin.cpp.

◆ chain_plug

chain_plugin* sysio::net_plugin_impl::chain_plug = nullptr

Definition at line 264 of file net_plugin.cpp.

◆ connections

std::set< connection_ptr > sysio::net_plugin_impl::connections

Definition at line 270 of file net_plugin.cpp.

◆ connections_mtx

std::shared_mutex sysio::net_plugin_impl::connections_mtx
mutable

Definition at line 269 of file net_plugin.cpp.

◆ connector_check_timer

unique_ptr<boost::asio::steady_timer> sysio::net_plugin_impl::connector_check_timer

Definition at line 273 of file net_plugin.cpp.

◆ connector_check_timer_mtx

std::mutex sysio::net_plugin_impl::connector_check_timer_mtx

Definition at line 272 of file net_plugin.cpp.

◆ connector_checks_in_flight

int sysio::net_plugin_impl::connector_checks_in_flight {0}

Definition at line 274 of file net_plugin.cpp.

274{0};

◆ connector_period

boost::asio::steady_timer::duration sysio::net_plugin_impl::connector_period {0}

Definition at line 245 of file net_plugin.cpp.

245{0};

◆ current_connection_id

std::atomic<uint32_t> sysio::net_plugin_impl::current_connection_id {0}

Definition at line 221 of file net_plugin.cpp.

221{0};

◆ dispatcher

unique_ptr< dispatch_manager > sysio::net_plugin_impl::dispatcher

Definition at line 224 of file net_plugin.cpp.

◆ expire_timer

unique_ptr<boost::asio::steady_timer> sysio::net_plugin_impl::expire_timer

Definition at line 277 of file net_plugin.cpp.

◆ expire_timer_mtx

std::mutex sysio::net_plugin_impl::expire_timer_mtx

Definition at line 276 of file net_plugin.cpp.

◆ heartbeat_timeout

std::chrono::milliseconds sysio::net_plugin_impl::heartbeat_timeout {keepalive_interval * 2}

Definition at line 249 of file net_plugin.cpp.

◆ in_shutdown

std::atomic<bool> sysio::net_plugin_impl::in_shutdown {false}

Definition at line 282 of file net_plugin.cpp.

282{false};

◆ incoming_transaction_ack_subscription

compat::channels::transaction_ack::channel_type::handle sysio::net_plugin_impl::incoming_transaction_ack_subscription

Definition at line 284 of file net_plugin.cpp.

◆ keepalive_interval

std::chrono::milliseconds sysio::net_plugin_impl::keepalive_interval {std::chrono::milliseconds{def_keepalive_interval}}

Definition at line 248 of file net_plugin.cpp.

248{std::chrono::milliseconds{def_keepalive_interval}};
constexpr auto def_keepalive_interval

◆ keepalive_timer

unique_ptr<boost::asio::steady_timer> sysio::net_plugin_impl::keepalive_timer

Definition at line 280 of file net_plugin.cpp.

◆ keepalive_timer_mtx

std::mutex sysio::net_plugin_impl::keepalive_timer_mtx

Definition at line 279 of file net_plugin.cpp.

◆ max_cleanup_time_ms

int sysio::net_plugin_impl::max_cleanup_time_ms = 0

Definition at line 251 of file net_plugin.cpp.

◆ max_client_count

uint32_t sysio::net_plugin_impl::max_client_count = 0

Definition at line 252 of file net_plugin.cpp.

◆ max_nodes_per_host

uint32_t sysio::net_plugin_impl::max_nodes_per_host = 1

Definition at line 253 of file net_plugin.cpp.

◆ node_id

fc::sha256 sysio::net_plugin_impl::node_id

Definition at line 261 of file net_plugin.cpp.

◆ p2p_accept_transactions

bool sysio::net_plugin_impl::p2p_accept_transactions = true

Definition at line 254 of file net_plugin.cpp.

◆ p2p_address

string sysio::net_plugin_impl::p2p_address

Thread safe, only updated in plugin initialize

Definition at line 230 of file net_plugin.cpp.

◆ p2p_dedup_cache_expire_time_us

fc::microseconds sysio::net_plugin_impl::p2p_dedup_cache_expire_time_us {}

Definition at line 255 of file net_plugin.cpp.

255{};

◆ p2p_server_address

string sysio::net_plugin_impl::p2p_server_address

Definition at line 231 of file net_plugin.cpp.

◆ peer_authentication_interval

const std::chrono::system_clock::duration sysio::net_plugin_impl::peer_authentication_interval {std::chrono::seconds{1}}

Definition at line 258 of file net_plugin.cpp.

258{std::chrono::seconds{1}};

◆ private_keys

std::map<chain::public_key_type, chain::private_key_type> sysio::net_plugin_impl::private_keys

Definition at line 236 of file net_plugin.cpp.

◆ producer_plug

producer_plugin* sysio::net_plugin_impl::producer_plug = nullptr

Definition at line 265 of file net_plugin.cpp.

◆ resp_expected_period

boost::asio::steady_timer::duration sysio::net_plugin_impl::resp_expected_period {0}

Definition at line 247 of file net_plugin.cpp.

247{0};

◆ supplied_peers

vector<string> sysio::net_plugin_impl::supplied_peers

Definition at line 233 of file net_plugin.cpp.

◆ sync_master

unique_ptr< sync_manager > sysio::net_plugin_impl::sync_master

Definition at line 223 of file net_plugin.cpp.

◆ thread_pool

std::optional<sysio::chain::named_thread_pool> sysio::net_plugin_impl::thread_pool

Definition at line 287 of file net_plugin.cpp.

◆ thread_pool_size

uint16_t sysio::net_plugin_impl::thread_pool_size = 2

Definition at line 286 of file net_plugin.cpp.

◆ txn_exp_period

boost::asio::steady_timer::duration sysio::net_plugin_impl::txn_exp_period {0}

Definition at line 246 of file net_plugin.cpp.

246{0};

◆ use_socket_read_watermark

bool sysio::net_plugin_impl::use_socket_read_watermark = false

Definition at line 266 of file net_plugin.cpp.

◆ user_agent_name

string sysio::net_plugin_impl::user_agent_name

Definition at line 262 of file net_plugin.cpp.


The documentation for this class was generated from the following file: