2021-12-09 16:23:00 -06:00
|
|
|
package db
|
|
|
|
|
2023-11-21 12:44:38 -06:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"os"
|
|
|
|
|
2024-02-14 21:46:47 -08:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/db/kv"
|
2023-11-21 12:44:38 -06:00
|
|
|
)
|
2021-12-09 16:23:00 -06:00
|
|
|
|
|
|
|
// ErrNotFound can be used to determine if an error from a method in the database package
|
|
|
|
// represents a "not found" error. These often require different handling than a low-level
|
|
|
|
// i/o error. This variable copies the value in the kv package to the same scope as the Database interfaces,
|
|
|
|
// so that it is available to code paths that do not interact directly with the kv package.
|
|
|
|
var ErrNotFound = kv.ErrNotFound
|
2022-03-09 13:33:18 -06:00
|
|
|
|
|
|
|
// ErrNotFoundState wraps ErrNotFound for an error specific to a state not being found in the database.
|
|
|
|
var ErrNotFoundState = kv.ErrNotFoundState
|
|
|
|
|
|
|
|
// ErrNotFoundOriginBlockRoot wraps ErrNotFound for an error specific to the origin block root.
|
|
|
|
var ErrNotFoundOriginBlockRoot = kv.ErrNotFoundOriginBlockRoot
|
2022-03-28 16:01:55 -05:00
|
|
|
|
2023-11-21 12:44:38 -06:00
|
|
|
// IsNotFound allows callers to treat errors from a flat-file database, where the file record is missing,
|
|
|
|
// as equivalent to db.ErrNotFound.
|
|
|
|
func IsNotFound(err error) bool {
|
|
|
|
return errors.Is(err, ErrNotFound) || os.IsNotExist(err)
|
|
|
|
}
|