diff options
author | Jeremy Rubin <jeremy.l.rubin@gmail.com> | 2016-06-15 19:28:04 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2016-09-08 13:06:05 -0400 |
commit | d1a2295f0d58423652b124b48fc887a9721b765c (patch) | |
tree | 72922e98c159106a37c8efdc2670630ab814f8cf /src/net.cpp | |
parent | 98591c50273b13cfc5419548b527280d6a84a43d (diff) |
Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index 508b0dd962..bf5cc07db1 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2697,7 +2697,7 @@ bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func) return found != nullptr && func(found); } -bool CConnman::ForEachNode(std::function<bool(CNode* pnode)> func) +bool CConnman::ForEachNodeContinueIf(std::function<bool(CNode* pnode)> func) { LOCK(cs_vNodes); for (auto&& node : vNodes) @@ -2706,7 +2706,7 @@ bool CConnman::ForEachNode(std::function<bool(CNode* pnode)> func) return true; } -bool CConnman::ForEachNode(std::function<bool(const CNode* pnode)> func) const +bool CConnman::ForEachNodeContinueIf(std::function<bool(const CNode* pnode)> func) const { LOCK(cs_vNodes); for (const auto& node : vNodes) @@ -2715,7 +2715,7 @@ bool CConnman::ForEachNode(std::function<bool(const CNode* pnode)> func) const return true; } -bool CConnman::ForEachNodeThen(std::function<bool(CNode* pnode)> pre, std::function<void()> post) +bool CConnman::ForEachNodeContinueIfThen(std::function<bool(CNode* pnode)> pre, std::function<void()> post) { bool ret = true; LOCK(cs_vNodes); @@ -2728,7 +2728,7 @@ bool CConnman::ForEachNodeThen(std::function<bool(CNode* pnode)> pre, std::funct return ret; } -bool CConnman::ForEachNodeThen(std::function<bool(const CNode* pnode)> pre, std::function<void()> post) const +bool CConnman::ForEachNodeContinueIfThen(std::function<bool(const CNode* pnode)> pre, std::function<void()> post) const { bool ret = true; LOCK(cs_vNodes); @@ -2741,6 +2741,35 @@ bool CConnman::ForEachNodeThen(std::function<bool(const CNode* pnode)> pre, std: return ret; } +void CConnman::ForEachNode(std::function<void(CNode* pnode)> func) +{ + LOCK(cs_vNodes); + for (auto&& node : vNodes) + func(node); +} + +void CConnman::ForEachNode(std::function<void(const CNode* pnode)> func) const +{ + LOCK(cs_vNodes); + for (const auto& node : vNodes) + func(node); +} + +void CConnman::ForEachNodeThen(std::function<void(CNode* pnode)> pre, std::function<void()> post) +{ + LOCK(cs_vNodes); + for (auto&& node : vNodes) + pre(node); + post(); +} + +void CConnman::ForEachNodeThen(std::function<void(const CNode* pnode)> pre, std::function<void()> post) const +{ + LOCK(cs_vNodes); + for (const auto& node : vNodes) + pre(node); + post(); +} int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) { return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5); } |