Handle not found block in rocksdb.GetBlockInfo
This commit is contained in:
parent
a6dce9f770
commit
d7ed48a657
@ -488,6 +488,10 @@ func (w *Worker) GetBlocks(page int, blocksOnPage int) (*Blocks, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if bi == nil {
|
||||||
|
r.Blocks = r.Blocks[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
r.Blocks[i-from] = *bi
|
r.Blocks[i-from] = *bi
|
||||||
}
|
}
|
||||||
glog.Info("GetBlocks page ", page, " finished in ", time.Since(start))
|
glog.Info("GetBlocks page ", page, " finished in ", time.Since(start))
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/bsm/go-vlq"
|
"github.com/bsm/go-vlq"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
|
|
||||||
"github.com/tecbot/gorocksdb"
|
"github.com/tecbot/gorocksdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -987,6 +986,10 @@ func (d *RocksDB) GetBlockInfo(height uint32) (*BlockInfo, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer val.Free()
|
defer val.Free()
|
||||||
|
if val.Size() == 0 {
|
||||||
|
// block not found
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
bi, err := d.unpackBlockInfo(val.Data())
|
bi, err := d.unpackBlockInfo(val.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user