Skip to content

Commit

Permalink
Merge pull request #1091 from bitshares/jmj_issue_1090
Browse files Browse the repository at this point in the history
remove needless find() in p2p
  • Loading branch information
abitmore authored Jun 26, 2018
2 parents faba78d + 3c931a9 commit 4613b96
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions libraries/net/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,13 +750,11 @@ namespace graphene { namespace net { namespace detail {
idump((inventory_to_advertise));
for (const item_id& item_to_advertise : inventory_to_advertise)
{
if (peer->inventory_advertised_to_peer.find(item_to_advertise) != peer->inventory_advertised_to_peer.end() )
idump((*peer->inventory_advertised_to_peer.find(item_to_advertise)));
if (peer->inventory_peer_advertised_to_us.find(item_to_advertise) != peer->inventory_peer_advertised_to_us.end() )
idump((*peer->inventory_peer_advertised_to_us.find(item_to_advertise)));
auto adv_to_peer = peer->inventory_advertised_to_peer.find(item_to_advertise);
auto adv_to_us = peer->inventory_peer_advertised_to_us.find(item_to_advertise);

if (peer->inventory_advertised_to_peer.find(item_to_advertise) == peer->inventory_advertised_to_peer.end() &&
peer->inventory_peer_advertised_to_us.find(item_to_advertise) == peer->inventory_peer_advertised_to_us.end())
if (adv_to_peer == peer->inventory_advertised_to_peer.end() &&
adv_to_us == peer->inventory_peer_advertised_to_us.end())
{
items_to_advertise_by_type[item_to_advertise.item_type].push_back(item_to_advertise.item_hash);
peer->inventory_advertised_to_peer.insert(peer_connection::timestamped_item_id(item_to_advertise, fc::time_point::now()));
Expand All @@ -765,6 +763,13 @@ namespace graphene { namespace net { namespace detail {
testnetlog("advertising transaction ${id} to peer ${endpoint}", ("id", item_to_advertise.item_hash)("endpoint", peer->get_remote_endpoint()));
dlog("advertising item ${id} to peer ${endpoint}", ("id", item_to_advertise.item_hash)("endpoint", peer->get_remote_endpoint()));
}
else
{
if (adv_to_peer != peer->inventory_advertised_to_peer.end() )
idump( (*adv_to_peer) );
if (adv_to_us != peer->inventory_peer_advertised_to_us.end() )
idump( (*adv_to_us) );
}
}
dlog("advertising ${count} new item(s) of ${types} type(s) to peer ${endpoint}",
("count", total_items_to_send_to_this_peer)
Expand Down

0 comments on commit 4613b96

Please sign in to comment.