summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-02-06 17:20:22 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-02-06 17:20:22 -0800
commit723a9a6e9aa4254c7d740f9af6596ba8450924ac (patch)
treebaa22b5fdef2f686a8a244072970aeebeeaadf93 /node
parent59ba7c8bf5788edf248771f24cd4e7e14a67e162 (diff)
downloadinfinitytier-723a9a6e9aa4254c7d740f9af6596ba8450924ac.tar.gz
infinitytier-723a9a6e9aa4254c7d740f9af6596ba8450924ac.zip
Small additional efficiency improvement.
Diffstat (limited to 'node')
-rw-r--r--node/Membership.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/node/Membership.cpp b/node/Membership.cpp
index 5bb23a1a..6307b85d 100644
--- a/node/Membership.cpp
+++ b/node/Membership.cpp
@@ -52,8 +52,18 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,const uint64_t now
} else sendCap = (const Capability *)0;
} else sendCap = (const Capability *)0;
+ const Tag *sendTags[ZT_MAX_NETWORK_TAGS];
+ unsigned int sendTagCount = 0;
+ for(unsigned int t=0;t<nconf.tagCount;++t) {
+ if ( (_localTags[t].id != nconf.tags[t].id()) || ((now - _localTags[t].lastPushed) >= ZT_CREDENTIAL_PUSH_EVERY) || (force) ) {
+ _localTags[t].lastPushed = now;
+ _localTags[t].id = nconf.tags[t].id();
+ sendTags[sendTagCount++] = &(nconf.tags[t]);
+ }
+ }
+
unsigned int tagPtr = 0;
- while ((tagPtr < nconf.tagCount)||(sendCom)||(sendCap)) {
+ while ((tagPtr < sendTagCount)||(sendCom)||(sendCap)) {
Packet outp(peerAddress,RR->identity.address(),Packet::VERB_NETWORK_CREDENTIALS);
if (sendCom) {
@@ -72,11 +82,9 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,const uint64_t now
const unsigned int tagCountAt = outp.size();
outp.addSize(2);
unsigned int thisPacketTagCount = 0;
- while ((tagPtr < nconf.tagCount)&&((outp.size() + sizeof(Tag) + 32) < ZT_PROTO_MAX_PACKET_LENGTH)) {
+ while ((tagPtr < sendTagCount)&&((outp.size() + sizeof(Tag) + 32) < ZT_PROTO_MAX_PACKET_LENGTH)) {
if ( (_localTags[tagPtr].id != nconf.tags[tagPtr].id()) || ((now - _localTags[tagPtr].lastPushed) >= ZT_CREDENTIAL_PUSH_EVERY) || (force) ) {
- _localTags[tagPtr].lastPushed = now;
- _localTags[tagPtr].id = nconf.tags[tagPtr].id();
- nconf.tags[tagPtr].serialize(outp);
+ sendTags[tagPtr]->serialize(outp);
++thisPacketTagCount;
}
++tagPtr;