decred / dcrd

Decred daemon in Go (golang).
https://decred.org
ISC License
731 stars 289 forks source link

server: Cache advertised txns. #3362

Closed davecgh closed 1 month ago

davecgh commented 1 month ago

This requires #3360.

This adds a cache to house transactions that have recently been advertised to other peers. It makes use of the new container/lru module to handle automatic expiration of entries and maximum entry limiting.

The rationale for this change is that it is considered misbehavior to advertise a transaction and then claim it is not found when the corresponding request arrives. Maintaining a separate cache of advertised transactions for a short period of time after they were advertised significantly increases the probability they are available to serve when a request for the advertisement arrives of the current status of the unconfirmed transaction mempool.