diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-04 12:14:21 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-04 12:14:21 -0700 |
commit | 3a959a7763b44ffcddce557167169150a28b9059 (patch) | |
tree | b2e07eba02cdd1716ba21cae14224e8fefa4d1b4 /node/Topology.hpp | |
parent | cfd101c9b85b20e5911445998a6f040089e3e414 (diff) | |
download | infinitytier-3a959a7763b44ffcddce557167169150a28b9059.tar.gz infinitytier-3a959a7763b44ffcddce557167169150a28b9059.zip |
Swap out std::map<> for Hashtable<> for main peer database in Topology. (ongoing std::map-ectomy)
Diffstat (limited to 'node/Topology.hpp')
-rw-r--r-- | node/Topology.hpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/node/Topology.hpp b/node/Topology.hpp index 1c5cca00..3066b50c 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -44,6 +44,7 @@ #include "Mutex.hpp" #include "InetAddress.hpp" #include "Dictionary.hpp" +#include "Hashtable.hpp" namespace ZeroTier { @@ -163,17 +164,20 @@ public: inline void eachPeer(F f) { Mutex::Lock _l(_lock); - for(std::map< Address,SharedPtr<Peer> >::const_iterator p(_activePeers.begin());p!=_activePeers.end();++p) - f(*this,p->second); + Hashtable< Address,SharedPtr<Peer> >::Iterator i(_activePeers); + Address *a = (Address *)0; + SharedPtr<Peer> *p = (SharedPtr<Peer> *)0; + while (i.next(a,p)) + f(*this,*p); } /** * @return All currently active peers by address */ - inline std::map< Address,SharedPtr<Peer> > allPeers() const + inline std::vector< std::pair< Address,SharedPtr<Peer> > > allPeers() const { Mutex::Lock _l(_lock); - return _activePeers; + return _activePeers.entries(); } /** @@ -190,7 +194,7 @@ private: const RuntimeEnvironment *RR; - std::map< Address,SharedPtr<Peer> > _activePeers; + Hashtable< Address,SharedPtr<Peer> > _activePeers; std::map< Identity,std::vector<InetAddress> > _roots; std::vector< Address > _rootAddresses; std::vector< SharedPtr<Peer> > _rootPeers; |