Introduce new error to indicate that block is not found vs db error.

ok @davecgh
This commit is contained in:
Dale Rahn 2014-07-17 10:48:03 -04:00 committed by Josh Rickmar
parent d9ee066af6
commit f373ba3583
2 changed files with 10 additions and 6 deletions

1
db.go
View file

@ -15,6 +15,7 @@ import (
var (
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")

View file

@ -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