Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove needless find() in p2p #1091

Merged
merged 1 commit into from
Jun 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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