Refactor IS - rename only (+related log messages) (#1146)
This commit is contained in:
parent
7a005a911e
commit
ce88ab3144
@ -2454,7 +2454,7 @@ void ThreadCheckDarkSendPool()
|
|||||||
mnodeman.CheckAndRemove();
|
mnodeman.CheckAndRemove();
|
||||||
mnodeman.ProcessMasternodeConnections();
|
mnodeman.ProcessMasternodeConnections();
|
||||||
mnpayments.CheckAndRemove();
|
mnpayments.CheckAndRemove();
|
||||||
CleanTransactionLocksList();
|
CleanTxLockCandidates();
|
||||||
}
|
}
|
||||||
|
|
||||||
darkSendPool.CheckTimeout();
|
darkSendPool.CheckTimeout();
|
||||||
|
216
src/instantx.cpp
216
src/instantx.cpp
@ -26,12 +26,12 @@ bool fEnableInstantSend = true;
|
|||||||
int nInstantSendDepth = DEFAULT_INSTANTSEND_DEPTH;
|
int nInstantSendDepth = DEFAULT_INSTANTSEND_DEPTH;
|
||||||
int nCompleteTXLocks;
|
int nCompleteTXLocks;
|
||||||
|
|
||||||
std::map<uint256, CTransaction> mapTxLockReq;
|
std::map<uint256, CTransaction> mapLockRequestAccepted;
|
||||||
std::map<uint256, CTransaction> mapTxLockReqRejected;
|
std::map<uint256, CTransaction> mapLockRequestRejected;
|
||||||
std::map<uint256, CConsensusVote> mapTxLockVote;
|
std::map<uint256, CTxLockVote> mapTxLockVotes;
|
||||||
std::map<COutPoint, uint256> mapLockedInputs;
|
std::map<COutPoint, uint256> mapLockedInputs;
|
||||||
|
|
||||||
std::map<uint256, CTransactionLock> mapTxLocks;
|
std::map<uint256, CTxLockCandidate> mapTxLockCandidates;
|
||||||
std::map<uint256, int64_t> mapUnknownVotes; //track votes with no tx for DOS
|
std::map<uint256, int64_t> mapUnknownVotes; //track votes with no tx for DOS
|
||||||
|
|
||||||
CCriticalSection cs_instantsend;
|
CCriticalSection cs_instantsend;
|
||||||
@ -65,7 +65,7 @@ void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStrea
|
|||||||
GetMainSignals().Inventory(inv.hash);
|
GetMainSignals().Inventory(inv.hash);
|
||||||
|
|
||||||
// have we seen it already?
|
// have we seen it already?
|
||||||
if(mapTxLockReq.count(inv.hash) || mapTxLockReqRejected.count(inv.hash)) return;
|
if(mapLockRequestAccepted.count(inv.hash) || mapLockRequestRejected.count(inv.hash)) return;
|
||||||
// is it a valid one?
|
// is it a valid one?
|
||||||
if(!IsInstantSendTxValid(tx)) return;
|
if(!IsInstantSendTxValid(tx)) return;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStrea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nBlockHeight = CreateNewLock(tx);
|
int nBlockHeight = CreateTxLockCandidate(tx);
|
||||||
|
|
||||||
bool fMissingInputs = false;
|
bool fMissingInputs = false;
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
@ -91,9 +91,9 @@ void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStrea
|
|||||||
if(fAccepted) {
|
if(fAccepted) {
|
||||||
RelayInv(inv);
|
RelayInv(inv);
|
||||||
|
|
||||||
DoConsensusVote(tx, nBlockHeight);
|
CreateTxLockVote(tx, nBlockHeight);
|
||||||
|
|
||||||
mapTxLockReq.insert(std::make_pair(tx.GetHash(), tx));
|
mapLockRequestAccepted.insert(std::make_pair(tx.GetHash(), tx));
|
||||||
|
|
||||||
LogPrintf("ProcessMessageInstantSend -- Transaction Lock Request: %s %s : accepted %s\n",
|
LogPrintf("ProcessMessageInstantSend -- Transaction Lock Request: %s %s : accepted %s\n",
|
||||||
pfrom->addr.ToString(), pfrom->cleanSubVer,
|
pfrom->addr.ToString(), pfrom->cleanSubVer,
|
||||||
@ -112,7 +112,7 @@ void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStrea
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mapTxLockReqRejected.insert(std::make_pair(tx.GetHash(), tx));
|
mapLockRequestRejected.insert(std::make_pair(tx.GetHash(), tx));
|
||||||
|
|
||||||
// can we get the conflicting transaction as proof?
|
// can we get the conflicting transaction as proof?
|
||||||
|
|
||||||
@ -129,28 +129,28 @@ void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStrea
|
|||||||
}
|
}
|
||||||
else if (strCommand == NetMsgType::TXLOCKVOTE) // InstantSend Transaction Lock Consensus Votes
|
else if (strCommand == NetMsgType::TXLOCKVOTE) // InstantSend Transaction Lock Consensus Votes
|
||||||
{
|
{
|
||||||
CConsensusVote vote;
|
CTxLockVote vote;
|
||||||
vRecv >> vote;
|
vRecv >> vote;
|
||||||
|
|
||||||
CInv inv(MSG_TXLOCK_VOTE, vote.GetHash());
|
CInv inv(MSG_TXLOCK_VOTE, vote.GetHash());
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
|
|
||||||
if(mapTxLockVote.count(vote.GetHash())) return;
|
if(mapTxLockVotes.count(vote.GetHash())) return;
|
||||||
mapTxLockVote.insert(std::make_pair(vote.GetHash(), vote));
|
mapTxLockVotes.insert(std::make_pair(vote.GetHash(), vote));
|
||||||
|
|
||||||
if(ProcessConsensusVote(pfrom, vote)) {
|
if(ProcessTxLockVote(pfrom, vote)) {
|
||||||
//Spam/Dos protection
|
//Spam/Dos protection
|
||||||
/*
|
/*
|
||||||
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.
|
||||||
This tracks those messages and allows it at the same rate of the rest of the network, if
|
This tracks those messages and allows it at the same rate of the rest of the network, if
|
||||||
a peer violates it, it will simply be ignored
|
a peer violates it, it will simply be ignored
|
||||||
*/
|
*/
|
||||||
if(!mapTxLockReq.count(vote.txHash) && !mapTxLockReqRejected.count(vote.txHash)) {
|
if(!mapLockRequestAccepted.count(vote.txHash) && !mapLockRequestRejected.count(vote.txHash)) {
|
||||||
if(!mapUnknownVotes.count(vote.vinMasternode.prevout.hash))
|
if(!mapUnknownVotes.count(vote.vinMasternode.prevout.hash))
|
||||||
mapUnknownVotes[vote.vinMasternode.prevout.hash] = GetTime()+(60*10);
|
mapUnknownVotes[vote.vinMasternode.prevout.hash] = GetTime()+(60*10);
|
||||||
|
|
||||||
if(mapUnknownVotes[vote.vinMasternode.prevout.hash] > GetTime() &&
|
if(mapUnknownVotes[vote.vinMasternode.prevout.hash] > GetTime() &&
|
||||||
mapUnknownVotes[vote.vinMasternode.prevout.hash] - GetAverageVoteTime() > 60*10) {
|
mapUnknownVotes[vote.vinMasternode.prevout.hash] - GetAverageUnknownVoteTime() > 60*10) {
|
||||||
LogPrintf("ProcessMessageInstantSend -- masternode is spamming transaction votes: %s %s\n",
|
LogPrintf("ProcessMessageInstantSend -- masternode is spamming transaction votes: %s %s\n",
|
||||||
vote.vinMasternode.ToString(),
|
vote.vinMasternode.ToString(),
|
||||||
vote.txHash.ToString()
|
vote.txHash.ToString()
|
||||||
@ -218,14 +218,14 @@ bool IsInstantSendTxValid(const CTransaction& txCandidate)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CreateNewLock(CTransaction tx)
|
int64_t CreateTxLockCandidate(CTransaction tx)
|
||||||
{
|
{
|
||||||
|
|
||||||
int64_t nTxAge = 0;
|
int64_t nTxAge = 0;
|
||||||
BOOST_REVERSE_FOREACH(CTxIn txin, tx.vin) {
|
BOOST_REVERSE_FOREACH(CTxIn txin, tx.vin) {
|
||||||
nTxAge = GetInputAge(txin);
|
nTxAge = GetInputAge(txin);
|
||||||
if(nTxAge < 5) { //1 less than the "send IX" gui requires, incase of a block propagating the network at the time
|
if(nTxAge < 5) { //1 less than the "send IX" gui requires, incase of a block propagating the network at the time
|
||||||
LogPrintf("CreateNewLock -- Transaction not found / too new: nTxAge=%d, txid=%s\n", nTxAge, tx.GetHash().ToString());
|
LogPrintf("CreateTxLockCandidate -- Transaction not found / too new: nTxAge=%d, txid=%s\n", nTxAge, tx.GetHash().ToString());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,19 +245,19 @@ int64_t CreateNewLock(CTransaction tx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mapTxLocks.count(tx.GetHash())) {
|
if(!mapTxLockCandidates.count(tx.GetHash())) {
|
||||||
LogPrintf("CreateNewLock -- New Transaction Lock! txid=%s\n", tx.GetHash().ToString());
|
LogPrintf("CreateTxLockCandidate -- New Transaction Lock Candidate! txid=%s\n", tx.GetHash().ToString());
|
||||||
|
|
||||||
CTransactionLock newLock;
|
CTxLockCandidate txLockCandidate;
|
||||||
newLock.nBlockHeight = nBlockHeight;
|
txLockCandidate.nBlockHeight = nBlockHeight;
|
||||||
//locks expire after nInstantSendKeepLock confirmations
|
//locks expire after nInstantSendKeepLock confirmations
|
||||||
newLock.nLockExpirationBlock = chainActive.Height() + Params().GetConsensus().nInstantSendKeepLock;
|
txLockCandidate.nExpirationBlock = chainActive.Height() + Params().GetConsensus().nInstantSendKeepLock;
|
||||||
newLock.nTimeout = GetTime()+(60*5);
|
txLockCandidate.nTimeout = GetTime()+(60*5);
|
||||||
newLock.txHash = tx.GetHash();
|
txLockCandidate.txHash = tx.GetHash();
|
||||||
mapTxLocks.insert(std::make_pair(tx.GetHash(), newLock));
|
mapTxLockCandidates.insert(std::make_pair(tx.GetHash(), txLockCandidate));
|
||||||
} else {
|
} else {
|
||||||
mapTxLocks[tx.GetHash()].nBlockHeight = nBlockHeight;
|
mapTxLockCandidates[tx.GetHash()].nBlockHeight = nBlockHeight;
|
||||||
LogPrint("instantsend", "CreateNewLock -- Transaction Lock Exists! txid=%s\n", tx.GetHash().ToString());
|
LogPrint("instantsend", "CreateTxLockCandidate -- Transaction Lock Candidate exists! txid=%s\n", tx.GetHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -266,43 +266,43 @@ int64_t CreateNewLock(CTransaction tx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if we need to vote on this transaction
|
// check if we need to vote on this transaction
|
||||||
void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
|
void CreateTxLockVote(CTransaction& tx, int64_t nBlockHeight)
|
||||||
{
|
{
|
||||||
if(!fMasterNode) return;
|
if(!fMasterNode) return;
|
||||||
|
|
||||||
int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
|
int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
|
||||||
|
|
||||||
if(n == -1) {
|
if(n == -1) {
|
||||||
LogPrint("instantsend", "DoConsensusVote -- Unknown Masternode %s\n", activeMasternode.vin.prevout.ToStringShort());
|
LogPrint("instantsend", "CreateTxLockVote -- Unknown Masternode %s\n", activeMasternode.vin.prevout.ToStringShort());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
|
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
|
||||||
LogPrint("instantsend", "DoConsensusVote -- Masternode not in the top %d (%d)\n", INSTANTSEND_SIGNATURES_TOTAL, n);
|
LogPrint("instantsend", "CreateTxLockVote -- Masternode not in the top %d (%d)\n", INSTANTSEND_SIGNATURES_TOTAL, n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
nBlockHeight calculated from the transaction is the authoritive source
|
nBlockHeight calculated from the transaction is the authoritive source
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LogPrint("instantsend", "DoConsensusVote -- In the top %d (%d)\n", INSTANTSEND_SIGNATURES_TOTAL, n);
|
LogPrint("instantsend", "CreateTxLockVote -- In the top %d (%d)\n", INSTANTSEND_SIGNATURES_TOTAL, n);
|
||||||
|
|
||||||
CConsensusVote vote;
|
CTxLockVote vote;
|
||||||
vote.vinMasternode = activeMasternode.vin;
|
vote.vinMasternode = activeMasternode.vin;
|
||||||
vote.txHash = tx.GetHash();
|
vote.txHash = tx.GetHash();
|
||||||
vote.nBlockHeight = nBlockHeight;
|
vote.nBlockHeight = nBlockHeight;
|
||||||
if(!vote.Sign()) {
|
if(!vote.Sign()) {
|
||||||
LogPrintf("DoConsensusVote -- Failed to sign consensus vote\n");
|
LogPrintf("CreateTxLockVote -- Failed to sign consensus vote\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!vote.CheckSignature()) {
|
if(!vote.CheckSignature()) {
|
||||||
LogPrintf("DoConsensusVote -- Signature invalid\n");
|
LogPrintf("CreateTxLockVote -- Signature invalid\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_instantsend);
|
LOCK(cs_instantsend);
|
||||||
mapTxLockVote[vote.GetHash()] = vote;
|
mapTxLockVotes[vote.GetHash()] = vote;
|
||||||
}
|
}
|
||||||
|
|
||||||
CInv inv(MSG_TXLOCK_VOTE, vote.GetHash());
|
CInv inv(MSG_TXLOCK_VOTE, vote.GetHash());
|
||||||
@ -310,73 +310,73 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//received a consensus vote
|
//received a consensus vote
|
||||||
bool ProcessConsensusVote(CNode* pnode, CConsensusVote& vote)
|
bool ProcessTxLockVote(CNode* pnode, CTxLockVote& vote)
|
||||||
{
|
{
|
||||||
int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
|
int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
|
||||||
|
|
||||||
CMasternode* pmn = mnodeman.Find(vote.vinMasternode);
|
CMasternode* pmn = mnodeman.Find(vote.vinMasternode);
|
||||||
if(pmn != NULL)
|
if(pmn != NULL)
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Masternode addr=%s, rank: %d\n", pmn->addr.ToString(), n);
|
LogPrint("instantsend", "ProcessTxLockVote -- Masternode addr=%s, rank: %d\n", pmn->addr.ToString(), n);
|
||||||
|
|
||||||
if(n == -1) {
|
if(n == -1) {
|
||||||
//can be caused by past versions trying to vote with an invalid protocol
|
//can be caused by past versions trying to vote with an invalid protocol
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Unknown Masternode: txin=%s\n", vote.vinMasternode.ToString());
|
LogPrint("instantsend", "ProcessTxLockVote -- Unknown Masternode: txin=%s\n", vote.vinMasternode.ToString());
|
||||||
mnodeman.AskForMN(pnode, vote.vinMasternode);
|
mnodeman.AskForMN(pnode, vote.vinMasternode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Masternode %s, rank=%d\n", vote.vinMasternode.prevout.ToStringShort(), n);
|
LogPrint("instantsend", "ProcessTxLockVote -- Masternode %s, rank=%d\n", vote.vinMasternode.prevout.ToStringShort(), n);
|
||||||
|
|
||||||
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
|
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Masternode %s is not in the top %d (%d), vote hash %s\n",
|
LogPrint("instantsend", "ProcessTxLockVote -- Masternode %s is not in the top %d (%d), vote hash %s\n",
|
||||||
vote.vinMasternode.prevout.ToStringShort(), INSTANTSEND_SIGNATURES_TOTAL, n, vote.GetHash().ToString());
|
vote.vinMasternode.prevout.ToStringShort(), INSTANTSEND_SIGNATURES_TOTAL, n, vote.GetHash().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!vote.CheckSignature()) {
|
if(!vote.CheckSignature()) {
|
||||||
LogPrintf("ProcessConsensusVote -- Signature invalid\n");
|
LogPrintf("ProcessTxLockVote -- Signature invalid\n");
|
||||||
// don't ban, it could just be a non-synced masternode
|
// don't ban, it could just be a non-synced masternode
|
||||||
mnodeman.AskForMN(pnode, vote.vinMasternode);
|
mnodeman.AskForMN(pnode, vote.vinMasternode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mapTxLocks.count(vote.txHash)) {
|
if (!mapTxLockCandidates.count(vote.txHash)) {
|
||||||
LogPrintf("ProcessConsensusVote -- New Transaction Lock! txid=%s\n", vote.txHash.ToString());
|
LogPrintf("ProcessTxLockVote -- New Transaction Lock Candidate! txid=%s\n", vote.txHash.ToString());
|
||||||
|
|
||||||
CTransactionLock newLock;
|
CTxLockCandidate txLockCandidate;
|
||||||
newLock.nBlockHeight = 0;
|
txLockCandidate.nBlockHeight = 0;
|
||||||
//locks expire after nInstantSendKeepLock confirmations
|
//locks expire after nInstantSendKeepLock confirmations
|
||||||
newLock.nLockExpirationBlock = chainActive.Height() + Params().GetConsensus().nInstantSendKeepLock;
|
txLockCandidate.nExpirationBlock = chainActive.Height() + Params().GetConsensus().nInstantSendKeepLock;
|
||||||
newLock.nTimeout = GetTime()+(60*5);
|
txLockCandidate.nTimeout = GetTime()+(60*5);
|
||||||
newLock.txHash = vote.txHash;
|
txLockCandidate.txHash = vote.txHash;
|
||||||
mapTxLocks.insert(std::make_pair(vote.txHash, newLock));
|
mapTxLockCandidates.insert(std::make_pair(vote.txHash, txLockCandidate));
|
||||||
} else {
|
} else {
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Transaction Lock Exists! txid=%s\n", vote.txHash.ToString());
|
LogPrint("instantsend", "ProcessTxLockVote -- Transaction Lock Exists! txid=%s\n", vote.txHash.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//compile consessus vote
|
//compile consessus vote
|
||||||
std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(vote.txHash);
|
std::map<uint256, CTxLockCandidate>::iterator i = mapTxLockCandidates.find(vote.txHash);
|
||||||
if (i != mapTxLocks.end()) {
|
if (i != mapTxLockCandidates.end()) {
|
||||||
(*i).second.AddVote(vote);
|
(*i).second.AddVote(vote);
|
||||||
|
|
||||||
int nSignatures = (*i).second.CountVotes();
|
int nSignatures = (*i).second.CountVotes();
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Transaction Lock signatures count: %d, vote hash=%s\n", nSignatures, vote.GetHash().ToString());
|
LogPrint("instantsend", "ProcessTxLockVote -- Transaction Lock signatures count: %d, vote hash=%s\n", nSignatures, vote.GetHash().ToString());
|
||||||
|
|
||||||
if(nSignatures >= INSTANTSEND_SIGNATURES_REQUIRED) {
|
if(nSignatures >= INSTANTSEND_SIGNATURES_REQUIRED) {
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Transaction Lock Is Complete! txid=%s\n", vote.txHash.ToString());
|
LogPrint("instantsend", "ProcessTxLockVote -- Transaction Lock Is Complete! txid=%s\n", vote.txHash.ToString());
|
||||||
|
|
||||||
// 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,
|
||||||
// will check for conflicting locks and update transaction status on a new vote message
|
// will check for conflicting locks and update transaction status on a new vote message
|
||||||
// only after the lock itself has arrived
|
// only after the lock itself has arrived
|
||||||
if(!mapTxLockReq.count(vote.txHash) && !mapTxLockReqRejected.count(vote.txHash)) return true;
|
if(!mapLockRequestAccepted.count(vote.txHash) && !mapLockRequestRejected.count(vote.txHash)) return true;
|
||||||
|
|
||||||
if(!FindConflictingLocks(mapTxLockReq[vote.txHash])) { //?????
|
if(!FindConflictingLocks(mapLockRequestAccepted[vote.txHash])) { //?????
|
||||||
if(mapTxLockReq.count(vote.txHash)) {
|
if(mapLockRequestAccepted.count(vote.txHash)) {
|
||||||
UpdateLockedTransaction(mapTxLockReq[vote.txHash]);
|
UpdateLockedTransaction(mapLockRequestAccepted[vote.txHash]);
|
||||||
LockTransactionInputs(mapTxLockReq[vote.txHash]);
|
LockTransactionInputs(mapLockRequestAccepted[vote.txHash]);
|
||||||
} else if(mapTxLockReqRejected.count(vote.txHash)) {
|
} else if(mapLockRequestRejected.count(vote.txHash)) {
|
||||||
ResolveConflicts(mapTxLockReqRejected[vote.txHash]); ///?????
|
ResolveConflicts(mapLockRequestRejected[vote.txHash]); ///?????
|
||||||
} else {
|
} else {
|
||||||
LogPrint("instantsend", "ProcessConsensusVote -- Transaction Lock Request is missing! nSignatures=%d, vote hash %s\n", nSignatures, vote.GetHash().ToString());
|
LogPrint("instantsend", "ProcessTxLockVote -- Transaction Lock Request is missing! nSignatures=%d, vote hash %s\n", nSignatures, vote.GetHash().ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification)
|
|||||||
if(FindConflictingLocks(tx)) return;
|
if(FindConflictingLocks(tx)) return;
|
||||||
uint256 txHash = tx.GetHash();
|
uint256 txHash = tx.GetHash();
|
||||||
// there must be a successfully verified lock request
|
// there must be a successfully verified lock request
|
||||||
if(!mapTxLockReq.count(txHash)) return;
|
if(!mapLockRequestAccepted.count(txHash)) return;
|
||||||
|
|
||||||
int nSignatures = GetTransactionLockSignatures(txHash);
|
int nSignatures = GetTransactionLockSignatures(txHash);
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LockTransactionInputs(CTransaction& tx) {
|
void LockTransactionInputs(CTransaction& tx) {
|
||||||
if(!mapTxLockReq.count(tx.GetHash())) return;
|
if(!mapLockRequestAccepted.count(tx.GetHash())) return;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||||
if(!mapLockedInputs.count(txin.prevout))
|
if(!mapLockedInputs.count(txin.prevout))
|
||||||
@ -439,11 +439,11 @@ bool FindConflictingLocks(CTransaction& tx)
|
|||||||
if(mapLockedInputs[txin.prevout] != tx.GetHash()) {
|
if(mapLockedInputs[txin.prevout] != tx.GetHash()) {
|
||||||
LogPrintf("FindConflictingLocks -- found two complete conflicting Transaction Locks, removing both: txid=%s, txin=%s", tx.GetHash().ToString(), mapLockedInputs[txin.prevout].ToString());
|
LogPrintf("FindConflictingLocks -- found two complete conflicting Transaction Locks, removing both: txid=%s, txin=%s", tx.GetHash().ToString(), mapLockedInputs[txin.prevout].ToString());
|
||||||
|
|
||||||
if(mapTxLocks.count(tx.GetHash()))
|
if(mapTxLockCandidates.count(tx.GetHash()))
|
||||||
mapTxLocks[tx.GetHash()].nLockExpirationBlock = -1;
|
mapTxLockCandidates[tx.GetHash()].nExpirationBlock = -1;
|
||||||
|
|
||||||
if(mapTxLocks.count(mapLockedInputs[txin.prevout]))
|
if(mapTxLockCandidates.count(mapLockedInputs[txin.prevout]))
|
||||||
mapTxLocks[mapLockedInputs[txin.prevout]].nLockExpirationBlock = -1;
|
mapTxLockCandidates[mapLockedInputs[txin.prevout]].nExpirationBlock = -1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -461,12 +461,12 @@ void ResolveConflicts(CTransaction& tx)
|
|||||||
|
|
||||||
//reprocess the last nInstantSendReprocessBlocks blocks
|
//reprocess the last nInstantSendReprocessBlocks blocks
|
||||||
ReprocessBlocks(Params().GetConsensus().nInstantSendReprocessBlocks);
|
ReprocessBlocks(Params().GetConsensus().nInstantSendReprocessBlocks);
|
||||||
if(!mapTxLockReq.count(tx.GetHash()))
|
if(!mapLockRequestAccepted.count(tx.GetHash()))
|
||||||
mapTxLockReq.insert(std::make_pair(tx.GetHash(), tx)); //?????
|
mapLockRequestAccepted.insert(std::make_pair(tx.GetHash(), tx)); //?????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetAverageVoteTime()
|
int64_t GetAverageUnknownVoteTime()
|
||||||
{
|
{
|
||||||
std::map<uint256, int64_t>::iterator it = mapUnknownVotes.begin();
|
std::map<uint256, int64_t>::iterator it = mapUnknownVotes.begin();
|
||||||
int64_t total = 0;
|
int64_t total = 0;
|
||||||
@ -481,33 +481,33 @@ int64_t GetAverageVoteTime()
|
|||||||
return total / count;
|
return total / count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanTransactionLocksList()
|
void CleanTxLockCandidates()
|
||||||
{
|
{
|
||||||
LOCK(cs_instantsend);
|
LOCK(cs_instantsend);
|
||||||
|
|
||||||
std::map<uint256, CTransactionLock>::iterator it = mapTxLocks.begin();
|
std::map<uint256, CTxLockCandidate>::iterator it = mapTxLockCandidates.begin();
|
||||||
|
|
||||||
int nHeight = chainActive.Height();
|
int nHeight = chainActive.Height();
|
||||||
while(it != mapTxLocks.end()) {
|
while(it != mapTxLockCandidates.end()) {
|
||||||
CTransactionLock &txLock = it->second;
|
CTxLockCandidate &txLockCandidate = it->second;
|
||||||
if(nHeight > txLock.nLockExpirationBlock) {
|
if(nHeight > txLockCandidate.nExpirationBlock) {
|
||||||
LogPrintf("Removing old transaction lock: txid=%s\n", txLock.txHash.ToString());
|
LogPrintf("CleanTxLockCandidates -- Removing expired Transaction Lock Candidate for txid %s\n", txLockCandidate.txHash.ToString());
|
||||||
|
|
||||||
if(mapTxLockReq.count(txLock.txHash)){
|
if(mapLockRequestAccepted.count(txLockCandidate.txHash)){
|
||||||
CTransaction& tx = mapTxLockReq[txLock.txHash];
|
CTransaction& tx = mapLockRequestAccepted[txLockCandidate.txHash];
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||||
mapLockedInputs.erase(txin.prevout);
|
mapLockedInputs.erase(txin.prevout);
|
||||||
|
|
||||||
mapTxLockReq.erase(txLock.txHash);
|
mapLockRequestAccepted.erase(txLockCandidate.txHash);
|
||||||
mapTxLockReqRejected.erase(txLock.txHash);
|
mapLockRequestRejected.erase(txLockCandidate.txHash);
|
||||||
|
|
||||||
BOOST_FOREACH(const CConsensusVote& vote, txLock.vecConsensusVotes)
|
BOOST_FOREACH(const CTxLockVote& vote, txLockCandidate.vecTxLockVotes)
|
||||||
if(mapTxLockVote.count(vote.GetHash()))
|
if(mapTxLockVotes.count(vote.GetHash()))
|
||||||
mapTxLockVote.erase(vote.GetHash());
|
mapTxLockVotes.erase(vote.GetHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
mapTxLocks.erase(it++);
|
mapTxLockCandidates.erase(it++);
|
||||||
} else {
|
} else {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
@ -517,10 +517,10 @@ void CleanTransactionLocksList()
|
|||||||
bool IsLockedInstandSendTransaction(uint256 txHash)
|
bool IsLockedInstandSendTransaction(uint256 txHash)
|
||||||
{
|
{
|
||||||
// there must be a successfully verified lock request...
|
// there must be a successfully verified lock request...
|
||||||
if (!mapTxLockReq.count(txHash)) return false;
|
if (!mapLockRequestAccepted.count(txHash)) return false;
|
||||||
// ...and corresponding lock must have enough signatures
|
// ...and corresponding lock must have enough signatures
|
||||||
std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(txHash);
|
std::map<uint256, CTxLockCandidate>::iterator i = mapTxLockCandidates.find(txHash);
|
||||||
return i != mapTxLocks.end() && (*i).second.CountVotes() >= INSTANTSEND_SIGNATURES_REQUIRED;
|
return i != mapTxLockCandidates.end() && (*i).second.CountVotes() >= INSTANTSEND_SIGNATURES_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetTransactionLockSignatures(uint256 txHash)
|
int GetTransactionLockSignatures(uint256 txHash)
|
||||||
@ -529,8 +529,8 @@ int GetTransactionLockSignatures(uint256 txHash)
|
|||||||
if(fLargeWorkForkFound || fLargeWorkInvalidChainFound) return -2;
|
if(fLargeWorkForkFound || fLargeWorkInvalidChainFound) return -2;
|
||||||
if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return -3;
|
if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return -3;
|
||||||
|
|
||||||
std::map<uint256, CTransactionLock>::iterator it = mapTxLocks.find(txHash);
|
std::map<uint256, CTxLockCandidate>::iterator it = mapTxLockCandidates.find(txHash);
|
||||||
if(it != mapTxLocks.end()) return it->second.CountVotes();
|
if(it != mapTxLockCandidates.end()) return it->second.CountVotes();
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -539,19 +539,19 @@ bool IsTransactionLockTimedOut(uint256 txHash)
|
|||||||
{
|
{
|
||||||
if(!fEnableInstantSend) return 0;
|
if(!fEnableInstantSend) return 0;
|
||||||
|
|
||||||
std::map<uint256, CTransactionLock>::iterator i = mapTxLocks.find(txHash);
|
std::map<uint256, CTxLockCandidate>::iterator i = mapTxLockCandidates.find(txHash);
|
||||||
if (i != mapTxLocks.end()) return GetTime() > (*i).second.nTimeout;
|
if (i != mapTxLockCandidates.end()) return GetTime() > (*i).second.nTimeout;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 CConsensusVote::GetHash() const
|
uint256 CTxLockVote::GetHash() const
|
||||||
{
|
{
|
||||||
return ArithToUint256(UintToArith256(vinMasternode.prevout.hash) + vinMasternode.prevout.n + UintToArith256(txHash));
|
return ArithToUint256(UintToArith256(vinMasternode.prevout.hash) + vinMasternode.prevout.n + UintToArith256(txHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CConsensusVote::CheckSignature()
|
bool CTxLockVote::CheckSignature()
|
||||||
{
|
{
|
||||||
std::string strError;
|
std::string strError;
|
||||||
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
|
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
|
||||||
@ -559,31 +559,31 @@ bool CConsensusVote::CheckSignature()
|
|||||||
CMasternode* pmn = mnodeman.Find(vinMasternode);
|
CMasternode* pmn = mnodeman.Find(vinMasternode);
|
||||||
|
|
||||||
if(pmn == NULL) {
|
if(pmn == NULL) {
|
||||||
LogPrintf("CConsensusVote::CheckSignature -- Unknown Masternode: txin=%s\n", vinMasternode.ToString());
|
LogPrintf("CTxLockVote::CheckSignature -- Unknown Masternode: txin=%s\n", vinMasternode.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!darkSendSigner.VerifyMessage(pmn->pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) {
|
if(!darkSendSigner.VerifyMessage(pmn->pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) {
|
||||||
LogPrintf("CConsensusVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConsensusVote::Sign()
|
bool CTxLockVote::Sign()
|
||||||
{
|
{
|
||||||
std::string strError;
|
std::string strError;
|
||||||
|
|
||||||
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
|
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
|
||||||
|
|
||||||
if(!darkSendSigner.SignMessage(strMessage, vchMasterNodeSignature, activeMasternode.keyMasternode)) {
|
if(!darkSendSigner.SignMessage(strMessage, vchMasterNodeSignature, activeMasternode.keyMasternode)) {
|
||||||
LogPrintf("CConsensusVote::Sign -- SignMessage() failed\n");
|
LogPrintf("CTxLockVote::Sign -- SignMessage() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) {
|
if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) {
|
||||||
LogPrintf("CConsensusVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
LogPrintf("CTxLockVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,25 +591,25 @@ bool CConsensusVote::Sign()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CTransactionLock::IsAllVotesValid()
|
bool CTxLockCandidate::IsAllVotesValid()
|
||||||
{
|
{
|
||||||
|
|
||||||
BOOST_FOREACH(CConsensusVote vote, vecConsensusVotes)
|
BOOST_FOREACH(CTxLockVote vote, vecTxLockVotes)
|
||||||
{
|
{
|
||||||
int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
|
int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
|
||||||
|
|
||||||
if(n == -1) {
|
if(n == -1) {
|
||||||
LogPrintf("CTransactionLock::IsAllVotesValid -- Unknown Masternode, txin=%s\n", vote.vinMasternode.ToString());
|
LogPrintf("CTxLockCandidate::IsAllVotesValid -- Unknown Masternode, txin=%s\n", vote.vinMasternode.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
|
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
|
||||||
LogPrintf("CTransactionLock::IsAllVotesValid -- Masternode not in the top %s\n", INSTANTSEND_SIGNATURES_TOTAL);
|
LogPrintf("CTxLockCandidate::IsAllVotesValid -- Masternode not in the top %s\n", INSTANTSEND_SIGNATURES_TOTAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!vote.CheckSignature()) {
|
if(!vote.CheckSignature()) {
|
||||||
LogPrintf("CTransactionLock::IsAllVotesValid -- Signature not valid\n");
|
LogPrintf("CTxLockCandidate::IsAllVotesValid -- Signature not valid\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -617,12 +617,12 @@ bool CTransactionLock::IsAllVotesValid()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTransactionLock::AddVote(CConsensusVote& vote)
|
void CTxLockCandidate::AddVote(CTxLockVote& vote)
|
||||||
{
|
{
|
||||||
vecConsensusVotes.push_back(vote);
|
vecTxLockVotes.push_back(vote);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CTransactionLock::CountVotes()
|
int CTxLockCandidate::CountVotes()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Only count signatures where the BlockHeight matches the transaction's blockheight.
|
Only count signatures where the BlockHeight matches the transaction's blockheight.
|
||||||
@ -632,7 +632,7 @@ int CTransactionLock::CountVotes()
|
|||||||
if(nBlockHeight == 0) return -1;
|
if(nBlockHeight == 0) return -1;
|
||||||
|
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
BOOST_FOREACH(CConsensusVote vote, vecConsensusVotes)
|
BOOST_FOREACH(CTxLockVote vote, vecTxLockVotes)
|
||||||
if(vote.nBlockHeight == nBlockHeight)
|
if(vote.nBlockHeight == nBlockHeight)
|
||||||
nCount++;
|
nCount++;
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
class CConsensusVote;
|
|
||||||
class CTransaction;
|
class CTransaction;
|
||||||
class CTransactionLock;
|
class CTxLockVote;
|
||||||
|
class CTxLockCandidate;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
At 15 signatures, 1/2 of the masternode network can be owned by
|
At 15 signatures, 1/2 of the masternode network can be owned by
|
||||||
@ -35,23 +35,23 @@ extern bool fEnableInstantSend;
|
|||||||
extern int nInstantSendDepth;
|
extern int nInstantSendDepth;
|
||||||
extern int nCompleteTXLocks;
|
extern int nCompleteTXLocks;
|
||||||
|
|
||||||
extern std::map<uint256, CTransaction> mapTxLockReq;
|
extern std::map<uint256, CTransaction> mapLockRequestAccepted;
|
||||||
extern std::map<uint256, CTransaction> mapTxLockReqRejected;
|
extern std::map<uint256, CTransaction> mapLockRequestRejected;
|
||||||
extern std::map<uint256, CConsensusVote> mapTxLockVote;
|
extern std::map<uint256, CTxLockVote> mapTxLockVotes;
|
||||||
extern std::map<COutPoint, uint256> mapLockedInputs;
|
extern std::map<COutPoint, uint256> mapLockedInputs;
|
||||||
|
|
||||||
|
|
||||||
int64_t CreateNewLock(CTransaction tx);
|
int64_t CreateTxLockCandidate(CTransaction tx);
|
||||||
|
|
||||||
bool IsInstantSendTxValid(const CTransaction& txCandidate);
|
bool IsInstantSendTxValid(const CTransaction& txCandidate);
|
||||||
|
|
||||||
void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
void ProcessMessageInstantSend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||||
|
|
||||||
//check if we need to vote on this transaction
|
//check if we need to vote on this transaction
|
||||||
void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight);
|
void CreateTxLockVote(CTransaction& tx, int64_t nBlockHeight);
|
||||||
|
|
||||||
//process consensus vote message
|
//process consensus vote message
|
||||||
bool ProcessConsensusVote(CNode *pnode, CConsensusVote& vote);
|
bool ProcessTxLockVote(CNode *pnode, CTxLockVote& vote);
|
||||||
|
|
||||||
//update UI and notify external script if any
|
//update UI and notify external script if any
|
||||||
void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification = false);
|
void UpdateLockedTransaction(CTransaction& tx, bool fForceNotification = false);
|
||||||
@ -65,7 +65,7 @@ bool FindConflictingLocks(CTransaction& tx);
|
|||||||
void ResolveConflicts(CTransaction& tx);
|
void ResolveConflicts(CTransaction& tx);
|
||||||
|
|
||||||
// keep transaction locks in memory for an hour
|
// keep transaction locks in memory for an hour
|
||||||
void CleanTransactionLocksList();
|
void CleanTxLockCandidates();
|
||||||
|
|
||||||
// verify if transaction is currently locked
|
// verify if transaction is currently locked
|
||||||
bool IsLockedInstandSendTransaction(uint256 txHash);
|
bool IsLockedInstandSendTransaction(uint256 txHash);
|
||||||
@ -76,9 +76,9 @@ int GetTransactionLockSignatures(uint256 txHash);
|
|||||||
// verify if transaction lock timed out
|
// verify if transaction lock timed out
|
||||||
bool IsTransactionLockTimedOut(uint256 txHash);
|
bool IsTransactionLockTimedOut(uint256 txHash);
|
||||||
|
|
||||||
int64_t GetAverageVoteTime();
|
int64_t GetAverageUnknownVoteTime();
|
||||||
|
|
||||||
class CConsensusVote
|
class CTxLockVote
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTxIn vinMasternode;
|
CTxIn vinMasternode;
|
||||||
@ -102,19 +102,19 @@ public:
|
|||||||
bool CheckSignature();
|
bool CheckSignature();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CTransactionLock
|
class CTxLockCandidate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int nBlockHeight;
|
int nBlockHeight;
|
||||||
uint256 txHash;
|
uint256 txHash;
|
||||||
std::vector<CConsensusVote> vecConsensusVotes;
|
std::vector<CTxLockVote> vecTxLockVotes;
|
||||||
int nLockExpirationBlock;
|
int nExpirationBlock;
|
||||||
int nTimeout;
|
int nTimeout;
|
||||||
|
|
||||||
uint256 GetHash() const { return txHash; }
|
uint256 GetHash() const { return txHash; }
|
||||||
|
|
||||||
bool IsAllVotesValid();
|
bool IsAllVotesValid();
|
||||||
void AddVote(CConsensusVote& vote);
|
void AddVote(CTxLockVote& vote);
|
||||||
int CountVotes();
|
int CountVotes();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -4921,10 +4921,10 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
|||||||
We want to only update the time on new hits, so that we can time out appropriately if needed.
|
We want to only update the time on new hits, so that we can time out appropriately if needed.
|
||||||
*/
|
*/
|
||||||
case MSG_TXLOCK_REQUEST:
|
case MSG_TXLOCK_REQUEST:
|
||||||
return mapTxLockReq.count(inv.hash) || mapTxLockReqRejected.count(inv.hash);
|
return mapLockRequestAccepted.count(inv.hash) || mapLockRequestRejected.count(inv.hash);
|
||||||
|
|
||||||
case MSG_TXLOCK_VOTE:
|
case MSG_TXLOCK_VOTE:
|
||||||
return mapTxLockVote.count(inv.hash);
|
return mapTxLockVotes.count(inv.hash);
|
||||||
|
|
||||||
case MSG_SPORK:
|
case MSG_SPORK:
|
||||||
return mapSporks.count(inv.hash);
|
return mapSporks.count(inv.hash);
|
||||||
@ -5078,20 +5078,20 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pushed && inv.type == MSG_TXLOCK_REQUEST) {
|
if (!pushed && inv.type == MSG_TXLOCK_REQUEST) {
|
||||||
if(mapTxLockReq.count(inv.hash)) {
|
if(mapLockRequestAccepted.count(inv.hash)) {
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ss.reserve(1000);
|
ss.reserve(1000);
|
||||||
ss << mapTxLockReq[inv.hash];
|
ss << mapLockRequestAccepted[inv.hash];
|
||||||
pfrom->PushMessage(NetMsgType::TXLOCKREQUEST, ss);
|
pfrom->PushMessage(NetMsgType::TXLOCKREQUEST, ss);
|
||||||
pushed = true;
|
pushed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pushed && inv.type == MSG_TXLOCK_VOTE) {
|
if (!pushed && inv.type == MSG_TXLOCK_VOTE) {
|
||||||
if(mapTxLockVote.count(inv.hash)) {
|
if(mapTxLockVotes.count(inv.hash)) {
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ss.reserve(1000);
|
ss.reserve(1000);
|
||||||
ss << mapTxLockVote[inv.hash];
|
ss << mapTxLockVotes[inv.hash];
|
||||||
pfrom->PushMessage(NetMsgType::TXLOCKVOTE, ss);
|
pfrom->PushMessage(NetMsgType::TXLOCKVOTE, ss);
|
||||||
pushed = true;
|
pushed = true;
|
||||||
}
|
}
|
||||||
|
@ -2068,8 +2068,8 @@ void RelayTransaction(const CTransaction& tx)
|
|||||||
uint256 hash = tx.GetHash();
|
uint256 hash = tx.GetHash();
|
||||||
if(mapDarksendBroadcastTxes.count(hash)) { // MSG_DSTX
|
if(mapDarksendBroadcastTxes.count(hash)) { // MSG_DSTX
|
||||||
ss << mapDarksendBroadcastTxes[hash];
|
ss << mapDarksendBroadcastTxes[hash];
|
||||||
} else if(mapTxLockReq.count(hash)) { // MSG_TXLOCK_REQUEST
|
} else if(mapLockRequestAccepted.count(hash)) { // MSG_TXLOCK_REQUEST
|
||||||
ss << mapTxLockReq[hash];
|
ss << mapLockRequestAccepted[hash];
|
||||||
} else { // MSG_TX
|
} else { // MSG_TX
|
||||||
ss << tx;
|
ss << tx;
|
||||||
}
|
}
|
||||||
@ -2080,7 +2080,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
|
|||||||
{
|
{
|
||||||
uint256 hash = tx.GetHash();
|
uint256 hash = tx.GetHash();
|
||||||
int nInv = mapDarksendBroadcastTxes.count(hash) ? MSG_DSTX :
|
int nInv = mapDarksendBroadcastTxes.count(hash) ? MSG_DSTX :
|
||||||
(mapTxLockReq.count(hash) ? MSG_TXLOCK_REQUEST : MSG_TX);
|
(mapLockRequestAccepted.count(hash) ? MSG_TXLOCK_REQUEST : MSG_TX);
|
||||||
CInv inv(nInv, hash);
|
CInv inv(nInv, hash);
|
||||||
{
|
{
|
||||||
LOCK(cs_mapRelay);
|
LOCK(cs_mapRelay);
|
||||||
|
@ -1472,8 +1472,8 @@ bool CWalletTx::RelayWalletTransaction(std::string strCommand)
|
|||||||
LogPrintf("Relaying wtx %s\n", hash.ToString());
|
LogPrintf("Relaying wtx %s\n", hash.ToString());
|
||||||
|
|
||||||
if(strCommand == NetMsgType::TXLOCKREQUEST){
|
if(strCommand == NetMsgType::TXLOCKREQUEST){
|
||||||
mapTxLockReq.insert(make_pair(hash, (CTransaction)*this));
|
mapLockRequestAccepted.insert(make_pair(hash, (CTransaction)*this));
|
||||||
CreateNewLock(((CTransaction)*this));
|
CreateTxLockCandidate(((CTransaction)*this));
|
||||||
}
|
}
|
||||||
RelayTransaction((CTransaction)*this);
|
RelayTransaction((CTransaction)*this);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user