btcsuite / btcwallet

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

chain: optimize removal of inputs in mempool #864

Closed yyforyongyu closed 1 year ago

yyforyongyu commented 1 year ago

This commit implements a new struct, cachedInputs, to provide faster lookup when removing inputs based on a given transaction. Instead of iterating all the inputs to decide whether they should be removed, we now cache txid -> inputs so we can update our local mempool faster by iterating much less data.