@@ -450,7 +450,7 @@ std::string CDarksendPool::GetStatus()
450
450
showingDarkSendMessage += 10 ;
451
451
std::string suffix = " " ;
452
452
453
- if (chainActive. Tip () ->nHeight - cachedLastSuccess < minBlockSpacing || !masternodeSync.IsBlockchainSynced ()) {
453
+ if ((pCurrentBlockIndex && pCurrentBlockIndex ->nHeight - cachedLastSuccess < minBlockSpacing) || !masternodeSync.IsBlockchainSynced ()) {
454
454
return strAutoDenomResult;
455
455
}
456
456
switch (state) {
@@ -570,10 +570,10 @@ void CDarksendPool::CheckFinalTransaction()
570
570
571
571
CWalletTx txNew = CWalletTx (pwalletMain, finalTransaction);
572
572
573
- LOCK2 (cs_main, pwalletMain->cs_wallet );
574
- {
575
- LogPrint (" darksend" , " Transaction 2: %s\n " , txNew.ToString ());
573
+ LogPrint (" darksend" , " Transaction 2: %s\n " , txNew.ToString ());
576
574
575
+ {
576
+ LOCK (cs_main);
577
577
// See if the transaction is valid
578
578
if (!txNew.AcceptToMemoryPool (false , true ))
579
579
{
@@ -585,58 +585,57 @@ void CDarksendPool::CheckFinalTransaction()
585
585
RelayCompletedTransaction (sessionID, true , ERR_INVALID_TX);
586
586
return ;
587
587
}
588
+ }
589
+ LogPrintf (" CDarksendPool::Check() -- IS MASTER -- TRANSMITTING DARKSEND\n " );
588
590
589
- LogPrintf (" CDarksendPool::Check() -- IS MASTER -- TRANSMITTING DARKSEND\n " );
590
-
591
- // sign a message
591
+ // sign a message
592
592
593
- int64_t sigTime = GetAdjustedTime ();
594
- std::string strMessage = txNew.GetHash ().ToString () + boost::lexical_cast<std::string>(sigTime);
595
- std::string strError = " " ;
596
- std::vector<unsigned char > vchSig;
597
- CKey key2;
598
- CPubKey pubkey2;
593
+ int64_t sigTime = GetAdjustedTime ();
594
+ std::string strMessage = txNew.GetHash ().ToString () + boost::lexical_cast<std::string>(sigTime);
595
+ std::string strError = " " ;
596
+ std::vector<unsigned char > vchSig;
597
+ CKey key2;
598
+ CPubKey pubkey2;
599
599
600
- if (!darkSendSigner.SetKey (strMasterNodePrivKey, strError, key2, pubkey2))
601
- {
602
- LogPrintf (" CDarksendPool::Check() - ERROR: Invalid Masternodeprivkey: '%s'\n " , strError);
603
- return ;
604
- }
600
+ if (!darkSendSigner.SetKey (strMasterNodePrivKey, strError, key2, pubkey2))
601
+ {
602
+ LogPrintf (" CDarksendPool::Check() - ERROR: Invalid Masternodeprivkey: '%s'\n " , strError);
603
+ return ;
604
+ }
605
605
606
- if (!darkSendSigner.SignMessage (strMessage, strError, vchSig, key2)) {
607
- LogPrintf (" CDarksendPool::Check() - Sign message failed\n " );
608
- return ;
609
- }
606
+ if (!darkSendSigner.SignMessage (strMessage, strError, vchSig, key2)) {
607
+ LogPrintf (" CDarksendPool::Check() - Sign message failed\n " );
608
+ return ;
609
+ }
610
610
611
- if (!darkSendSigner.VerifyMessage (pubkey2, vchSig, strMessage, strError)) {
612
- LogPrintf (" CDarksendPool::Check() - Verify message failed\n " );
613
- return ;
614
- }
611
+ if (!darkSendSigner.VerifyMessage (pubkey2, vchSig, strMessage, strError)) {
612
+ LogPrintf (" CDarksendPool::Check() - Verify message failed\n " );
613
+ return ;
614
+ }
615
615
616
- if (!mapDarksendBroadcastTxes.count (txNew.GetHash ())){
617
- CDarksendBroadcastTx dstx;
618
- dstx.tx = txNew;
619
- dstx.vin = activeMasternode.vin ;
620
- dstx.vchSig = vchSig;
621
- dstx.sigTime = sigTime;
616
+ if (!mapDarksendBroadcastTxes.count (txNew.GetHash ())){
617
+ CDarksendBroadcastTx dstx;
618
+ dstx.tx = txNew;
619
+ dstx.vin = activeMasternode.vin ;
620
+ dstx.vchSig = vchSig;
621
+ dstx.sigTime = sigTime;
622
622
623
- mapDarksendBroadcastTxes.insert (make_pair (txNew.GetHash (), dstx));
624
- }
623
+ mapDarksendBroadcastTxes.insert (make_pair (txNew.GetHash (), dstx));
624
+ }
625
625
626
- CInv inv (MSG_DSTX, txNew.GetHash ());
627
- RelayInv (inv);
626
+ CInv inv (MSG_DSTX, txNew.GetHash ());
627
+ RelayInv (inv);
628
628
629
- // Tell the clients it was successful
630
- RelayCompletedTransaction (sessionID, false , MSG_SUCCESS);
629
+ // Tell the clients it was successful
630
+ RelayCompletedTransaction (sessionID, false , MSG_SUCCESS);
631
631
632
- // Randomly charge clients
633
- ChargeRandomFees ();
632
+ // Randomly charge clients
633
+ ChargeRandomFees ();
634
634
635
- // Reset
636
- LogPrint (" darksend" , " CDarksendPool::Check() -- COMPLETED -- RESETTING\n " );
637
- SetNull ();
638
- RelayStatus (sessionID, GetState (), GetEntriesCount (), MASTERNODE_RESET);
639
- }
635
+ // Reset
636
+ LogPrint (" darksend" , " CDarksendPool::Check() -- COMPLETED -- RESETTING\n " );
637
+ SetNull ();
638
+ RelayStatus (sessionID, GetState (), GetEntriesCount (), MASTERNODE_RESET);
640
639
}
641
640
642
641
//
@@ -1342,7 +1341,7 @@ void CDarksendPool::CompletedTransaction(bool error, int errorID)
1342
1341
SetNull ();
1343
1342
1344
1343
// To avoid race conditions, we'll only let DS run once per block
1345
- cachedLastSuccess = chainActive. Tip () ->nHeight ;
1344
+ cachedLastSuccess = pCurrentBlockIndex ->nHeight ;
1346
1345
}
1347
1346
lastMessage = GetMessageByID (errorID);
1348
1347
}
@@ -1361,6 +1360,9 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
1361
1360
{
1362
1361
if (!fEnableDarksend ) return false ;
1363
1362
if (fMasterNode ) return false ;
1363
+
1364
+ if (!pCurrentBlockIndex) return false ;
1365
+
1364
1366
if (state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false ;
1365
1367
if (GetEntriesCount () > 0 ) {
1366
1368
strAutoDenomResult = _ (" Mixing in progress..." );
@@ -1383,7 +1385,7 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
1383
1385
return false ;
1384
1386
}
1385
1387
1386
- if (!fDarksendMultiSession && chainActive. Tip () ->nHeight - cachedLastSuccess < minBlockSpacing) {
1388
+ if (!fDarksendMultiSession && pCurrentBlockIndex ->nHeight - cachedLastSuccess < minBlockSpacing) {
1387
1389
LogPrintf (" CDarksendPool::DoAutomaticDenominating - Last successful Darksend action was too recent\n " );
1388
1390
strAutoDenomResult = _ (" Last successful Darksend action was too recent." );
1389
1391
return false ;
@@ -1704,7 +1706,7 @@ bool CDarksendPool::MakeCollateralAmounts()
1704
1706
return false ;
1705
1707
}
1706
1708
1707
- cachedLastSuccess = chainActive. Tip () ->nHeight ;
1709
+ cachedLastSuccess = pCurrentBlockIndex ->nHeight ;
1708
1710
1709
1711
return true ;
1710
1712
}
@@ -1795,7 +1797,7 @@ bool CDarksendPool::CreateDenominated(CAmount nTotalValue)
1795
1797
1796
1798
// use the same cachedLastSuccess as for DS mixinx to prevent race
1797
1799
if (pwalletMain->CommitTransaction (wtx, reservekeyChange))
1798
- cachedLastSuccess = chainActive. Tip () ->nHeight ;
1800
+ cachedLastSuccess = pCurrentBlockIndex ->nHeight ;
1799
1801
else
1800
1802
LogPrintf (" CreateDenominated: CommitTransaction failed!\n " );
1801
1803
@@ -2198,6 +2200,15 @@ void CDarksendPool::RelayCompletedTransaction(const int sessionID, const bool er
2198
2200
pnode->PushMessage (NetMsgType::DSSTATUSUPDATE, sessionID, error, errorID);
2199
2201
}
2200
2202
2203
+ void CDarksendPool::UpdatedBlockTip (const CBlockIndex *pindex)
2204
+ {
2205
+ pCurrentBlockIndex = pindex;
2206
+ LogPrint (" darksend" , " pCurrentBlockIndex->nHeight: %d\n " , pCurrentBlockIndex->nHeight );
2207
+
2208
+ if (!fLiteMode && masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST)
2209
+ NewBlock ();
2210
+ }
2211
+
2201
2212
// TODO: Rename/move to core
2202
2213
void ThreadCheckDarkSendPool ()
2203
2214
{
0 commit comments