Introduce new error to indicate that block is not found vs db error.
ok @davecgh
This commit is contained in:
parent
d9ee066af6
commit
f373ba3583
2 changed files with 10 additions and 6 deletions
11
db.go
11
db.go
|
@ -13,11 +13,12 @@ import (
|
|||
|
||||
// Errors that the various database functions may return.
|
||||
var (
|
||||
PrevShaMissing = errors.New("Previous sha missing from database")
|
||||
TxShaMissing = errors.New("Requested transaction does not exist")
|
||||
DuplicateSha = errors.New("Duplicate insert attempted")
|
||||
DbDoesNotExist = errors.New("Non-existent database")
|
||||
DbUnknownType = errors.New("Non-existent database type")
|
||||
PrevShaMissing = errors.New("Previous sha missing from database")
|
||||
TxShaMissing = errors.New("Requested transaction does not exist")
|
||||
BlockShaMissing = errors.New("Requested block does not exist")
|
||||
DuplicateSha = errors.New("Duplicate insert attempted")
|
||||
DbDoesNotExist = errors.New("Non-existent database")
|
||||
DbUnknownType = errors.New("Non-existent database type")
|
||||
)
|
||||
|
||||
// AllShas is a special value that can be used as the final sha when requesting
|
||||
|
|
|
@ -76,6 +76,9 @@ func (db *LevelDb) getBlkLoc(sha *btcwire.ShaHash) (int64, error) {
|
|||
|
||||
data, err := db.lDb.Get(key, db.ro)
|
||||
if err != nil {
|
||||
if err == leveldb.ErrNotFound {
|
||||
err = btcdb.BlockShaMissing
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
|
@ -203,7 +206,7 @@ func (db *LevelDb) blkExistsSha(sha *btcwire.ShaHash) (bool, error) {
|
|||
switch err {
|
||||
case nil:
|
||||
return true, nil
|
||||
case leveldb.ErrNotFound:
|
||||
case leveldb.ErrNotFound, btcdb.BlockShaMissing:
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
|
|
Loading…
Reference in a new issue