Skip to content

Commit 3e978d1

Browse files
committed
rpc: add time_remaining field to listbanned
1 parent 5456b34 commit 3e978d1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/rpc/net.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ static RPCHelpMan listbanned()
753753
{RPCResult::Type::NUM_TIME, "ban_created", "The " + UNIX_EPOCH_TIME + " the ban was created"},
754754
{RPCResult::Type::NUM_TIME, "banned_until", "The " + UNIX_EPOCH_TIME + " the ban expires"},
755755
{RPCResult::Type::NUM_TIME, "ban_duration", "The ban duration, in seconds"},
756+
{RPCResult::Type::NUM_TIME, "time_remaining", "The time remaining until the ban expires, in seconds"},
756757
}},
757758
}},
758759
RPCExamples{
@@ -768,6 +769,7 @@ static RPCHelpMan listbanned()
768769

769770
banmap_t banMap;
770771
node.banman->GetBanned(banMap);
772+
const int64_t current_time{GetTime()};
771773

772774
UniValue bannedAddresses(UniValue::VARR);
773775
for (const auto& entry : banMap)
@@ -778,6 +780,7 @@ static RPCHelpMan listbanned()
778780
rec.pushKV("ban_created", banEntry.nCreateTime);
779781
rec.pushKV("banned_until", banEntry.nBanUntil);
780782
rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime));
783+
rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time));
781784

782785
bannedAddresses.push_back(rec);
783786
}

0 commit comments

Comments
 (0)