Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #835 from EOSIO/p2p-sync-ignore-txns-stat-221-gh-833
Browse files Browse the repository at this point in the history
fix for notice forwarding
  • Loading branch information
heifner authored Dec 1, 2017
2 parents cf60c2e + c71a357 commit 21f37d4
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ namespace eosio {
// notices of previously unknown blocks or txns,
//
fc_dlog(logger, "got a notice_message from ${p}", ("p",c->peer_name()));
bool can_fwd = false;
notice_message fwd;
request_message req;
bool send_req = false;
Expand Down Expand Up @@ -1552,15 +1553,22 @@ namespace eosio {
fc_dlog(logger,"this is a ${m} notice with ${n} blocks", ("m",modes_str(msg.known_blocks.mode))("n",msg.known_blocks.pending));


if( msg.known_blocks.mode == id_list_modes::last_irr_catch_up ) {
switch (msg.known_blocks.mode) {
case id_list_modes::none : {
elog( "got a block notice message with a mode of none from ${p}",("p",c->peer_name()));
return;
}
case id_list_modes::last_irr_catch_up : {
sync_master->start_sync(c, msg.known_blocks.pending);
break;
}
else if( msg.known_blocks.mode == id_list_modes::catch_up ) {
req.req_blocks.mode = id_list_modes::catch_up;
req.req_blocks.pending = msg.known_blocks.pending;
send_req = true;
}
else {
case id_list_modes::catch_up : {
req.req_blocks.mode = id_list_modes::catch_up;
req.req_blocks.pending = msg.known_blocks.pending;
send_req = true;
break;
}
case id_list_modes::normal : {
req.req_blocks.mode = normal;
for( const auto& blkid : msg.known_blocks.ids) {
optional<signed_block> b;
Expand All @@ -1579,9 +1587,15 @@ namespace eosio {
req.req_blocks.ids.push_back(blkid);
}
}
break;
}
default: {
elog( "received a bogus known_blocks.mode ${m} from ${p}",("m",static_cast<uint32_t>(msg.known_blocks.mode))("p",c->peer_name()));
close(c);
}
}
if( msg.known_trx.pending == 0 && (fwd.known_trx.ids.size() > 0 ||
fwd.known_blocks.ids.size() > 0) ) {

if( can_fwd ) {
send_all( fwd, [c,fwd](connection_ptr cptr) -> bool {
return cptr != c;
});
Expand Down Expand Up @@ -1753,6 +1767,10 @@ namespace eosio {
return;
}
}
if( sync_master->syncing() ) {
fc_dlog(logger, "got a txn during sync - dropping");
return;
}

try {
// chain_plug->chain().validate_transaction(msg);
Expand Down Expand Up @@ -2031,6 +2049,7 @@ namespace eosio {
}
else {
fc_dlog(logger, "pending_notify, mode = ${m}, pending count = ${p}",("m",modes_str(pending_notify.mode))("p",pending_notify.pending));
pending_notify.mode = normal;
pending_notify.ids.push_back( txnid );
notice_message nm = { pending_notify, ordered_blk_ids( ) };
send_all( nm, [txn, txnid](connection_ptr c) -> bool {
Expand Down

0 comments on commit 21f37d4

Please sign in to comment.