blockchain: Return early on nil utxo view in dbPutUtxoView

This change is part of the effort to add utxocache support to btcd.

connectBlock may have an empty utxoviewpoint as the block verification
process may be using the utxo cache directly.  In that case, a nil utxo
viewpoint will be passed in.  Just return early on a nil utxoviewpoint.
This commit is contained in:
Calvin Kim 2023-07-21 17:14:24 +09:00
parent d86e79eb79
commit 953d62afa7

View File

@ -790,6 +790,10 @@ func dbFetchUtxoEntry(dbTx database.Tx, outpoint wire.OutPoint) (*UtxoEntry, err
// particular, only the entries that have been marked as modified are written
// to the database.
func dbPutUtxoView(dbTx database.Tx, view *UtxoViewpoint) error {
// Return early if the view is nil.
if view == nil {
return nil
}
utxoBucket := dbTx.Metadata().Bucket(utxoSetBucketName)
for outpoint, entry := range view.entries {
// No need to update the database if the entry was not modified.