diff --git a/src/main.h b/src/main.h index bbd3d32c6..1c337d103 100644 --- a/src/main.h +++ b/src/main.h @@ -39,8 +39,6 @@ static const unsigned int MAX_STANDARD_TX_SIZE = 100000; static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; /** The maximum number of orphan transactions kept in memory */ static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; -/** The maximum number of entries in an 'inv' protocol message */ -static const unsigned int MAX_INV_SZ = 50000; /** The maximum size of a blk?????.dat file (since 0.8) */ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ diff --git a/src/net.h b/src/net.h index 0f4ba4f41..5a2968c3c 100644 --- a/src/net.h +++ b/src/net.h @@ -27,6 +27,10 @@ class CBlockIndex; extern int nBestHeight; +/** The maximum number of entries in an 'inv' protocol message */ +static const unsigned int MAX_INV_SZ = 50000; +/** The maximum number of entries in mapAskFor */ +static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ; inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } @@ -357,6 +361,9 @@ public: void AskFor(const CInv& inv) { + if (mapAskFor.size() > MAPASKFOR_MAX_SZ) + return; + // We're using mapAskFor as a priority queue, // the key is the earliest time the request can be sent int64 nRequestTime;