Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | void OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, | ||||
CSemaphoreGrant *grantOutbound, | CSemaphoreGrant *grantOutbound, | ||||
const char *strDest, ConnectionType conn_type); | const char *strDest, ConnectionType conn_type); | ||||
bool CheckIncomingNonce(uint64_t nonce); | bool CheckIncomingNonce(uint64_t nonce); | ||||
bool ForNode(NodeId id, std::function<bool(CNode *pnode)> func); | bool ForNode(NodeId id, std::function<bool(CNode *pnode)> func); | ||||
void PushMessage(CNode *pnode, CSerializedNetMsg &&msg); | void PushMessage(CNode *pnode, CSerializedNetMsg &&msg); | ||||
template <typename Callable> void ForEachNode(Callable &&func) { | using NodeFn = std::function<void(CNode *)>; | ||||
void ForEachNode(const NodeFn &func) { | |||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
for (auto &&node : vNodes) { | for (auto &&node : vNodes) { | ||||
if (NodeFullyConnected(node)) { | if (NodeFullyConnected(node)) { | ||||
func(node); | func(node); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
template <typename Callable> void ForEachNode(Callable &&func) const { | void ForEachNode(const NodeFn &func) const { | ||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
for (auto &&node : vNodes) { | for (auto &&node : vNodes) { | ||||
if (NodeFullyConnected(node)) { | if (NodeFullyConnected(node)) { | ||||
func(node); | func(node); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 1,047 Lines • Show Last 20 Lines |