mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
lnwallet/btcwallet: remove internal utxoCache
The cache wasn't really serving a purpose as FetchInputInfo isn't known to be a hot path. Also, with a planned addition of returning the confirmation status of an output within FetchInputInfo in a later commit, caching won't be useful as we'll have to go to disk anyway to determine the confirmation status.
This commit is contained in:
parent
a9efb61767
commit
c7bdfe149a
2 changed files with 1 additions and 20 deletions
|
@ -59,11 +59,6 @@ type BtcWallet struct {
|
|||
netParams *chaincfg.Params
|
||||
|
||||
chainKeyScope waddrmgr.KeyScope
|
||||
|
||||
// utxoCache is a cache used to speed up repeated calls to
|
||||
// FetchInputInfo.
|
||||
utxoCache map[wire.OutPoint]*wire.TxOut
|
||||
cacheMtx sync.RWMutex
|
||||
}
|
||||
|
||||
// A compile time check to ensure that BtcWallet implements the
|
||||
|
@ -130,7 +125,6 @@ func New(cfg Config) (*BtcWallet, error) {
|
|||
chain: cfg.ChainSource,
|
||||
netParams: cfg.NetParams,
|
||||
chainKeyScope: chainKeyScope,
|
||||
utxoCache: make(map[wire.OutPoint]*wire.TxOut),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -26,17 +26,7 @@ func (b *BtcWallet) FetchInputInfo(prevOut *wire.OutPoint) (*wire.TxOut, error)
|
|||
err error
|
||||
output *wire.TxOut
|
||||
)
|
||||
|
||||
// First check to see if the output is already within the utxo cache.
|
||||
// If so we can return directly saving a disk access.
|
||||
b.cacheMtx.RLock()
|
||||
if output, ok := b.utxoCache[*prevOut]; ok {
|
||||
b.cacheMtx.RUnlock()
|
||||
return output, nil
|
||||
}
|
||||
b.cacheMtx.RUnlock()
|
||||
|
||||
// Otherwise, we manually look up the output within the tx store.
|
||||
// We manually look up the output within the tx store.
|
||||
txid := &prevOut.Hash
|
||||
txDetail, err := base.UnstableAPI(b.wallet).TxDetails(txid)
|
||||
if err != nil {
|
||||
|
@ -54,9 +44,6 @@ func (b *BtcWallet) FetchInputInfo(prevOut *wire.OutPoint) (*wire.TxOut, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
b.cacheMtx.Lock()
|
||||
b.utxoCache[*prevOut] = output
|
||||
b.cacheMtx.Unlock()
|
||||
|
||||
return output, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue