diff --git a/blockchain/chain.go b/blockchain/chain.go index 19de74ab..fd07575a 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -960,7 +960,7 @@ func (b *BlockChain) reorganizeChain(detachNodes, attachNodes *list.List) error // Load all of the utxos referenced by the block that aren't // already in the view. - err = view.fetchInputUtxos(nil, b.utxoCache, block) + err = view.fetchInputUtxos(b.utxoCache, block) if err != nil { return err } @@ -1027,7 +1027,7 @@ func (b *BlockChain) reorganizeChain(detachNodes, attachNodes *list.List) error // checkConnectBlock gets skipped, we still need to update the UTXO // view. if b.index.NodeStatus(n).KnownValid() { - err = view.fetchInputUtxos(nil, b.utxoCache, block) + err = view.fetchInputUtxos(b.utxoCache, block) if err != nil { return err } @@ -1089,7 +1089,7 @@ func (b *BlockChain) reorganizeChain(detachNodes, attachNodes *list.List) error // Load all of the utxos referenced by the block that aren't // already in the view. - err := view.fetchInputUtxos(nil, b.utxoCache, block) + err := view.fetchInputUtxos(b.utxoCache, block) if err != nil { return err } diff --git a/blockchain/utxoviewpoint.go b/blockchain/utxoviewpoint.go index fdd165c0..1e687431 100644 --- a/blockchain/utxoviewpoint.go +++ b/blockchain/utxoviewpoint.go @@ -666,15 +666,11 @@ func (view *UtxoViewpoint) findInputsToFetch(block *btcutil.Block) []wire.OutPoi // fetchInputUtxos loads the unspent transaction outputs for the inputs // referenced by the transactions in the given block into the view from the -// database or the cache as needed. In particular, referenced entries that -// are earlier in the block are added to the view and entries that are already -// in the view are not modified. -func (view *UtxoViewpoint) fetchInputUtxos(db database.DB, cache *utxoCache, block *btcutil.Block) error { - if cache != nil { - return view.fetchUtxosFromCache(cache, view.findInputsToFetch(block)) - } - // Request the input utxos from the cache. - return view.fetchUtxosMain(db, view.findInputsToFetch(block)) +// cache as needed. In particular, referenced entries that are earlier in +// the block are added to the view and entries that are already in the view +// are not modified. +func (view *UtxoViewpoint) fetchInputUtxos(cache *utxoCache, block *btcutil.Block) error { + return view.fetchUtxosFromCache(cache, view.findInputsToFetch(block)) } // NewUtxoViewpoint returns a new empty unspent transaction output view. diff --git a/blockchain/validate.go b/blockchain/validate.go index 83929810..641967fb 100644 --- a/blockchain/validate.go +++ b/blockchain/validate.go @@ -1084,7 +1084,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block, vi // // These utxo entries are needed for verification of things such as // transaction inputs, counting pay-to-script-hashes, and scripts. - err := view.fetchInputUtxos(nil, b.utxoCache, block) + err := view.fetchInputUtxos(b.utxoCache, block) if err != nil { return err }