diff options
author | Jarol Rodriguez <jarolrod@tutanota.com> | 2021-04-06 23:45:31 -0400 |
---|---|---|
committer | Jarol Rodriguez <jarolrod@tutanota.com> | 2021-04-06 23:45:31 -0400 |
commit | 3e978d1a5dbd43f85bd03e759984ab1f209d6e34 (patch) | |
tree | 71caef4c7d9f408858c8a99719b9e6a42d6bb27c /src | |
parent | 5456b345312857981cb426712f0665800c682e09 (diff) | |
download | bitcoin-3e978d1a5dbd43f85bd03e759984ab1f209d6e34.tar.xz |
rpc: add time_remaining field to listbanned
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/net.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
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); } |