mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Vote on IS only if it was accepted to mempool (#1826)
This commit is contained in:
parent
068b20bc70
commit
c9bafe1542
@ -122,15 +122,11 @@ bool CInstantSend::ProcessTxLockRequest(const CTxLockRequest& txLockRequest, CCo
|
|||||||
}
|
}
|
||||||
LogPrintf("CInstantSend::ProcessTxLockRequest -- accepted, txid=%s\n", txHash.ToString());
|
LogPrintf("CInstantSend::ProcessTxLockRequest -- accepted, txid=%s\n", txHash.ToString());
|
||||||
|
|
||||||
std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash);
|
|
||||||
CTxLockCandidate& txLockCandidate = itLockCandidate->second;
|
|
||||||
Vote(txLockCandidate, connman);
|
|
||||||
ProcessOrphanTxLockVotes(connman);
|
|
||||||
|
|
||||||
// Masternodes will sometimes propagate votes before the transaction is known to the client.
|
// Masternodes will sometimes propagate votes before the transaction is known to the client.
|
||||||
// If this just happened - lock inputs, resolve conflicting locks, update transaction status
|
// If this just happened - lock inputs, resolve conflicting locks, update transaction status
|
||||||
// forcing external script notification.
|
// forcing external script notification.
|
||||||
TryToFinalizeLockCandidate(txLockCandidate);
|
std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash);
|
||||||
|
TryToFinalizeLockCandidate(itLockCandidate->second);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -182,6 +178,18 @@ void CInstantSend::CreateEmptyTxLockCandidate(const uint256& txHash)
|
|||||||
mapTxLockCandidates.insert(std::make_pair(txHash, CTxLockCandidate(txLockRequest)));
|
mapTxLockCandidates.insert(std::make_pair(txHash, CTxLockCandidate(txLockRequest)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInstantSend::Vote(const uint256& txHash, CConnman& connman)
|
||||||
|
{
|
||||||
|
AssertLockHeld(cs_main);
|
||||||
|
LOCK(cs_instantsend);
|
||||||
|
|
||||||
|
std::map<uint256, CTxLockCandidate>::iterator itLockCandidate = mapTxLockCandidates.find(txHash);
|
||||||
|
if (itLockCandidate == mapTxLockCandidates.end()) return;
|
||||||
|
Vote(itLockCandidate->second, connman);
|
||||||
|
// Let's see if our vote changed smth
|
||||||
|
TryToFinalizeLockCandidate(itLockCandidate->second);
|
||||||
|
}
|
||||||
|
|
||||||
void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
|
void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
|
||||||
{
|
{
|
||||||
if(!fMasterNode) return;
|
if(!fMasterNode) return;
|
||||||
@ -190,6 +198,8 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
|
|||||||
LOCK2(cs_main, cs_instantsend);
|
LOCK2(cs_main, cs_instantsend);
|
||||||
|
|
||||||
uint256 txHash = txLockCandidate.GetHash();
|
uint256 txHash = txLockCandidate.GetHash();
|
||||||
|
// We should never vote on a Transaction Lock Request that was not (yet) accepted by the mempool
|
||||||
|
if(mapLockRequestAccepted.find(txHash) == mapLockRequestAccepted.end()) return;
|
||||||
// check if we need to vote on this candidate's outpoints,
|
// check if we need to vote on this candidate's outpoints,
|
||||||
// it's possible that we need to vote for several of them
|
// it's possible that we need to vote for several of them
|
||||||
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin();
|
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin();
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman);
|
void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman);
|
||||||
|
|
||||||
bool ProcessTxLockRequest(const CTxLockRequest& txLockRequest, CConnman& connman);
|
bool ProcessTxLockRequest(const CTxLockRequest& txLockRequest, CConnman& connman);
|
||||||
|
void Vote(const uint256& txHash, CConnman& connman);
|
||||||
|
|
||||||
bool AlreadyHave(const uint256& hash);
|
bool AlreadyHave(const uint256& hash);
|
||||||
|
|
||||||
|
@ -1635,6 +1635,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
LogPrintf("TXLOCKREQUEST -- Transaction Lock Request accepted, txid=%s, peer=%d\n",
|
LogPrintf("TXLOCKREQUEST -- Transaction Lock Request accepted, txid=%s, peer=%d\n",
|
||||||
tx.GetHash().ToString(), pfrom->id);
|
tx.GetHash().ToString(), pfrom->id);
|
||||||
instantsend.AcceptLockRequest(txLockRequest);
|
instantsend.AcceptLockRequest(txLockRequest);
|
||||||
|
instantsend.Vote(tx.GetHash(), connman);
|
||||||
}
|
}
|
||||||
|
|
||||||
mempool.check(pcoinsTip);
|
mempool.check(pcoinsTip);
|
||||||
|
Loading…
Reference in New Issue
Block a user