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
1
db.go
1
db.go
|
@ -15,6 +15,7 @@ import (
|
||||||
var (
|
var (
|
||||||
PrevShaMissing = errors.New("Previous sha missing from database")
|
PrevShaMissing = errors.New("Previous sha missing from database")
|
||||||
TxShaMissing = errors.New("Requested transaction does not exist")
|
TxShaMissing = errors.New("Requested transaction does not exist")
|
||||||
|
BlockShaMissing = errors.New("Requested block does not exist")
|
||||||
DuplicateSha = errors.New("Duplicate insert attempted")
|
DuplicateSha = errors.New("Duplicate insert attempted")
|
||||||
DbDoesNotExist = errors.New("Non-existent database")
|
DbDoesNotExist = errors.New("Non-existent database")
|
||||||
DbUnknownType = errors.New("Non-existent database type")
|
DbUnknownType = errors.New("Non-existent database type")
|
||||||
|
|
|
@ -76,6 +76,9 @@ func (db *LevelDb) getBlkLoc(sha *btcwire.ShaHash) (int64, error) {
|
||||||
|
|
||||||
data, err := db.lDb.Get(key, db.ro)
|
data, err := db.lDb.Get(key, db.ro)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == leveldb.ErrNotFound {
|
||||||
|
err = btcdb.BlockShaMissing
|
||||||
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +206,7 @@ func (db *LevelDb) blkExistsSha(sha *btcwire.ShaHash) (bool, error) {
|
||||||
switch err {
|
switch err {
|
||||||
case nil:
|
case nil:
|
||||||
return true, nil
|
return true, nil
|
||||||
case leveldb.ErrNotFound:
|
case leveldb.ErrNotFound, btcdb.BlockShaMissing:
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, err
|
return false, err
|
||||||
|
|
Loading…
Reference in a new issue