From 953d62afa720e489ff2456f20da21cbb341fc597 Mon Sep 17 00:00:00 2001 From: Calvin Kim Date: Fri, 21 Jul 2023 17:14:24 +0900 Subject: [PATCH] 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. --- blockchain/chainio.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blockchain/chainio.go b/blockchain/chainio.go index 33ed91f5..3013be3d 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -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.