|
|
@ -921,6 +921,7 @@ static RPCHelpMan addpeeraddress()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address of the peer"},
|
|
|
|
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address of the peer"},
|
|
|
|
{"port", RPCArg::Type::NUM, RPCArg::Optional::NO, "The port of the peer"},
|
|
|
|
{"port", RPCArg::Type::NUM, RPCArg::Optional::NO, "The port of the peer"},
|
|
|
|
|
|
|
|
{"tried", RPCArg::Type::BOOL, RPCArg::Default{false}, "If true, attempt to add the peer to the tried addresses table"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
RPCResult{
|
|
|
|
RPCResult{
|
|
|
|
RPCResult::Type::OBJ, "", "",
|
|
|
|
RPCResult::Type::OBJ, "", "",
|
|
|
@ -929,8 +930,8 @@ static RPCHelpMan addpeeraddress()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
RPCExamples{
|
|
|
|
RPCExamples{
|
|
|
|
HelpExampleCli("addpeeraddress", "\"1.2.3.4\" 8333")
|
|
|
|
HelpExampleCli("addpeeraddress", "\"1.2.3.4\" 8333 true")
|
|
|
|
+ HelpExampleRpc("addpeeraddress", "\"1.2.3.4\", 8333")
|
|
|
|
+ HelpExampleRpc("addpeeraddress", "\"1.2.3.4\", 8333, true")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
|
|
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -941,6 +942,7 @@ static RPCHelpMan addpeeraddress()
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& addr_string{request.params[0].get_str()};
|
|
|
|
const std::string& addr_string{request.params[0].get_str()};
|
|
|
|
const uint16_t port{static_cast<uint16_t>(request.params[1].get_int())};
|
|
|
|
const uint16_t port{static_cast<uint16_t>(request.params[1].get_int())};
|
|
|
|
|
|
|
|
const bool tried{request.params[2].isTrue()};
|
|
|
|
|
|
|
|
|
|
|
|
UniValue obj(UniValue::VOBJ);
|
|
|
|
UniValue obj(UniValue::VOBJ);
|
|
|
|
CNetAddr net_addr;
|
|
|
|
CNetAddr net_addr;
|
|
|
@ -951,7 +953,13 @@ static RPCHelpMan addpeeraddress()
|
|
|
|
address.nTime = GetAdjustedTime();
|
|
|
|
address.nTime = GetAdjustedTime();
|
|
|
|
// The source address is set equal to the address. This is equivalent to the peer
|
|
|
|
// The source address is set equal to the address. This is equivalent to the peer
|
|
|
|
// announcing itself.
|
|
|
|
// announcing itself.
|
|
|
|
if (node.addrman->Add({address}, address)) success = true;
|
|
|
|
if (node.addrman->Add({address}, address)) {
|
|
|
|
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
if (tried) {
|
|
|
|
|
|
|
|
// Attempt to move the address to the tried addresses table.
|
|
|
|
|
|
|
|
node.addrman->Good(address);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.pushKV("success", success);
|
|
|
|
obj.pushKV("success", success);
|
|
|
|