@@ -873,23 +873,19 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
873
873
874
874
vecMasternodesUsed.push_back (dsq.vin .prevout );
875
875
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 ;
885
879
return true ;
886
880
});
887
- if (fDisconnect )
881
+ if (fSkip ) {
882
+ LogPrintf (" CPrivateSendClient::JoinExistingQueue -- skipping masternode connection, addr=%s\n " , infoMn.addr .ToString ());
888
883
continue ;
884
+ }
889
885
890
886
LogPrintf (" CPrivateSendClient::JoinExistingQueue -- attempt to connect to masternode from queue, addr=%s\n " , infoMn.addr .ToString ());
891
887
// 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 );
893
889
if (pnode) {
894
890
infoMixingMasternode = infoMn;
895
891
nSessionDenom = dsq.nDenom ;
@@ -900,9 +896,6 @@ bool CPrivateSendClient::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CCon
900
896
strAutoDenomResult = _ (" Mixing in progress..." );
901
897
SetState (POOL_STATE_QUEUE);
902
898
nTimeLastSuccessfulStep = GetTimeMillis ();
903
- if (pnodeFound) {
904
- pnodeFound->Release ();
905
- }
906
899
return true ;
907
900
} else {
908
901
LogPrintf (" CPrivateSendClient::JoinExistingQueue -- can't connect, addr=%s\n " , infoMn.addr .ToString ());
@@ -947,24 +940,19 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA
947
940
continue ;
948
941
}
949
942
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 ;
959
946
return true ;
960
947
});
961
- if (fDisconnect ) {
948
+ if (fSkip ) {
949
+ LogPrintf (" CPrivateSendClient::StartNewQueue -- skipping masternode connection, addr=%s\n " , infoMn.addr .ToString ());
962
950
nTries++;
963
951
continue ;
964
952
}
965
953
966
954
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 );
968
956
if (pnode) {
969
957
LogPrintf (" CPrivateSendClient::StartNewQueue -- connected, addr=%s\n " , infoMn.addr .ToString ());
970
958
infoMixingMasternode = infoMn;
@@ -982,9 +970,6 @@ bool CPrivateSendClient::StartNewQueue(CAmount nValueMin, CAmount nBalanceNeedsA
982
970
strAutoDenomResult = _ (" Mixing in progress..." );
983
971
SetState (POOL_STATE_QUEUE);
984
972
nTimeLastSuccessfulStep = GetTimeMillis ();
985
- if (pnodeFound) {
986
- pnodeFound->Release ();
987
- }
988
973
return true ;
989
974
} else {
990
975
LogPrintf (" CPrivateSendClient::StartNewQueue -- can't connect, addr=%s\n " , infoMn.addr .ToString ());
@@ -1002,13 +987,24 @@ bool CPrivateSendClient::SubmitDenominate(CConnman& connman)
1002
987
std::vector<CTxOut> vecTxOutRet;
1003
988
1004
989
// Submit transaction to the pool if we get here
1005
- // Try to use only inputs with the same number of rounds starting from the highest number of rounds possible
1006
- for (int i = nPrivateSendRounds; i > 0 ; i--) {
1007
- if (PrepareDenominate (i - 1 , i, strError, vecTxDSInRet, vecTxOutRet)) {
1008
- LogPrintf (" CPrivateSendClient::SubmitDenominate -- Running PrivateSend denominate for %d rounds, success\n " , i);
1009
- return SendDenominate (vecTxDSInRet, vecTxOutRet, connman);
990
+ if (nLiquidityProvider) {
991
+ // Try to use only inputs with the same number of rounds starting from the lowest number of rounds possible
992
+ for (int i = 0 ; i< nPrivateSendRounds; i++) {
993
+ if (PrepareDenominate (i, i + 1 , strError, vecTxDSInRet, vecTxOutRet)) {
994
+ LogPrintf (" CPrivateSendClient::SubmitDenominate -- Running PrivateSend denominate for %d rounds, success\n " , i);
995
+ return SendDenominate (vecTxDSInRet, vecTxOutRet, connman);
996
+ }
997
+ LogPrint (" privatesend" , " CPrivateSendClient::SubmitDenominate -- Running PrivateSend denominate for %d rounds, error: %s\n " , i, strError);
998
+ }
999
+ } else {
1000
+ // Try to use only inputs with the same number of rounds starting from the highest number of rounds possible
1001
+ for (int i = nPrivateSendRounds; i > 0 ; i--) {
1002
+ if (PrepareDenominate (i - 1 , i, strError, vecTxDSInRet, vecTxOutRet)) {
1003
+ LogPrintf (" CPrivateSendClient::SubmitDenominate -- Running PrivateSend denominate for %d rounds, success\n " , i);
1004
+ return SendDenominate (vecTxDSInRet, vecTxOutRet, connman);
1005
+ }
1006
+ LogPrint (" privatesend" , " CPrivateSendClient::SubmitDenominate -- Running PrivateSend denominate for %d rounds, error: %s\n " , i, strError);
1010
1007
}
1011
- LogPrint (" privatesend" , " CPrivateSendClient::SubmitDenominate -- Running PrivateSend denominate for %d rounds, error: %s\n " , i, strError);
1012
1008
}
1013
1009
1014
1010
// We failed? That's strange but let's just make final attempt and try to mix everything
@@ -1100,7 +1096,7 @@ bool CPrivateSendClient::PrepareDenominate(int nMinRounds, int nMaxRounds, std::
1100
1096
vecTxDSIn.erase (it);
1101
1097
vCoins.erase (it2);
1102
1098
1103
- CScript scriptDenom = keyHolderStorage.AddKey (pwalletMain). GetScriptForDestination () ;
1099
+ CScript scriptDenom = keyHolderStorage.AddKey (pwalletMain);
1104
1100
1105
1101
// add new output
1106
1102
CTxOut txout (nValueDenom, scriptDenom);
@@ -1276,7 +1272,7 @@ bool CPrivateSendClient::CreateDenominated(const CompactTallyItem& tallyItem, bo
1276
1272
// ****** Add an output for mixing collaterals ************ /
1277
1273
1278
1274
if (fCreateMixingCollaterals ) {
1279
- CScript scriptCollateral = keyHolderStorageDenom.AddKey (pwalletMain). GetScriptForDestination () ;
1275
+ CScript scriptCollateral = keyHolderStorageDenom.AddKey (pwalletMain);
1280
1276
vecSend.push_back ((CRecipient){ scriptCollateral, CPrivateSend::GetMaxCollateralAmount (), false });
1281
1277
nValueLeft -= CPrivateSend::GetMaxCollateralAmount ();
1282
1278
}
@@ -1311,7 +1307,7 @@ bool CPrivateSendClient::CreateDenominated(const CompactTallyItem& tallyItem, bo
1311
1307
1312
1308
// add each output up to 11 times until it can't be added again
1313
1309
while (nValueLeft - nDenomValue >= 0 && nOutputs <= 10 ) {
1314
- CScript scriptDenom = keyHolderStorageDenom.AddKey (pwalletMain). GetScriptForDestination () ;
1310
+ CScript scriptDenom = keyHolderStorageDenom.AddKey (pwalletMain);
1315
1311
1316
1312
vecSend.push_back ((CRecipient){ scriptDenom, nDenomValue, false });
1317
1313
0 commit comments