mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
feat(rpc): Added RPC cleardiscouraged (#5273)
## Issue being fixed or feature implemented ## What was done? Added RPC `cleardiscouraged` which clears internally the list of discouraged peers. Note: Implementation of a `listdiscouraged` RPC is not possible because the internal data structure used for discouraged peers is a Bloom filter. ## How Has This Been Tested? ## Breaking Changes ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **For repository code-owners and collaborators only** - [x] I have assigned this pull request to a milestone
This commit is contained in:
parent
7f520f5c95
commit
5456be6780
5
doc/release-notes-5273.md
Normal file
5
doc/release-notes-5273.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Added RPCs
|
||||||
|
--------
|
||||||
|
|
||||||
|
- `cleardiscouraged` clears all the already discouraged peers.
|
||||||
|
|
@ -68,6 +68,16 @@ void BanMan::ClearBanned()
|
|||||||
if (m_client_interface) m_client_interface->BannedListChanged();
|
if (m_client_interface) m_client_interface->BannedListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BanMan::ClearDiscouraged()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
LOCK(m_cs_banned);
|
||||||
|
m_discouraged.reset();
|
||||||
|
m_is_dirty = true;
|
||||||
|
}
|
||||||
|
if (m_client_interface) m_client_interface->BannedListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
bool BanMan::IsDiscouraged(const CNetAddr& net_addr)
|
bool BanMan::IsDiscouraged(const CNetAddr& net_addr)
|
||||||
{
|
{
|
||||||
LOCK(m_cs_banned);
|
LOCK(m_cs_banned);
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
void Ban(const CSubNet& sub_net, int64_t ban_time_offset = 0, bool since_unix_epoch = false);
|
void Ban(const CSubNet& sub_net, int64_t ban_time_offset = 0, bool since_unix_epoch = false);
|
||||||
void Discourage(const CNetAddr& net_addr);
|
void Discourage(const CNetAddr& net_addr);
|
||||||
void ClearBanned();
|
void ClearBanned();
|
||||||
|
void ClearDiscouraged();
|
||||||
|
|
||||||
//! Return whether net_addr is banned
|
//! Return whether net_addr is banned
|
||||||
bool IsBanned(const CNetAddr& net_addr);
|
bool IsBanned(const CNetAddr& net_addr);
|
||||||
|
@ -736,6 +736,27 @@ static UniValue clearbanned(const JSONRPCRequest& request)
|
|||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static UniValue cleardiscouraged(const JSONRPCRequest& request)
|
||||||
|
{
|
||||||
|
RPCHelpMan{"cleardiscouraged",
|
||||||
|
"\nClear all discouraged nodes.\n",
|
||||||
|
{},
|
||||||
|
RPCResult{RPCResult::Type::NONE, "", ""},
|
||||||
|
RPCExamples{
|
||||||
|
HelpExampleCli("cleardiscouraged", "")
|
||||||
|
+ HelpExampleRpc("cleardiscouraged", "")
|
||||||
|
},
|
||||||
|
}.Check(request);
|
||||||
|
NodeContext& node = EnsureNodeContext(request.context);
|
||||||
|
if (!node.banman) {
|
||||||
|
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
node.banman->ClearDiscouraged();
|
||||||
|
|
||||||
|
return NullUniValue;
|
||||||
|
}
|
||||||
|
|
||||||
static UniValue setnetworkactive(const JSONRPCRequest& request)
|
static UniValue setnetworkactive(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
RPCHelpMan{"setnetworkactive",
|
RPCHelpMan{"setnetworkactive",
|
||||||
@ -825,6 +846,7 @@ static const CRPCCommand commands[] =
|
|||||||
{ "network", "setban", &setban, {"subnet", "command", "bantime", "absolute"} },
|
{ "network", "setban", &setban, {"subnet", "command", "bantime", "absolute"} },
|
||||||
{ "network", "listbanned", &listbanned, {} },
|
{ "network", "listbanned", &listbanned, {} },
|
||||||
{ "network", "clearbanned", &clearbanned, {} },
|
{ "network", "clearbanned", &clearbanned, {} },
|
||||||
|
{ "network", "cleardiscouraged", &cleardiscouraged, {} },
|
||||||
{ "network", "setnetworkactive", &setnetworkactive, {"state"} },
|
{ "network", "setnetworkactive", &setnetworkactive, {"state"} },
|
||||||
{ "network", "getnodeaddresses", &getnodeaddresses, {"count"} },
|
{ "network", "getnodeaddresses", &getnodeaddresses, {"count"} },
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user