Add time_remaining to listbanned output
Example output:
hush-cli listbanned
[
{
"address": "1.2.3.4/255.255.255.255",
"banned_until": 1640921730,
"time_remaining": 86395
}
]
This commit is contained in:
@@ -635,6 +635,7 @@ UniValue listbanned(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
std::map<CSubNet, int64_t> banMap;
|
||||
CNode::GetBanned(banMap);
|
||||
const int64_t current_time{GetTime()};
|
||||
|
||||
UniValue bannedAddresses(UniValue::VARR);
|
||||
for (std::map<CSubNet, int64_t>::iterator it = banMap.begin(); it != banMap.end(); it++)
|
||||
@@ -642,6 +643,7 @@ UniValue listbanned(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
UniValue rec(UniValue::VOBJ);
|
||||
rec.push_back(Pair("address", (*it).first.ToString()));
|
||||
rec.push_back(Pair("banned_until", (*it).second));
|
||||
rec.push_back(Pair("time_remaining", (*it).second - current_time));
|
||||
bannedAddresses.push_back(rec);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user