Skip to content

Commit ea93757

Browse files
committed
Made sure errors are caught and returned.
1 parent 9bbb2e6 commit ea93757

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

database/ldb/dblock.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ func (db *LevelDb) FetchHeightRange(startHeight, endHeight int64) (rshalist []wi
179179
// part of the database.Db interface implementation.
180180
func (db *LevelDb) FetchBlockHeightBySha(sha *wire.ShaHash) (int64, error) {
181181

182-
dblk, _ := db.FetchDBlockByHash(sha.ToFactomHash())
182+
dblk, err := db.FetchDBlockByHash(sha.ToFactomHash())
183+
if err != nil {
184+
return 0, err
185+
}
183186

184187
var height int64 = -1
185188
if dblk != nil {
@@ -261,10 +264,16 @@ func (db *LevelDb) FetchDBlockByHash(dBlockHash *common.Hash) (*common.Directory
261264

262265
// FetchDBlockByHeight gets an directory block by height from the database.
263266
func (db *LevelDb) FetchDBlockByHeight(dBlockHeight uint32) (dBlock *common.DirectoryBlock, err error) {
264-
dBlockHash, _ := db.FetchDBHashByHeight(dBlockHeight)
267+
dBlockHash, err := db.FetchDBHashByHeight(dBlockHeight)
268+
if err != nil {
269+
return nil, err
270+
}
265271

266272
if dBlockHash != nil {
267-
dBlock, _ = db.FetchDBlockByHash(dBlockHash)
273+
dBlock, err = db.FetchDBlockByHash(dBlockHash)
274+
if err != nil {
275+
return nil, err
276+
}
268277
}
269278

270279
return dBlock, nil

database/ldb/eblock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ func (db *LevelDb) FetchAllEBlocksByChain(chainID *common.Hash) (eBlocks *[]comm
230230

231231
var key []byte = []byte{byte(TBL_EB)}
232232
key = append(key, eBlockHash.Bytes()...)
233-
data, _ := db.lDb.Get(key, db.ro)
233+
data, err := db.lDb.Get(key, db.ro)
234+
if err != nil {
235+
return nil, err
236+
}
234237

235238
eBlock := common.NewEBlock()
236239
if data != nil {

0 commit comments

Comments
 (0)