koinos / koinos-p2p

The p2p microservice orchestrates the distribution of blocks and transactions between peers.
MIT License
6 stars 4 forks source link

Transaction Cache #209

Closed youkaicountry closed 2 years ago

youkaicountry commented 2 years ago

Resolves #206

Brief description

Adds a transaction cache

Checklist

Demonstration

2022-03-21 06:55:22.070990 (p2p.Koinos) [p2p/transaction_cache.go:87] <info>: TransactionCache.pruneTransactions: pruned 1 transactions                                                                                                                                        2022-03-21 06:55:22.071033 (p2p.Koinos) [p2p/transaction_cache.go:88] <info>: Items currently in transaction cache: 0
2022-03-21 06:55:22.071050 (p2p.Koinos) [p2p/transaction_cache.go:49] <info>: TransactionCache.addTransactionItem: added transaction to cache: ID: 0x12202bce7f56692050d7bcc4b988123a6bcd5b4a7c33ad63da2f0ed3ca2db34efe45
2022-03-21 06:55:22.071064 (p2p.Koinos) [p2p/transaction_cache.go:50] <info>: Items currently in transaction cache: 1
mvandeberg commented 2 years ago

This might be a bit nit-picky, but I'd really like to see a demonstration of this log line:

log.Debugf("Gossiped transaction already in cache - %s from peer %v", util.TransactionString(transaction), msg.ReceivedFrom)

This would ensure that the cache is actually helping prevent what we think it should be preventing.

Other than that, this looks good.

mvandeberg commented 2 years ago

We should also add transactions seen from blocks to the transaction cache.