Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6486,6 +6486,12 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t
if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id);

if (pfrom->vRecvGetData.size() + vInv.size() > 100000) {
Misbehaving(pfrom->GetId(), 20);
pfrom->fDisconnect = true;
return true;
}

pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
ProcessGetData(pfrom);
}
Expand All @@ -6497,6 +6503,11 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t
uint256 hashStop;
vRecv >> locator >> hashStop;

if (locator.vHave.size() > 64) {
Misbehaving(pfrom->GetId(), 20);
return true;
}

LOCK(cs_main);

// Find the last block the caller has in the main chain
Expand Down Expand Up @@ -6541,6 +6552,11 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t
uint256 hashStop;
vRecv >> locator >> hashStop;

if (locator.vHave.size() > 64) {
Misbehaving(pfrom->GetId(), 20);
return true;
}

LOCK(cs_main);

if (IsInitialBlockDownload())
Expand Down Expand Up @@ -6821,6 +6837,11 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t

else if (strCommand == "mempool")
{
if (pfrom->fSentMempool) {
LogPrint("net", "Ignoring repeated \"mempool\" from peer=%d\n", pfrom->id);
return true;
}

int currentHeight = GetHeight();

LOCK2(cs_main, pfrom->cs_filter);
Expand Down Expand Up @@ -6848,6 +6869,7 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t
}
if (vInv.size() > 0)
pfrom->PushMessage("inv", vInv);
pfrom->fSentMempool = true;
}


Expand Down
1 change: 1 addition & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,7 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa
fGetAddr = false;
fRelayTxes = false;
fSentAddr = false;
fSentMempool = false;
fBootstrapManifestSent = false;
fBootstrapParamManifestSent = false;
pfilter = new CBloomFilter();
Expand Down
1 change: 1 addition & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class CNode
// until it has initialized its bloom filter.
bool fRelayTxes;
bool fSentAddr;
bool fSentMempool;
CSemaphoreGrant grantOutbound;
CCriticalSection cs_filter;
CBloomFilter* pfilter;
Expand Down
Loading