Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | bool PeerManager::removePeer(const PeerId peerid) { | ||||
// active. This ensure that we don't overquery them in case they are | // active. This ensure that we don't overquery them in case they are | ||||
// subsequently added to another peer. | // subsequently added to another peer. | ||||
nview.erase(nview.lower_bound(boost::make_tuple(peerid, TimePoint())), | nview.erase(nview.lower_bound(boost::make_tuple(peerid, TimePoint())), | ||||
nview.upper_bound(boost::make_tuple( | nview.upper_bound(boost::make_tuple( | ||||
peerid, std::chrono::steady_clock::now()))); | peerid, std::chrono::steady_clock::now()))); | ||||
// Release UTXOs attached to this proof. | // Release UTXOs attached to this proof. | ||||
for (const auto &s : it->proof->getStakes()) { | for (const auto &s : it->proof->getStakes()) { | ||||
bool deleted = utxos.erase(s.getStake().getUTXO()) > 0; | auto utxo_it = utxos.find(s.getStake().getUTXO()); | ||||
assert(deleted); | // Make sure the UTXO has not been re-assigned to another peer before | ||||
// erasing. | |||||
if (utxo_it->second == peerid) { | |||||
utxos.erase(utxo_it); | |||||
} | |||||
} | } | ||||
m_unbroadcast_proofids.erase(it->proof->getId()); | m_unbroadcast_proofids.erase(it->proof->getId()); | ||||
peers.erase(it); | peers.erase(it); | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 218 Lines • Show Last 20 Lines |