From dd3c8eaa3399b28dc78a883ff78cbe7cc5c31b5b Mon Sep 17 00:00:00 2001 From: Jarol Rodriguez Date: Tue, 6 Apr 2021 17:54:29 -0400 Subject: rpc: swap position of banned_until and ban_created fields A ban expires after its creation. Therefore, for the listbanned RPC, position banned_until after ban_created in help and output. --- src/rpc/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rpc/net.cpp') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 96533a50c8..41e5ea1c6c 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -750,8 +750,8 @@ static RPCHelpMan listbanned() {RPCResult::Type::OBJ, "", "", { {RPCResult::Type::STR, "address", ""}, - {RPCResult::Type::NUM_TIME, "banned_until", ""}, {RPCResult::Type::NUM_TIME, "ban_created", ""}, + {RPCResult::Type::NUM_TIME, "banned_until", ""}, }}, }}, RPCExamples{ @@ -774,8 +774,8 @@ static RPCHelpMan listbanned() const CBanEntry& banEntry = entry.second; UniValue rec(UniValue::VOBJ); rec.pushKV("address", entry.first.ToString()); - rec.pushKV("banned_until", banEntry.nBanUntil); rec.pushKV("ban_created", banEntry.nCreateTime); + rec.pushKV("banned_until", banEntry.nBanUntil); bannedAddresses.push_back(rec); } -- cgit v1.2.3 From c95c61657afd058b46549fb3d65633d7c736f5fc Mon Sep 17 00:00:00 2001 From: Jarol Rodriguez Date: Tue, 6 Apr 2021 18:18:52 -0400 Subject: doc: improve listbanned help Add descriptions for the address, ban_created, and banned_until fields. --- src/rpc/net.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/rpc/net.cpp') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 41e5ea1c6c..27ff6bcdaf 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -749,9 +749,9 @@ static RPCHelpMan listbanned() { {RPCResult::Type::OBJ, "", "", { - {RPCResult::Type::STR, "address", ""}, - {RPCResult::Type::NUM_TIME, "ban_created", ""}, - {RPCResult::Type::NUM_TIME, "banned_until", ""}, + {RPCResult::Type::STR, "address", "The IP/Subnet of the banned node"}, + {RPCResult::Type::NUM_TIME, "ban_created", "The " + UNIX_EPOCH_TIME + " the ban was created"}, + {RPCResult::Type::NUM_TIME, "banned_until", "The " + UNIX_EPOCH_TIME + " the ban expires"}, }}, }}, RPCExamples{ -- cgit v1.2.3 From 5456b345312857981cb426712f0665800c682e09 Mon Sep 17 00:00:00 2001 From: Jarol Rodriguez Date: Tue, 6 Apr 2021 23:01:10 -0400 Subject: rpc: add ban_duration field to listbanned --- src/rpc/net.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/rpc/net.cpp') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 27ff6bcdaf..b11138cacc 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -752,6 +752,7 @@ static RPCHelpMan listbanned() {RPCResult::Type::STR, "address", "The IP/Subnet of the banned node"}, {RPCResult::Type::NUM_TIME, "ban_created", "The " + UNIX_EPOCH_TIME + " the ban was created"}, {RPCResult::Type::NUM_TIME, "banned_until", "The " + UNIX_EPOCH_TIME + " the ban expires"}, + {RPCResult::Type::NUM_TIME, "ban_duration", "The ban duration, in seconds"}, }}, }}, RPCExamples{ @@ -776,6 +777,7 @@ static RPCHelpMan listbanned() rec.pushKV("address", entry.first.ToString()); rec.pushKV("ban_created", banEntry.nCreateTime); rec.pushKV("banned_until", banEntry.nBanUntil); + rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime)); bannedAddresses.push_back(rec); } -- cgit v1.2.3 From 3e978d1a5dbd43f85bd03e759984ab1f209d6e34 Mon Sep 17 00:00:00 2001 From: Jarol Rodriguez Date: Tue, 6 Apr 2021 23:45:31 -0400 Subject: rpc: add time_remaining field to listbanned --- src/rpc/net.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/rpc/net.cpp') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index b11138cacc..4826f091a6 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -753,6 +753,7 @@ static RPCHelpMan listbanned() {RPCResult::Type::NUM_TIME, "ban_created", "The " + UNIX_EPOCH_TIME + " the ban was created"}, {RPCResult::Type::NUM_TIME, "banned_until", "The " + UNIX_EPOCH_TIME + " the ban expires"}, {RPCResult::Type::NUM_TIME, "ban_duration", "The ban duration, in seconds"}, + {RPCResult::Type::NUM_TIME, "time_remaining", "The time remaining until the ban expires, in seconds"}, }}, }}, RPCExamples{ @@ -768,6 +769,7 @@ static RPCHelpMan listbanned() banmap_t banMap; node.banman->GetBanned(banMap); + const int64_t current_time{GetTime()}; UniValue bannedAddresses(UniValue::VARR); for (const auto& entry : banMap) @@ -778,6 +780,7 @@ static RPCHelpMan listbanned() rec.pushKV("ban_created", banEntry.nCreateTime); rec.pushKV("banned_until", banEntry.nBanUntil); rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime)); + rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time)); bannedAddresses.push_back(rec); } -- cgit v1.2.3