diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-07-23 10:23:55 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-07-23 10:23:55 -0700 |
commit | 0c7f8e247cc1469e7f8206693e4fe4909f8e0a38 (patch) | |
tree | 39651ad2158f54eae667e22db5e04435026d7005 /node/Topology.cpp | |
parent | b8e9a79d009411525c99b886b7af41bb4c650669 (diff) | |
download | infinitytier-0c7f8e247cc1469e7f8206693e4fe4909f8e0a38.tar.gz infinitytier-0c7f8e247cc1469e7f8206693e4fe4909f8e0a38.zip |
Add amSupernode to make code clearer in the check-if-self-is-supernode case.
Diffstat (limited to 'node/Topology.cpp')
-rw-r--r-- | node/Topology.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/node/Topology.cpp b/node/Topology.cpp index e627e767..43c5303e 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -39,7 +39,8 @@ namespace ZeroTier { Topology::Topology(const RuntimeEnvironment *renv,const char *dbpath) throw(std::runtime_error) : Thread(), - _r(renv) + _r(renv), + _amSupernode(false) { if (KISSDB_open(&_dbm,dbpath,KISSDB_OPEN_MODE_RWCREAT,ZT_KISSDB_HASH_TABLE_SIZE,ZT_KISSDB_KEY_SIZE,ZT_KISSDB_VALUE_SIZE)) { if (KISSDB_open(&_dbm,dbpath,KISSDB_OPEN_MODE_RWREPLACE,ZT_KISSDB_HASH_TABLE_SIZE,ZT_KISSDB_KEY_SIZE,ZT_KISSDB_VALUE_SIZE)) @@ -77,9 +78,11 @@ Topology::~Topology() void Topology::setSupernodes(const std::map< Identity,std::vector<InetAddress> > &sn) { Mutex::Lock _l(_supernodes_m); + _supernodes = sn; _supernodeAddresses.clear(); _supernodePeers.clear(); + for(std::map< Identity,std::vector<InetAddress> >::const_iterator i(sn.begin());i!=sn.end();++i) { if (i->first != _r->identity) { SharedPtr<Peer> p(getPeer(i->first.address())); @@ -93,6 +96,8 @@ void Topology::setSupernodes(const std::map< Identity,std::vector<InetAddress> > } _supernodeAddresses.insert(i->first.address()); } + + _amSupernode = (_supernodes.find(_r->identity) != _supernodes.end()); } void Topology::addPeer(const SharedPtr<Peer> &candidate,void (*callback)(void *,const SharedPtr<Peer> &,Topology::PeerVerifyResult),void *arg) |