summaryrefslogtreecommitdiff
path: root/node/Peer.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-19 09:22:51 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-19 09:22:51 -0700
commit4c455876f92c629b015cbfc6d904dc8c2d12eca2 (patch)
treee3ac6cec45bc6f3d0576fb8e5eb62557716d1da9 /node/Peer.cpp
parentcecfa99b7bf13b8231a5a8141e723b57a8e5e3cd (diff)
downloadinfinitytier-4c455876f92c629b015cbfc6d904dc8c2d12eca2.tar.gz
infinitytier-4c455876f92c629b015cbfc6d904dc8c2d12eca2.zip
Revise peer path weighting to always prioritize cluster-optimal paths.
Diffstat (limited to 'node/Peer.cpp')
-rw-r--r--node/Peer.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 6c935e0a..ce4401cd 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -144,14 +144,17 @@ void Peer::received(
if (np < ZT_MAX_PEER_NETWORK_PATHS) {
slot = &(_paths[np++]);
} else {
- uint64_t slotLRmin = 0xffffffffffffffffULL;
+ uint64_t slotWorstScore = 0xffffffffffffffffULL;
for(unsigned int p=0;p<ZT_MAX_PEER_NETWORK_PATHS;++p) {
if (!_paths[p].active(now)) {
slot = &(_paths[p]);
break;
- } else if (_paths[p].lastReceived() <= slotLRmin) {
- slotLRmin = _paths[p].lastReceived();
- slot = &(_paths[p]);
+ } else {
+ const uint64_t score = _paths[p].score();
+ if (score <= slotWorstScore) {
+ slotWorstScore = score;
+ slot = &(_paths[p]);
+ }
}
}
}