Fix erroneous listpeers last send and receive values

This commit is contained in:
Joseph Henry 2021-08-04 12:16:26 -07:00
parent 613d7b5ece
commit 2053415418
No known key found for this signature in database
GPG Key ID: C45B33FF5EBC9344

View File

@ -393,7 +393,9 @@ static int cli(int argc,char **argv)
char tmp[256];
std::string addr = path["address"];
const int64_t now = OSUtils::now();
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%s;%lld;%lld",addr.c_str(),now - (int64_t)path["lastSend"],now - (int64_t)path["lastReceive"]);
int64_t lastSendDiff = (uint64_t)path["lastSend"] ? now - (uint64_t)path["lastSend"] : -1;
int64_t lastReceiveDiff = (uint64_t)path["lastReceive"] ? now - (uint64_t)path["lastReceive"] : -1;
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%s;%lld;%lld",addr.c_str(),lastSendDiff,lastReceiveDiff);
bestPath = tmp;
break;
}
@ -460,7 +462,9 @@ static int cli(int argc,char **argv)
char tmp[256];
std::string addr = path["address"];
const int64_t now = OSUtils::now();
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%-8lld %-8lld %s",now - (int64_t)path["lastSend"],now - (int64_t)path["lastReceive"],addr.c_str());
int64_t lastSendDiff = (uint64_t)path["lastSend"] ? now - (uint64_t)path["lastSend"] : -1;
int64_t lastReceiveDiff = (uint64_t)path["lastReceive"] ? now - (uint64_t)path["lastReceive"] : -1;
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%-8lld %-8lld %s",lastSendDiff,lastReceiveDiff,addr.c_str());
bestPath = std::string("DIRECT ") + tmp;
break;
}