@@ -760,19 +760,21 @@ const char* SINGLE_CONN = "single_conn";
760760const char * QUORUM_MEMBERS_CONN = " quorum_members_conn" ;
761761const char * IQR_MEMBERS_CONN = " iqr_members_conn" ;
762762const char * PROBE_CONN = " probe_conn" ;
763+ const char * CLEAR_CONN = " clear_conn" ;
763764
764765/* What essentially does is add a pending MN connection
765766 * Can be in the following forms:
766767 * 1) Direct single DMN connection.
767768 * 2) Quorum members connection (set of DMNs to connect).
768769 * 3) Quorum relay members connections (set of DMNs to connect and relay intra-quorum messages).
769770 * 4) Probe DMN connection.
771+ * 5) Clear tier two net connections cache
770772**/
771773UniValue mnconnect (const JSONRPCRequest& request)
772774{
773- if (request.fHelp || request.params .size () < 2 || request. params . size () > 4 ) {
775+ if (request.fHelp || request.params .size () > 4 ) {
774776 throw std::runtime_error (
775- " mnconnect \" op_type\" \" [pro_tx_hash, pro_tx_hash,..]\" ( llmq_type \" quorum_hash\" )\n "
777+ " mnconnect \" op_type\" ( \" [pro_tx_hash, pro_tx_hash,..]\" llmq_type \" quorum_hash\" )\n "
776778 " \n Add manual quorum members connections for internal testing purposes of the tier two p2p network layer\n "
777779 );
778780 }
@@ -781,7 +783,19 @@ UniValue mnconnect(const JSONRPCRequest& request)
781783 if (!chainparams.IsRegTestNet ())
782784 throw std::runtime_error (" mnconnect for regression testing (-regtest mode) only" );
783785
784- RPCTypeCheck (request.params , {UniValue::VSTR, UniValue::VARR});
786+ // Connection type
787+ RPCTypeCheck (request.params , {UniValue::VSTR});
788+ const std::string& op_type = request.params [0 ].get_str ();
789+
790+ // DMNs pro_tx list
791+ std::set<uint256> set_dmn_protxhash;
792+ if (request.params .size () > 1 ) {
793+ RPCTypeCheckArgument (request.params [1 ], UniValue::VARR);
794+ const auto & array{request.params [1 ].get_array ()};
795+ for (unsigned int i = 0 ; i < array.size (); i++) {
796+ set_dmn_protxhash.emplace (uint256S (array[i].get_str ()));
797+ }
798+ }
785799
786800 Consensus::LLMQType llmq_type = Consensus::LLMQ_NONE;
787801 if (request.params .size () > 2 ) {
@@ -795,15 +809,6 @@ UniValue mnconnect(const JSONRPCRequest& request)
795809 quorum_hash = uint256S (request.params [3 ].get_str ());
796810 }
797811
798- // First obtain the connection type
799- const std::string& op_type = request.params [0 ].get_str ();
800- // Check provided mn_list
801- const auto & array{request.params [1 ].get_array ()};
802- std::set<uint256> set_dmn_protxhash;
803- for (unsigned int i = 0 ; i < array.size (); i++) {
804- set_dmn_protxhash.emplace (uint256S (array[i].get_str ()));
805- }
806-
807812 const auto & mn_connan = g_connman->GetTierTwoConnMan ();
808813 if (op_type == SINGLE_CONN) {
809814 for (const auto & protxhash : set_dmn_protxhash) {
@@ -821,6 +826,9 @@ UniValue mnconnect(const JSONRPCRequest& request)
821826 } else if (op_type == PROBE_CONN) {
822827 mn_connan->addPendingProbeConnections (set_dmn_protxhash);
823828 return true ;
829+ } else if (op_type == CLEAR_CONN) {
830+ mn_connan->clear ();
831+ return true ;
824832 }
825833 return false ;
826834}
0 commit comments