Downgrade TXLOCKREQUEST to TX when new IX system is active
The new system does not require explicit lock requests, so we downgrade TXLOCKREQUEST to TX and start propagating it instead of the original.
This commit is contained in:
parent
1959f3e4a5
commit
5ff4db0a05
@ -28,6 +28,7 @@
|
|||||||
#include "instantx.h"
|
#include "instantx.h"
|
||||||
#include "masternode-sync.h"
|
#include "masternode-sync.h"
|
||||||
#include "privatesend.h"
|
#include "privatesend.h"
|
||||||
|
#include "llmq/quorums_instantsend.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -2786,8 +2787,12 @@ bool CConnman::DisconnectNode(NodeId id)
|
|||||||
void CConnman::RelayTransaction(const CTransaction& tx)
|
void CConnman::RelayTransaction(const CTransaction& tx)
|
||||||
{
|
{
|
||||||
uint256 hash = tx.GetHash();
|
uint256 hash = tx.GetHash();
|
||||||
int nInv = static_cast<bool>(CPrivateSend::GetDSTX(hash)) ? MSG_DSTX :
|
int nInv = MSG_TX;
|
||||||
(instantsend.HasTxLockRequest(hash) ? MSG_TXLOCK_REQUEST : MSG_TX);
|
if (CPrivateSend::GetDSTX(hash)) {
|
||||||
|
nInv = MSG_DSTX;
|
||||||
|
} else if (llmq::IsOldInstantSendEnabled() && instantsend.HasTxLockRequest(hash)) {
|
||||||
|
nInv = MSG_TXLOCK_REQUEST;
|
||||||
|
}
|
||||||
CInv inv(nInv, hash);
|
CInv inv(nInv, hash);
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||||
|
@ -2015,11 +2015,16 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
if(strCommand == NetMsgType::TX) {
|
if(strCommand == NetMsgType::TX) {
|
||||||
vRecv >> ptx;
|
vRecv >> ptx;
|
||||||
txLockRequest = CTxLockRequest(ptx);
|
txLockRequest = CTxLockRequest(ptx);
|
||||||
fCanAutoLock = CInstantSend::CanAutoLock() && txLockRequest.IsSimple();
|
fCanAutoLock = llmq::IsOldInstantSendEnabled() && CInstantSend::CanAutoLock() && txLockRequest.IsSimple();
|
||||||
} else if(strCommand == NetMsgType::TXLOCKREQUEST) {
|
} else if(strCommand == NetMsgType::TXLOCKREQUEST) {
|
||||||
vRecv >> txLockRequest;
|
vRecv >> txLockRequest;
|
||||||
ptx = txLockRequest.tx;
|
ptx = txLockRequest.tx;
|
||||||
nInvType = MSG_TXLOCK_REQUEST;
|
nInvType = MSG_TXLOCK_REQUEST;
|
||||||
|
if (llmq::IsNewInstantSendEnabled()) {
|
||||||
|
// the new system does not require explicit lock requests
|
||||||
|
// changing the inv type to MSG_TX also results in re-broadcasting the TX as normal TX
|
||||||
|
nInvType = MSG_TX;
|
||||||
|
}
|
||||||
} else if (strCommand == NetMsgType::DSTX) {
|
} else if (strCommand == NetMsgType::DSTX) {
|
||||||
vRecv >> dstx;
|
vRecv >> dstx;
|
||||||
ptx = dstx.tx;
|
ptx = dstx.tx;
|
||||||
@ -2035,7 +2040,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process custom logic, no matter if tx will be accepted to mempool later or not
|
// Process custom logic, no matter if tx will be accepted to mempool later or not
|
||||||
if (strCommand == NetMsgType::TXLOCKREQUEST || fCanAutoLock) {
|
if (nInvType == MSG_TXLOCK_REQUEST || fCanAutoLock) {
|
||||||
if(!instantsend.ProcessTxLockRequest(txLockRequest, connman)) {
|
if(!instantsend.ProcessTxLockRequest(txLockRequest, connman)) {
|
||||||
LogPrint("instantsend", "TXLOCKREQUEST -- failed %s\n", txLockRequest.GetHash().ToString());
|
LogPrint("instantsend", "TXLOCKREQUEST -- failed %s\n", txLockRequest.GetHash().ToString());
|
||||||
// Should not really happen for "fCanAutoLock == true" but just in case:
|
// Should not really happen for "fCanAutoLock == true" but just in case:
|
||||||
@ -2046,7 +2051,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// Fallback for normal txes to process as usual
|
// Fallback for normal txes to process as usual
|
||||||
fCanAutoLock = false;
|
fCanAutoLock = false;
|
||||||
}
|
}
|
||||||
} else if (strCommand == NetMsgType::DSTX) {
|
} else if (nInvType == MSG_DSTX) {
|
||||||
uint256 hashTx = tx.GetHash();
|
uint256 hashTx = tx.GetHash();
|
||||||
if(CPrivateSend::GetDSTX(hashTx)) {
|
if(CPrivateSend::GetDSTX(hashTx)) {
|
||||||
LogPrint("privatesend", "DSTX -- Already have %s, skipping...\n", hashTx.ToString());
|
LogPrint("privatesend", "DSTX -- Already have %s, skipping...\n", hashTx.ToString());
|
||||||
@ -2083,11 +2088,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
|
|
||||||
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, ptx, true, &fMissingInputs)) {
|
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, ptx, true, &fMissingInputs)) {
|
||||||
// Process custom txes, this changes AlreadyHave to "true"
|
// Process custom txes, this changes AlreadyHave to "true"
|
||||||
if (strCommand == NetMsgType::DSTX) {
|
if (nInvType == MSG_DSTX) {
|
||||||
LogPrintf("DSTX -- Masternode transaction accepted, txid=%s, peer=%d\n",
|
LogPrintf("DSTX -- Masternode transaction accepted, txid=%s, peer=%d\n",
|
||||||
tx.GetHash().ToString(), pfrom->id);
|
tx.GetHash().ToString(), pfrom->id);
|
||||||
CPrivateSend::AddDSTX(dstx);
|
CPrivateSend::AddDSTX(dstx);
|
||||||
} else if (strCommand == NetMsgType::TXLOCKREQUEST || fCanAutoLock) {
|
} else if (nInvType == MSG_TXLOCK_REQUEST || fCanAutoLock) {
|
||||||
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);
|
||||||
@ -2208,7 +2213,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::TXLOCKREQUEST && !AlreadyHave(inv)) {
|
if (nInvType == MSG_TXLOCK_REQUEST && !AlreadyHave(inv)) {
|
||||||
// i.e. AcceptToMemoryPool failed, probably because it's conflicting
|
// i.e. AcceptToMemoryPool failed, probably because it's conflicting
|
||||||
// with existing normal tx or tx lock for another tx. For the same tx lock
|
// with existing normal tx or tx lock for another tx. For the same tx lock
|
||||||
// AlreadyHave would have return "true" already.
|
// AlreadyHave would have return "true" already.
|
||||||
|
Loading…
Reference in New Issue
Block a user