Handle not found block in rocksdb.GetBlockInfo

This commit is contained in:
Martin Boehm 2018-10-18 17:56:25 +02:00
parent a6dce9f770
commit d7ed48a657
2 changed files with 8 additions and 1 deletions

View File

@ -488,6 +488,10 @@ func (w *Worker) GetBlocks(page int, blocksOnPage int) (*Blocks, error) {
if err != nil {
return nil, err
}
if bi == nil {
r.Blocks = r.Blocks[:i]
break
}
r.Blocks[i-from] = *bi
}
glog.Info("GetBlocks page ", page, " finished in ", time.Since(start))

View File

@ -15,7 +15,6 @@ import (
"github.com/bsm/go-vlq"
"github.com/golang/glog"
"github.com/juju/errors"
"github.com/tecbot/gorocksdb"
)
@ -987,6 +986,10 @@ func (d *RocksDB) GetBlockInfo(height uint32) (*BlockInfo, error) {
return nil, err
}
defer val.Free()
if val.Size() == 0 {
// block not found
return nil, nil
}
bi, err := d.unpackBlockInfo(val.Data())
if err != nil {
return nil, err