From 1474e204a8580d10d4ff22155bbd385e4363383d Mon Sep 17 00:00:00 2001 From: ErikEk Date: Fri, 17 Jun 2022 14:45:53 +0200 Subject: [PATCH] add-error-msg-if-missing-key --- headerfs/index.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/headerfs/index.go b/headerfs/index.go index 812e4be4..6fd3157f 100644 --- a/headerfs/index.go +++ b/headerfs/index.go @@ -266,6 +266,12 @@ func (h *headerIndex) chainTipWithTx(tx walletdb.ReadTx) (*chainhash.Hash, // fetch the hash for this tip, then using that we'll fetch the height // that corresponds to that hash. tipHashBytes := rootBucket.Get(tipKey) + if tipHashBytes == nil { + return nil, 0, fmt.Errorf( + "the key %s does not exist in bucket %s", + tipKey, indexBucket, + ) + } tipHeight, err := getHeaderEntry(rootBucket, tipHashBytes) if err != nil { return nil, 0, ErrHeightNotFound