summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/Cluster.cpp2
-rw-r--r--node/Cluster.hpp15
-rw-r--r--node/Topology.cpp36
3 files changed, 51 insertions, 2 deletions
diff --git a/node/Cluster.cpp b/node/Cluster.cpp
index a2a99ecd..bd455933 100644
--- a/node/Cluster.cpp
+++ b/node/Cluster.cpp
@@ -239,7 +239,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
const MAC mac(dmsg.field(ptr,6),6); ptr += 6;
const uint32_t adi = dmsg.at<uint32_t>(ptr); ptr += 4;
RR->mc->add(RR->node->now(),nwid,MulticastGroup(mac,adi),address);
- TRACE("[%u] %s likes %s/%u on %.16llu",(unsigned int)fromMemberId,address.toString().c_str(),mac.toString().c_str(),(unsigned int)adi,nwid);
+ TRACE("[%u] %s likes %s/%.8x on %.16llu",(unsigned int)fromMemberId,address.toString().c_str(),mac.toString().c_str(),(unsigned int)adi,nwid);
} break;
case STATE_MESSAGE_COM: {
diff --git a/node/Cluster.hpp b/node/Cluster.hpp
index 080c9310..7d0c6a08 100644
--- a/node/Cluster.hpp
+++ b/node/Cluster.hpp
@@ -158,7 +158,20 @@ public:
* while PROXY_SEND is used to implement proxy sending (which right
* now is only used to send RENDEZVOUS).
*/
- STATE_MESSAGE_PROXY_SEND = 6
+ STATE_MESSAGE_PROXY_SEND = 6,
+
+ /**
+ * Replicate a network config for a network we belong to:
+ * <[8] 64-bit network ID>
+ * <[2] 16-bit length of network config>
+ * <[...] serialized network config>
+ *
+ * This is used by clusters to avoid every member having to query
+ * for the same netconf for networks all members belong to.
+ *
+ * TODO: not implemented yet!
+ */
+ STATE_MESSAGE_NETWORK_CONFIG = 7
};
/**
diff --git a/node/Topology.cpp b/node/Topology.cpp
index 6a72cf8c..49854f0e 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -215,10 +215,45 @@ SharedPtr<Peer> Topology::getBestRoot(const Address *avoid,unsigned int avoidCou
}
}
}
+
} else {
/* If I am not a root server, the best root server is the active one with
* the lowest latency. */
+ unsigned int bestLatencyOverall = ~((unsigned int)0);
+ unsigned int bestLatencyNotAvoid = ~((unsigned int)0);
+ const SharedPtr<Peer> *bestOverall = (const SharedPtr<Peer> *)0;
+ const SharedPtr<Peer> *bestNotAvoid = (const SharedPtr<Peer> *)0;
+
+ for(std::vector< SharedPtr<Peer> >::const_iterator r(_rootPeers.begin());r!=_rootPeers.end();++r) {
+ if ((*r)->hasActiveDirectPath(now)) {
+ bool avoiding = false;
+ for(unsigned int i=0;i<avoidCount;++i) {
+ if (avoid[i] == (*r)->address()) {
+ avoiding = true;
+ break;
+ }
+ }
+ unsigned int l = (*r)->latency();
+ if (!l) l = ~l; // zero latency indicates no measurment, so make this 'max'
+ if (l <= bestLatencyOverall) {
+ bestLatencyOverall = l;
+ bestOverall = &(*r);
+ }
+ if ((!avoiding)&&(l <= bestLatencyNotAvoid)) {
+ bestLatencyNotAvoid = l;
+ bestNotAvoid = &(*r);
+ }
+ }
+ }
+
+ if (bestNotAvoid)
+ return *bestNotAvoid;
+ else if ((!strictAvoid)&&(bestOverall))
+ return *bestOverall;
+ return SharedPtr<Peer>();
+
+ /*
unsigned int l,bestLatency = 65536;
uint64_t lds,ldr;
@@ -278,6 +313,7 @@ keep_searching_for_roots:
}
}
}
+ */
}
if (bestRoot)