Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | return nodes.modify(nit, [&](AvalancheNode &n) { | ||||
n.pubkey = std::move(pubkey); | n.pubkey = std::move(pubkey); | ||||
}); | }); | ||||
} | } | ||||
bool PeerManager::removeNode(NodeId nodeid) { | bool PeerManager::removeNode(NodeId nodeid) { | ||||
return nodes.erase(nodeid) > 0; | return nodes.erase(nodeid) > 0; | ||||
} | } | ||||
bool PeerManager::forNode( | |||||
NodeId nodeid, std::function<bool(const AvalancheNode &n)> func) const { | |||||
auto it = nodes.find(nodeid); | |||||
return it != nodes.end() && func(*it); | |||||
} | |||||
bool PeerManager::updateNextRequestTime(NodeId nodeid, TimePoint timeout) { | bool PeerManager::updateNextRequestTime(NodeId nodeid, TimePoint timeout) { | ||||
auto it = nodes.find(nodeid); | auto it = nodes.find(nodeid); | ||||
if (it == nodes.end()) { | if (it == nodes.end()) { | ||||
return false; | return false; | ||||
} | } | ||||
return nodes.modify(it, | return nodes.modify(it, | ||||
[&](AvalancheNode &n) { n.nextRequestTime = timeout; }); | [&](AvalancheNode &n) { n.nextRequestTime = timeout; }); | ||||
▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines |