summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-01 12:25:43 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-01 12:25:43 -0700
commit53e5f94b996af73517940cb70d8bf8ca8c7b112f (patch)
treee73d5d86df978b09861ee2d032bd05548813689a
parent64bf3ffe6ccd0344c4bd86537ef285253e44b185 (diff)
downloadinfinitytier-53e5f94b996af73517940cb70d8bf8ca8c7b112f.tar.gz
infinitytier-53e5f94b996af73517940cb70d8bf8ca8c7b112f.zip
.
-rw-r--r--node/Peer.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/node/Peer.cpp b/node/Peer.cpp
index d98e0807..6d9b8cc7 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -67,24 +67,6 @@ Peer::Peer(const Identity &myIdentity,const Identity &peerIdentity)
throw std::runtime_error("new peer identity key agreement failed");
}
-struct _SortPathsByQuality
-{
- uint64_t _now;
- _SortPathsByQuality(const uint64_t now) : _now(now) {}
- inline bool operator()(const RemotePath &a,const RemotePath &b) const
- {
- const uint64_t qa = (
- ((uint64_t)a.active(_now) << 63) |
- (((uint64_t)(a.preferenceRank() & 0xfff)) << 51) |
- ((uint64_t)a.lastReceived() & 0x7ffffffffffffULL) );
- const uint64_t qb = (
- ((uint64_t)b.active(_now) << 63) |
- (((uint64_t)(b.preferenceRank() & 0xfff)) << 51) |
- ((uint64_t)b.lastReceived() & 0x7ffffffffffffULL) );
- return (qb < qa); // invert sense to sort in descending order
- }
-};
-
void Peer::received(
const RuntimeEnvironment *RR,
const InetAddress &localAddr,
@@ -511,6 +493,23 @@ void Peer::clean(const RuntimeEnvironment *RR,uint64_t now)
}
}
+struct _SortPathsByQuality
+{
+ uint64_t _now;
+ _SortPathsByQuality(const uint64_t now) : _now(now) {}
+ inline bool operator()(const RemotePath &a,const RemotePath &b) const
+ {
+ const uint64_t qa = (
+ ((uint64_t)a.active(_now) << 63) |
+ (((uint64_t)(a.preferenceRank() & 0xfff)) << 51) |
+ ((uint64_t)a.lastReceived() & 0x7ffffffffffffULL) );
+ const uint64_t qb = (
+ ((uint64_t)b.active(_now) << 63) |
+ (((uint64_t)(b.preferenceRank() & 0xfff)) << 51) |
+ ((uint64_t)b.lastReceived() & 0x7ffffffffffffULL) );
+ return (qb < qa); // invert sense to sort in descending order
+ }
+};
void Peer::_sortPaths(const uint64_t now)
{
// assumes _lock is locked