@@ -921,6 +921,7 @@ static RPCHelpMan addpeeraddress()
921
921
{
922
922
{" address" , RPCArg::Type::STR, RPCArg::Optional::NO, " The IP address of the peer" },
923
923
{" port" , RPCArg::Type::NUM, RPCArg::Optional::NO, " The port of the peer" },
924
+ {" tried" , RPCArg::Type::BOOL, RPCArg::Default{false }, " If true, attempt to add the peer to the tried addresses table" },
924
925
},
925
926
RPCResult{
926
927
RPCResult::Type::OBJ, " " , " " ,
@@ -929,8 +930,8 @@ static RPCHelpMan addpeeraddress()
929
930
},
930
931
},
931
932
RPCExamples{
932
- HelpExampleCli (" addpeeraddress" , " \" 1.2.3.4\" 8333" )
933
- + HelpExampleRpc (" addpeeraddress" , " \" 1.2.3.4\" , 8333" )
933
+ HelpExampleCli (" addpeeraddress" , " \" 1.2.3.4\" 8333 true " )
934
+ + HelpExampleRpc (" addpeeraddress" , " \" 1.2.3.4\" , 8333, true " )
934
935
},
935
936
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
936
937
{
@@ -941,6 +942,7 @@ static RPCHelpMan addpeeraddress()
941
942
942
943
const std::string& addr_string{request.params [0 ].get_str ()};
943
944
const uint16_t port{static_cast <uint16_t >(request.params [1 ].get_int ())};
945
+ const bool tried{request.params [2 ].isTrue ()};
944
946
945
947
UniValue obj (UniValue::VOBJ);
946
948
CNetAddr net_addr;
@@ -951,7 +953,13 @@ static RPCHelpMan addpeeraddress()
951
953
address.nTime = GetAdjustedTime ();
952
954
// The source address is set equal to the address. This is equivalent to the peer
953
955
// announcing itself.
954
- if (node.addrman ->Add ({address}, address)) success = true ;
956
+ if (node.addrman ->Add ({address}, address)) {
957
+ success = true ;
958
+ if (tried) {
959
+ // Attempt to move the address to the tried addresses table.
960
+ node.addrman ->Good (address);
961
+ }
962
+ }
955
963
}
956
964
957
965
obj.pushKV (" success" , success);
0 commit comments