diff --git a/fluffy/network/wire/portal_protocol.nim b/fluffy/network/wire/portal_protocol.nim index 5c3a6db24..34f03eab7 100644 --- a/fluffy/network/wire/portal_protocol.nim +++ b/fluffy/network/wire/portal_protocol.nim @@ -118,6 +118,9 @@ const # And then there are still limits to be applied also for FindContent and the # incoming directions. concurrentOffers = 50 + # Max size of the offerQueue, when reaching this limits, offers to be started + # for neighborhoodGossip or POKE will be dropped. + offerQueueSize = 200 type ToContentIdHandler* = @@ -475,7 +478,7 @@ proc new*(T: type PortalProtocol, bootstrapRecords: @bootstrapRecords, stream: stream, radiusCache: RadiusCache.init(256), - offerQueue: newAsyncQueue[OfferRequest](concurrentOffers), + offerQueue: newAsyncQueue[OfferRequest](offerQueueSize), disablePoke: config.disablePoke) proto.baseProtocol.registerTalkProtocol(@(proto.protocolId), proto).expect( @@ -956,7 +959,7 @@ proc triggerPoke*( contentKV = ContentKV(contentKey: contentKey, content: content) list = List[ContentKV, contentKeysLimit].init(@[contentKV]) req = OfferRequest(dst: node, kind: Direct, contentList: list) - p.offerQueue.putNoWait(req) + p.offerQueue.addLastNoWait(req) except AsyncQueueFullError as e: # Should not occur as full() check is done. raiseAssert(e.msg) @@ -1178,21 +1181,32 @@ proc neighborhoodGossip*( if gossipNodes.len >= 8: # use local nodes for gossip portal_gossip_without_lookup.inc(labelValues = [$p.protocolId]) let numberOfGossipedNodes = min(gossipNodes.len, maxGossipNodes) - for node in gossipNodes[0..