Open diegomrsantos opened 1 week ago
Where is this complexity needed? The seen cache doesn't need it since all entries go through validation and therefore the peer will be descored if they add junk to it - the idontwant cache is limited in size already, here: https://github.com/vacp2p/nim-libp2p/blob/0f27f896ab69b40e8f566e77646c6980238a3a13/libp2p/protocols/pubsub/gossipsub/behavior.nim#L309
Where is this complexity needed?
I wouldn't call it complexity, even if we don't use it right now, being able to specify a max size is a common feature in data structures. IMO it doesn't make the code much harder to understand either.
the idontwant cache is limited in size already, here:
I'd argue that what is harder to understand and error-prone is adding a limit somewhere else in the code than in the data structure itself.
This PR adds an optional
maxSize
toTimedCache
. In this way, we can avoid the cache growing unbounded.