From 4135740ffd02c1998053467345b933865afe10da Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 24 Oct 2019 00:46:17 +0300 Subject: [PATCH] p2p: formatting and comments --- .../currency_protocol_handler.h | 36 +++++++++---------- .../currency_protocol_handler.inl | 12 +++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/currency_protocol/currency_protocol_handler.h b/src/currency_protocol/currency_protocol_handler.h index 58f9d218..5faa2efb 100644 --- a/src/currency_protocol/currency_protocol_handler.h +++ b/src/currency_protocol/currency_protocol_handler.h @@ -22,7 +22,7 @@ PUSH_VS_WARNINGS DISABLE_VS_WARNINGS(4355) -#define ASYNC_RELAY_MODE +#define ASYNC_RELAY_MODE // relay transactions asyncronously via m_relay_que namespace currency { @@ -117,25 +117,25 @@ namespace currency int64_t m_last_ntp2local_time_difference; template - bool post_notify(typename t_parametr::request& arg, currency_connection_context& context) - { - LOG_PRINT_L2("[POST]" << typeid(t_parametr).name() << " to " << context); - std::string blob; - epee::serialization::store_t_to_binary(arg, blob); - return m_p2p->invoke_notify_to_peer(t_parametr::ID, blob, context); - } + bool post_notify(typename t_parametr::request& arg, currency_connection_context& context) + { + LOG_PRINT_L3("[POST]" << typeid(t_parametr).name() << " to " << context); + std::string blob; + epee::serialization::store_t_to_binary(arg, blob); + return m_p2p->invoke_notify_to_peer(t_parametr::ID, blob, context); + } - template - bool relay_post_notify(typename t_parametr::request& arg, currency_connection_context& exlude_context) - { - std::string arg_buff; - epee::serialization::store_t_to_binary(arg, arg_buff); - std::list relayed_peers; - bool r = m_p2p->relay_notify_to_all(t_parametr::ID, arg_buff, exlude_context, relayed_peers); + template + bool relay_post_notify(typename t_parametr::request& arg, currency_connection_context& exlude_context) + { + std::string arg_buff; + epee::serialization::store_t_to_binary(arg, arg_buff); + std::list relayed_peers; + bool r = m_p2p->relay_notify_to_all(t_parametr::ID, arg_buff, exlude_context, relayed_peers); - LOG_PRINT_GREEN("[POST RELAY] " << typeid(t_parametr).name() << " relayed contexts list: " << print_connection_context_list(relayed_peers, ", "), LOG_LEVEL_2); - return r; - } + LOG_PRINT_GREEN("[POST RELAY] " << typeid(t_parametr).name() << " to (" << relayed_peers.size() << "): " << print_connection_context_list(relayed_peers, ", "), LOG_LEVEL_2); + return r; + } }; } diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index e9ca4eb7..7ff9a340 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -245,7 +245,6 @@ namespace currency if(context.m_state != currency_connection_context::state_normal) return 1; - //check if block already exists block b = AUTO_VAL_INIT(b); block_verification_context bvc = AUTO_VAL_INIT(bvc); @@ -255,6 +254,7 @@ namespace currency m_p2p->drop_connection(context); return 1; } + crypto::hash block_id = get_block_hash(b); LOG_PRINT_GREEN("[HANDLE]NOTIFY_NEW_BLOCK " << block_id << " HEIGHT " << get_block_height(b) << " (hop " << arg.hop << ")", LOG_LEVEL_2); @@ -324,11 +324,11 @@ namespace currency m_p2p->drop_connection(context); return 1; } - LOG_PRINT_GREEN("[HANDLE]NOTIFY_NEW_BLOCK EXTRA: id: " << block_id - << ",bvc.m_added_to_main_chain " << bvc.m_added_to_main_chain - //<< ",prevalidate_result " << prevalidate_relayed - << ",bvc.added_to_altchain " << bvc.added_to_altchain - << ",bvc.m_marked_as_orphaned " << bvc.m_marked_as_orphaned, LOG_LEVEL_2); + LOG_PRINT_GREEN("[HANDLE]NOTIFY_NEW_BLOCK EXTRA " << block_id + << " bvc.m_added_to_main_chain=" << bvc.m_added_to_main_chain + //<< ", prevalidate_result=" << prevalidate_relayed + << ", bvc.added_to_altchain=" << bvc.added_to_altchain + << ", bvc.m_marked_as_orphaned=" << bvc.m_marked_as_orphaned, LOG_LEVEL_2); if (bvc.m_added_to_main_chain || (bvc.added_to_altchain && bvc.height_difference < 2)) {