Skip to content

Commit

Permalink
Merge pull request #2334 from barton2526/listbanned
Browse files Browse the repository at this point in the history
rpc: add additional ban time fields to listbanned
  • Loading branch information
jamescowens authored Sep 17, 2021
2 parents 2a89710 + ec4c0bd commit 2ffbc06
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,18 @@ UniValue listbanned(const UniValue& params, bool fHelp)

banmap_t banMap;
g_banman->GetBanned(banMap);
const int64_t current_time{GetTime()};

UniValue bannedAddresses(UniValue::VARR);
for (const auto& entry : banMap)
{
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);
rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime));
rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time));
rec.pushKV("ban_reason", banEntry.banReasonToString());

bannedAddresses.push_back(rec);
Expand Down

0 comments on commit 2ffbc06

Please sign in to comment.