Browse Source

code review

cl-refactor
subtly 10 years ago
parent
commit
f5e03f5550
  1. 11
      libp2p/Host.cpp
  2. 2
      libp2p/NodeTable.cpp

11
libp2p/Host.cpp

@ -176,11 +176,14 @@ unsigned Host::protocolVersion() const
void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io, bi::tcp::endpoint _endpoint) void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io, bi::tcp::endpoint _endpoint)
{ {
shared_ptr<Peer> p(new Peer()); shared_ptr<Peer> p;
if (m_peers.count(_id)) if (!m_peers.count(_id))
p = m_peers[_id]; {
else p.reset(new Peer());
p->id = _id; p->id = _id;
}
else
p = m_peers[_id];
p->m_lastDisconnect = NoDisconnect; p->m_lastDisconnect = NoDisconnect;
if (p->isOffline()) if (p->isOffline())
p->m_lastConnected = std::chrono::system_clock::now(); p->m_lastConnected = std::chrono::system_clock::now();

2
libp2p/NodeTable.cpp

@ -309,7 +309,7 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en
Guard l(x_state); Guard l(x_state);
NodeBucket& s = bucket_UNSAFE(node.get()); NodeBucket& s = bucket_UNSAFE(node.get());
bool removed = false; bool removed = false;
s.nodes.remove_if([&node, &removed](weak_ptr<NodeEntry> n) s.nodes.remove_if([&node, &removed](weak_ptr<NodeEntry> const& n)
{ {
if (n.lock() == node) if (n.lock() == node)
removed = true; removed = true;

Loading…
Cancel
Save