Remove hashes from setAskFor (#1264)
We should remove hash from setAskFor when the message corresponding to previous inv arrives, otherwise it's stays there forever and setAskFor overflows (i.e. AskFor returns immediately without processing).
This commit is contained in:
parent
f1ee9d9c71
commit
f81ea67a08
@ -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());
|
||||
|
19
src/main.cpp
19
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))
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user