From 9adcefc2ef7e7de9ea9ef8e1eaa26dc93457eb7c Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 25 Feb 2022 13:44:14 +0300 Subject: [PATCH] core: gracefully wrap Seek error if failed to retrieve header hases --- pkg/core/dao/dao.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index cae2622d6..04eb31cf4 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -5,6 +5,7 @@ import ( "context" "encoding/binary" "errors" + "fmt" iocore "io" "github.com/nspcc-dev/neo-go/pkg/core/block" @@ -513,18 +514,20 @@ func (dao *Simple) GetStateSyncCurrentBlockHeight() (uint32, error) { func (dao *Simple) GetHeaderHashes() ([]util.Uint256, error) { var hashes = make([]util.Uint256, 0) + var seekErr error dao.Store.Seek(storage.SeekRange{ Prefix: dao.mkKeyPrefix(storage.IXHeaderHashList), }, func(k, v []byte) bool { newHashes, err := read2000Uint256Hashes(v) if err != nil { - panic(err) + seekErr = fmt.Errorf("failed to read batch of 2000 header hashes: %w", err) + return false } hashes = append(hashes, newHashes...) return true }) - return hashes, nil + return hashes, seekErr } // GetTransaction returns Transaction and its height by the given hash