Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | public: | ||||
template <typename Callable> | template <typename Callable> | ||||
bool forPeer(const ProofId &proofid, Callable &&func) const { | bool forPeer(const ProofId &proofid, Callable &&func) const { | ||||
auto &pview = peers.get<proof_index>(); | auto &pview = peers.get<proof_index>(); | ||||
auto it = pview.find(proofid); | auto it = pview.find(proofid); | ||||
return it != pview.end() && func(*it); | return it != pview.end() && func(*it); | ||||
} | } | ||||
template <typename Callable> | |||||
bool forPeer(const PeerId &peerid, Callable &&func) const { | |||||
auto it = peers.find(peerid); | |||||
return it != peers.end() && func(*it); | |||||
} | |||||
template <typename Callable> void forEachPeer(Callable &&func) const { | template <typename Callable> void forEachPeer(Callable &&func) const { | ||||
for (const auto &p : peers) { | for (const auto &p : peers) { | ||||
func(p); | func(p); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Update the peer set when a new block is connected. | * Update the peer set when a new block is connected. | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |