btcsuite / btcwallet

A secure bitcoin wallet daemon written in Go (golang)
ISC License
1.15k stars 590 forks source link

chain: handle replacement and duplicate txes properly #872

Closed yyforyongyu closed 1 year ago

yyforyongyu commented 1 year ago

Previously when adding a replacement tx to the local mempool, when the txid's nested map becomes empty, we forgot to delete the key from the root map. And when adding the same tx to the txids map(which happens in ZMQ), we may treat the tx as a replacement tx. These are now fixed and the related unit tests are added/updated to reflect the fix.

yyforyongyu commented 1 year ago

IMO only the first two commits should go in 0.17. The other commits would take more review time than I have and aren't as critical as the memory leak fix.

You mean the first three? The redundant Add needs to be removed otherwise the mempool will keep growing between polling intervals.

yyforyongyu commented 1 year ago

Updated the PR to focus on the memory leak fix. The last commit adds a unit test to check that the mempool state is updated as expected, and the only change is the newly added interface so I think it belongs here. cc @Crypt-iQ

Crypt-iQ commented 1 year ago

ACK 8476f55