diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index 9ceac334f..1d54f4afe 100644 --- a/libp2p/Host.cpp +++ b/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) { - shared_ptr p(new Peer()); - if (m_peers.count(_id)) - p = m_peers[_id]; - else + shared_ptr p; + if (!m_peers.count(_id)) + { + p.reset(new Peer()); p->id = _id; + } + else + p = m_peers[_id]; p->m_lastDisconnect = NoDisconnect; if (p->isOffline()) p->m_lastConnected = std::chrono::system_clock::now(); diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index fa00e9ce2..47aefe63c 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -309,7 +309,7 @@ void NodeTable::noteActiveNode(Public const& _pubk, bi::udp::endpoint const& _en Guard l(x_state); NodeBucket& s = bucket_UNSAFE(node.get()); bool removed = false; - s.nodes.remove_if([&node, &removed](weak_ptr n) + s.nodes.remove_if([&node, &removed](weak_ptr const& n) { if (n.lock() == node) removed = true;