forked from lthn/blockchain
p2p: formatting and comments
This commit is contained in:
parent
998ab7cfa8
commit
4135740ffd
2 changed files with 24 additions and 24 deletions
|
|
@ -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<class t_parametr>
|
||||
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<class t_parametr>
|
||||
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<epee::net_utils::connection_context_base> relayed_peers;
|
||||
bool r = m_p2p->relay_notify_to_all(t_parametr::ID, arg_buff, exlude_context, relayed_peers);
|
||||
template<class t_parametr>
|
||||
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<epee::net_utils::connection_context_base> 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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue