Skip to content

Commit 664a5d6

Browse files
UdjinM6CryptoCentric
authored andcommitted
Drop unnecessary AcceptToMemoryPool in PS (and corresponding cs-main locks), just relay what we have (dashpay#1922)
1 parent 1488853 commit 664a5d6

File tree

2 files changed

+4
-46
lines changed

2 files changed

+4
-46
lines changed

src/privatesend-client.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ bool CPrivateSendClient::SendDenominate(const std::vector<CTxDSIn>& vecTxDSIn, c
404404

405405
LogPrintf("CPrivateSendClient::SendDenominate -- Added transaction to pool.\n");
406406

407-
//check it against the memory pool to make sure it's valid
408407
{
409-
CValidationState validationState;
408+
// construct a pseudo tx, for debugging purpuses only
409+
410410
CMutableTransaction tx;
411411

412412
for (const auto& txdsin : vecTxDSIn) {
@@ -420,16 +420,6 @@ bool CPrivateSendClient::SendDenominate(const std::vector<CTxDSIn>& vecTxDSIn, c
420420
}
421421

422422
LogPrintf("CPrivateSendClient::SendDenominate -- Submitting partial tx %s", tx.ToString());
423-
424-
mempool.PrioritiseTransaction(tx.GetHash(), tx.GetHash().ToString(), 1000, 0.1*COIN);
425-
TRY_LOCK(cs_main, lockMain);
426-
if(!lockMain || !AcceptToMemoryPool(mempool, validationState, MakeTransactionRef(tx), false, NULL, false, maxTxFee, true)) {
427-
LogPrintf("CPrivateSendClient::SendDenominate -- AcceptToMemoryPool() failed! tx=%s", tx.ToString());
428-
UnlockCoins();
429-
keyHolderStorage.ReturnAll();
430-
SetNull();
431-
return false;
432-
}
433423
}
434424

435425
// store our entry for later use

src/privatesend-server.cpp

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,6 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm
212212
PushStatus(pfrom, STATUS_REJECTED, ERR_FEES, connman);
213213
return;
214214
}
215-
216-
{
217-
LOCK(cs_main);
218-
CValidationState validationState;
219-
mempool.PrioritiseTransaction(tx.GetHash(), tx.GetHash().ToString(), 1000, 0.1*COIN);
220-
if(!AcceptToMemoryPool(mempool, validationState, MakeTransactionRef(tx), false, NULL, false, maxTxFee, true)) {
221-
LogPrintf("DSVIN -- transaction not valid! tx=%s", tx.ToString());
222-
PushStatus(pfrom, STATUS_REJECTED, ERR_INVALID_TX, connman);
223-
return;
224-
}
225-
}
226215
}
227216

228217
PoolMessage nMessageID = MSG_NOERR;
@@ -443,16 +432,7 @@ void CPrivateSendServer::ChargeFees(CConnman& connman)
443432
LogPrintf("CPrivateSendServer::ChargeFees -- found uncooperative node (didn't %s transaction), charging fees: %s\n",
444433
(nState == POOL_STATE_SIGNING) ? "sign" : "send", vecOffendersCollaterals[0]->ToString());
445434

446-
LOCK(cs_main);
447-
448-
CValidationState state;
449-
bool fMissingInputs;
450-
if(!AcceptToMemoryPool(mempool, state, vecOffendersCollaterals[0], false, &fMissingInputs, false, maxTxFee)) {
451-
// should never really happen
452-
LogPrintf("CPrivateSendServer::ChargeFees -- ERROR: AcceptToMemoryPool failed!\n");
453-
} else {
454-
connman.RelayTransaction(*vecOffendersCollaterals[0]);
455-
}
435+
connman.RelayTransaction(*vecOffendersCollaterals[0]);
456436
}
457437
}
458438

@@ -472,22 +452,10 @@ void CPrivateSendServer::ChargeRandomFees(CConnman& connman)
472452
{
473453
if(!fMasternodeMode) return;
474454

475-
LOCK(cs_main);
476-
477455
for (const auto& txCollateral : vecSessionCollaterals) {
478-
479456
if(GetRandInt(100) > 10) return;
480-
481457
LogPrintf("CPrivateSendServer::ChargeRandomFees -- charging random fees, txCollateral=%s", txCollateral->ToString());
482-
483-
CValidationState state;
484-
bool fMissingInputs;
485-
if(!AcceptToMemoryPool(mempool, state, txCollateral, false, &fMissingInputs, false, maxTxFee)) {
486-
// should never really happen
487-
LogPrintf("CPrivateSendServer::ChargeRandomFees -- ERROR: AcceptToMemoryPool failed!\n");
488-
} else {
489-
connman.RelayTransaction(*txCollateral);
490-
}
458+
connman.RelayTransaction(*txCollateral);
491459
}
492460
}
493461

0 commit comments

Comments
 (0)