Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Fix incorrect logging of NodeIPEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Aug 10, 2018
1 parent f19c9ae commit 55a2d75
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
9 changes: 5 additions & 4 deletions libp2p/Common.cpp
Expand Up @@ -226,12 +226,13 @@ std::string NodeSpec::enode() const

namespace dev
{

std::ostream& operator<<(std::ostream& _out, dev::p2p::NodeIPEndpoint const& _ep)
namespace p2p
{
std::ostream& operator<<(std::ostream& _out, NodeIPEndpoint const& _ep)
{
_out << _ep.address() << _ep.udpPort() << _ep.tcpPort();
_out << _ep.address() << " UDP " << _ep.udpPort() << " TCP " << _ep.tcpPort();
return _out;
}

} // namespace p2p
}

4 changes: 2 additions & 2 deletions libp2p/Common.h
Expand Up @@ -329,10 +329,10 @@ class DeadlineOps
std::atomic<bool> m_stopped;
};

/// Simple stream output for a NodeIPEndpoint.
std::ostream& operator<<(std::ostream& _out, NodeIPEndpoint const& _ep);
}

/// Simple stream output for a NodeIPEndpoint.
std::ostream& operator<<(std::ostream& _out, dev::p2p::NodeIPEndpoint const& _ep);
}

/// std::hash for asio::adress
Expand Down
20 changes: 13 additions & 7 deletions libp2p/NodeTable.cpp
Expand Up @@ -98,11 +98,15 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node, NodeRelation _relati
if (!_node.id)
{
DEV_GUARDED(x_nodes)
LOG(m_logger) << "Sending public key discovery Ping to "
<< (bi::udp::endpoint)_node.endpoint
<< " (Advertising: " << (bi::udp::endpoint)m_node.endpoint << ")";
{
LOG(m_logger) << "Sending public key discovery Ping to "
<< (bi::udp::endpoint)_node.endpoint
<< " (Advertising: " << (bi::udp::endpoint)m_node.endpoint << ")";
}
DEV_GUARDED(x_pubkDiscoverPings)
m_pubkDiscoverPings[_node.endpoint.address()] = std::chrono::steady_clock::now();
{
m_pubkDiscoverPings[_node.endpoint.address()] = std::chrono::steady_clock::now();
}
ping(_node.endpoint);
return shared_ptr<NodeEntry>();
}
Expand All @@ -113,10 +117,12 @@ shared_ptr<NodeEntry> NodeTable::addNode(Node const& _node, NodeRelation _relati

auto ret = make_shared<NodeEntry>(m_node.id, _node.id, _node.endpoint);
DEV_GUARDED(x_nodes)
{
m_nodes[_node.id] = ret;
LOG(m_logger) << "addNode pending for " << _node.endpoint;
ping(_node.endpoint);
return ret;
}
LOG(m_logger) << "addNode pending for " << _node.endpoint;
ping(_node.endpoint);
return ret;
}

list<NodeID> NodeTable::nodes() const
Expand Down

0 comments on commit 55a2d75

Please sign in to comment.