summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-12-17 11:03:39 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-12-17 11:03:39 -0800
commitaa39b0dc24b221980f72280af8c47d2a88a71b90 (patch)
tree2f52e7cfc334773765805cfbff989968bcd55c96
parent2160164e8c20d9e5cb5fb266ca69c040b7881252 (diff)
downloadinfinitytier-aa39b0dc24b221980f72280af8c47d2a88a71b90.tar.gz
infinitytier-aa39b0dc24b221980f72280af8c47d2a88a71b90.zip
Show paths as active or preferred in listpeers.
-rw-r--r--node/Path.hpp3
-rw-r--r--one.cpp12
2 files changed, 9 insertions, 6 deletions
diff --git a/node/Path.hpp b/node/Path.hpp
index c1fe68d4..c6de6612 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -266,6 +266,9 @@ public:
return (p - startAt);
}
+ inline bool operator==(const Path &p) const { return ((p._addr == _addr)&&(p._localAddress == _localAddress)); }
+ inline bool operator!=(const Path &p) const { return ((p._addr != _addr)||(p._localAddress != _localAddress)); }
+
private:
uint64_t _lastSend;
uint64_t _lastReceived;
diff --git a/one.cpp b/one.cpp
index deb0a398..d702fa62 100644
--- a/one.cpp
+++ b/one.cpp
@@ -366,8 +366,8 @@ static int cli(int argc,char **argv)
const char *paddr = (const char *)0;
int64_t lastSend = 0;
int64_t lastReceive = 0;
- bool fixed = false;
- bool active = false; // fixed/active/inactive
+ bool preferred = false;
+ bool active = false;
for(unsigned int kk=0;kk<jpath->u.object.length;++kk) {
if ((!strcmp(jpath->u.object.values[kk].name,"address"))&&(jpath->u.object.values[kk].value->type == json_string))
paddr = jpath->u.object.values[kk].value->u.string.ptr;
@@ -375,12 +375,12 @@ static int cli(int argc,char **argv)
lastSend = jpath->u.object.values[kk].value->u.integer;
else if ((!strcmp(jpath->u.object.values[kk].name,"lastReceive"))&&(jpath->u.object.values[kk].value->type == json_integer))
lastReceive = jpath->u.object.values[kk].value->u.integer;
- else if ((!strcmp(jpath->u.object.values[kk].name,"fixed"))&&(jpath->u.object.values[kk].value->type == json_boolean))
- fixed = (jpath->u.object.values[kk].value->u.boolean != 0);
+ else if ((!strcmp(jpath->u.object.values[kk].name,"preferred"))&&(jpath->u.object.values[kk].value->type == json_boolean))
+ preferred = (jpath->u.object.values[kk].value->u.boolean != 0);
else if ((!strcmp(jpath->u.object.values[kk].name,"active"))&&(jpath->u.object.values[kk].value->type == json_boolean))
active = (jpath->u.object.values[kk].value->u.boolean != 0);
}
- if ((paddr)&&((active)||(fixed))) {
+ if ((paddr)&&(active)) {
int64_t now = (int64_t)OSUtils::now();
if (lastSend > 0)
lastSend = now - lastSend;
@@ -391,7 +391,7 @@ static int cli(int argc,char **argv)
paddr,
lastSend,
lastReceive,
- (fixed ? "fixed" : (active ? "active" : "inactive")));
+ (preferred ? "preferred" : "active"));
if (paths.length())
paths.push_back(',');
paths.append(pathtmp);