@@ -873,23 +873,19 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
873873
874874 vecMasternodesUsed.push_back (dsq.vin .prevout );
875875
876- CNode* pnodeFound = NULL ;
877- bool fDisconnect = false ;
878- connman.ForNode (infoMn.addr , CConnman::AllNodes, [&pnodeFound, &fDisconnect ](CNode* pnode) {
879- pnodeFound = pnode;
880- if (pnodeFound->fDisconnect ) {
881- fDisconnect = true ;
882- } else {
883- pnodeFound->AddRef ();
884- }
876+ bool fSkip = false ;
877+ connman.ForNode (infoMn.addr , CConnman::AllNodes, [&fSkip ](CNode* pnode) {
878+ fSkip = pnode->fDisconnect || pnode->fMasternode ;
885879 return true ;
886880 });
887- if (fDisconnect )
881+ if (fSkip ) {
882+ LogPrintf (" CPrivateSendClient::JoinExistingQueue -- skipping masternode connection, addr=%s\n " , infoMn.addr .ToString ());
888883 continue ;
884+ }
889885
890886 LogPrintf (" CPrivateSendClient::JoinExistingQueue -- attempt to connect to masternode from queue, addr=%s\n " , infoMn.addr .ToString ());
891887 // connect to Masternode and submit the queue request
892- CNode* pnode = (pnodeFound && pnodeFound-> fMasternode ) ? pnodeFound : connman.ConnectNode (CAddress (infoMn.addr , NODE_NETWORK), NULL , true );
888+ CNode* pnode = connman.ConnectNode (CAddress (infoMn.addr , NODE_NETWORK), NULL , true );
893889 if (pnode) {
894890 infoMixingMasternode = infoMn;
895891 nSessionDenom = dsq.nDenom ;
@@ -900,9 +896,6 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
900896 strAutoDenomResult = _ (" Mixing in progress..." );
901897 SetState (POOL_STATE_QUEUE);
902898 nTimeLastSuccessfulStep = GetTimeMillis ();
903- if (pnodeFound) {
904- pnodeFound->Release ();
905- }
906899 return true ;
907900 } else {
908901 LogPrintf (" CPrivateSendClient::JoinExistingQueue -- can't connect, addr=%s\n " , infoMn.addr .ToString ());
@@ -947,24 +940,19 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA
947940 continue ;
948941 }
949942
950- CNode* pnodeFound = NULL ;
951- bool fDisconnect = false ;
952- connman.ForNode (infoMn.addr , CConnman::AllNodes, [&pnodeFound, &fDisconnect ](CNode* pnode) {
953- pnodeFound = pnode;
954- if (pnodeFound->fDisconnect ) {
955- fDisconnect = true ;
956- } else {
957- pnodeFound->AddRef ();
958- }
943+ bool fSkip = false ;
944+ connman.ForNode (infoMn.addr , CConnman::AllNodes, [&fSkip ](CNode* pnode) {
945+ fSkip = pnode->fDisconnect || pnode->fMasternode ;
959946 return true ;
960947 });
961- if (fDisconnect ) {
948+ if (fSkip ) {
949+ LogPrintf (" CPrivateSendClient::StartNewQueue -- skipping masternode connection, addr=%s\n " , infoMn.addr .ToString ());
962950 nTries++;
963951 continue ;
964952 }
965953
966954 LogPrintf (" CPrivateSendClient::StartNewQueue -- attempt %d connection to Masternode %s\n " , nTries, infoMn.addr .ToString ());
967- CNode* pnode = (pnodeFound && pnodeFound-> fMasternode ) ? pnodeFound : connman.ConnectNode (CAddress (infoMn.addr , NODE_NETWORK), NULL , true );
955+ CNode* pnode = connman.ConnectNode (CAddress (infoMn.addr , NODE_NETWORK), NULL , true );
968956 if (pnode) {
969957 LogPrintf (" CPrivateSendClient::StartNewQueue -- connected, addr=%s\n " , infoMn.addr .ToString ());
970958 infoMixingMasternode = infoMn;
@@ -982,9 +970,6 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA
982970 strAutoDenomResult = _ (" Mixing in progress..." );
983971 SetState (POOL_STATE_QUEUE);
984972 nTimeLastSuccessfulStep = GetTimeMillis ();
985- if (pnodeFound) {
986- pnodeFound->Release ();
987- }
988973 return true ;
989974 } else {
990975 LogPrintf (" CPrivateSendClient::StartNewQueue -- can't connect, addr=%s\n " , infoMn.addr .ToString ());
0 commit comments