diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-26 12:41:08 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-26 12:41:08 -0700 |
| commit | 865acfa40f65626f41bbd718b645f57c7d6db9b2 (patch) | |
| tree | cb7bb750148f101578f28eec54154c40ef3a0ba2 /node/Topology.cpp | |
| parent | 3ce5ad9e2c1a31e1a3cc34f0ac8d950e4f0cf7b4 (diff) | |
| download | infinitytier-865acfa40f65626f41bbd718b645f57c7d6db9b2.tar.gz infinitytier-865acfa40f65626f41bbd718b645f57c7d6db9b2.zip | |
Cluster status plumbing.
Diffstat (limited to 'node/Topology.cpp')
| -rw-r--r-- | node/Topology.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp index 624c4987..e56d1f47 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -332,6 +332,21 @@ void Topology::clean(uint64_t now) } } +unsigned long Topology::countAlive() const +{ + const uint64_t now = RR->node->now(); + unsigned long cnt = 0; + Mutex::Lock _l(_lock); + Hashtable< Address,SharedPtr<Peer> >::Iterator i(const_cast<Topology *>(this)->_peers); + Address *a = (Address *)0; + SharedPtr<Peer> *p = (SharedPtr<Peer> *)0; + while (i.next(a,p)) { + if ((*p)->alive(now)) + ++cnt; + } + return cnt; +} + Identity Topology::_getIdentity(const Address &zta) { char p[128]; |
