mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-22 04:38:55 +02:00
net: move SendBufferSize/ReceiveFloodSize to CConnman
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -4769,6 +4769,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman& connma
|
||||
void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParams, CConnman& connman)
|
||||
{
|
||||
std::deque<CInv>::iterator it = pfrom->vRecvGetData.begin();
|
||||
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize();
|
||||
|
||||
vector<CInv> vNotFound;
|
||||
|
||||
@@ -4776,7 +4777,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
|
||||
|
||||
while (it != pfrom->vRecvGetData.end()) {
|
||||
// Don't bother if send buffer is too full to respond anyway
|
||||
if (pfrom->nSendSize >= SendBufferSize())
|
||||
if (pfrom->nSendSize >= nMaxSendBufferSize)
|
||||
break;
|
||||
|
||||
const CInv &inv = *it;
|
||||
@@ -4934,6 +4935,8 @@ uint32_t GetFetchFlags(CNode* pfrom, CBlockIndex* pprev, const Consensus::Params
|
||||
|
||||
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman)
|
||||
{
|
||||
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize();
|
||||
|
||||
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||
{
|
||||
@@ -5283,7 +5286,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
// Track requests for our stuff
|
||||
GetMainSignals().Inventory(inv.hash);
|
||||
|
||||
if (pfrom->nSendSize > (SendBufferSize() * 2)) {
|
||||
if (pfrom->nSendSize > (nMaxSendBufferSize * 2)) {
|
||||
Misbehaving(pfrom->GetId(), 50);
|
||||
return error("send buffer size() = %u", pfrom->nSendSize);
|
||||
}
|
||||
@@ -6188,6 +6191,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
bool ProcessMessages(CNode* pfrom, CConnman& connman)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize();
|
||||
//if (fDebug)
|
||||
// LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size());
|
||||
|
||||
@@ -6210,7 +6214,7 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman)
|
||||
std::deque<CNetMessage>::iterator it = pfrom->vRecvMsg.begin();
|
||||
while (!pfrom->fDisconnect && it != pfrom->vRecvMsg.end()) {
|
||||
// Don't bother if send buffer is too full to respond anyway
|
||||
if (pfrom->nSendSize >= SendBufferSize())
|
||||
if (pfrom->nSendSize >= nMaxSendBufferSize)
|
||||
break;
|
||||
|
||||
// get next message
|
||||
|
||||
Reference in New Issue
Block a user