diff --git a/src/governance.cpp b/src/governance.cpp index 351b0075a..88a4b0724 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -152,6 +152,8 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C uint256 nHash = govobj.GetHash(); std::string strHash = nHash.ToString(); + pfrom->setAskFor.erase(nHash); + LogPrint("gobject", "MNGOVERNANCEOBJECT -- Received object: %s\n", strHash); if(!AcceptObjectMessage(nHash)) { @@ -236,6 +238,8 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C uint256 nHash = vote.GetHash(); std::string strHash = nHash.ToString(); + pfrom->setAskFor.erase(nHash); + if(!AcceptVoteMessage(nHash)) { LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- Received unrequested vote object: %s, hash: %s, peer = %d\n", vote.ToString(), strHash, pfrom->GetId()); diff --git a/src/main.cpp b/src/main.cpp index 306bcad77..fbcc40fa9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5692,11 +5692,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if(strCommand == NetMsgType::TX) { vRecv >> tx; + } else if(strCommand == NetMsgType::TXLOCKREQUEST) { + vRecv >> tx; + nInvType = MSG_TXLOCK_REQUEST; } else if (strCommand == NetMsgType::DSTX) { vRecv >> dstx; tx = dstx.tx; - uint256 hashTx = tx.GetHash(); nInvType = MSG_DSTX; + } + + CInv inv(nInvType, tx.GetHash()); + pfrom->AddInventoryKnown(inv); + pfrom->setAskFor.erase(inv.hash); + + if (strCommand == NetMsgType::DSTX) { + uint256 hashTx = tx.GetHash(); if(mapDarksendBroadcastTxes.count(hashTx)) { LogPrint("privatesend", "DSTX -- Already have %s, skipping...\n", hashTx.ToString()); @@ -5724,20 +5734,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrintf("DSTX -- Got Masternode transaction %s\n", hashTx.ToString()); mempool.PrioritiseTransaction(hashTx, hashTx.ToString(), 1000, 0.1*COIN); pmn->fAllowMixingTx = false; - } else if (strCommand == NetMsgType::TXLOCKREQUEST) { - vRecv >> tx; - nInvType = MSG_TXLOCK_REQUEST; } - CInv inv(nInvType, tx.GetHash()); - pfrom->AddInventoryKnown(inv); - LOCK(cs_main); bool fMissingInputs = false; CValidationState state; - pfrom->setAskFor.erase(inv.hash); mapAlreadyAskedFor.erase(inv.hash); if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 89a1edfa8..35a4e3619 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -340,18 +340,22 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand, if(!pCurrentBlockIndex) return; + uint256 nHash = vote.GetHash(); + + pfrom->setAskFor.erase(nHash); + { LOCK(cs_mapMasternodePaymentVotes); - if(mapMasternodePaymentVotes.count(vote.GetHash())) { - LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nHeight=%d seen\n", vote.GetHash().ToString(), pCurrentBlockIndex->nHeight); + if(mapMasternodePaymentVotes.count(nHash)) { + LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nHeight=%d seen\n", nHash.ToString(), pCurrentBlockIndex->nHeight); return; } // Avoid processing same vote multiple times - mapMasternodePaymentVotes[vote.GetHash()] = vote; + mapMasternodePaymentVotes[nHash] = vote; // but first mark vote as non-verified, // AddPaymentVote() below should take care of it if vote is actually ok - mapMasternodePaymentVotes[vote.GetHash()].MarkAsNotVerified(); + mapMasternodePaymentVotes[nHash].MarkAsNotVerified(); } int nFirstBlock = pCurrentBlockIndex->nHeight - GetStorageLimit(); diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 58d92927e..ac11375f4 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -780,6 +780,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData CMasternodeBroadcast mnb; vRecv >> mnb; + pfrom->setAskFor.erase(mnb.GetHash()); + LogPrint("masternode", "MNANNOUNCE -- Masternode announce, masternode=%s\n", mnb.vin.prevout.ToStringShort()); // backward compatibility patch @@ -805,13 +807,17 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData CMasternodePing mnp; vRecv >> mnp; + uint256 nHash = mnp.GetHash(); + + pfrom->setAskFor.erase(nHash); + LogPrint("masternode", "MNPING -- Masternode ping, masternode=%s\n", mnp.vin.prevout.ToStringShort()); // Need LOCK2 here to ensure consistent locking order because the CheckAndUpdate call below locks cs_main LOCK2(cs_main, cs); - if(mapSeenMasternodePing.count(mnp.GetHash())) return; //seen - mapSeenMasternodePing.insert(std::make_pair(mnp.GetHash(), mnp)); + if(mapSeenMasternodePing.count(nHash)) return; //seen + mapSeenMasternodePing.insert(std::make_pair(nHash, mnp)); LogPrint("masternode", "MNPING -- Masternode ping, masternode=%s new\n", mnp.vin.prevout.ToStringShort()); diff --git a/src/spork.cpp b/src/spork.cpp index af6a65fc3..512957e11 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -30,6 +30,7 @@ void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStr std::string strLogMsg; { LOCK(cs_main); + pfrom->setAskFor.erase(hash); if(!chainActive.Tip()) return; strLogMsg = strprintf("SPORK -- hash: %s id: %d value: %10d bestHeight: %d peer=%d", hash.ToString(), spork.nSporkID, spork.nValue, chainActive.Height(), pfrom->id); }