mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
833 B
42 lines
833 B
package ethchain
|
|
|
|
import "fmt"
|
|
|
|
// Parent error. In case a parent is unknown this error will be thrown
|
|
// by the block manager
|
|
type ParentErr struct {
|
|
Message string
|
|
}
|
|
|
|
func (err *ParentErr) Error() string {
|
|
return err.Message
|
|
}
|
|
|
|
func ParentError(hash []byte) error {
|
|
return &ParentErr{Message: fmt.Sprintf("Block's parent unkown %x", hash)}
|
|
}
|
|
|
|
func IsParentErr(err error) bool {
|
|
_, ok := err.(*ParentErr)
|
|
|
|
return ok
|
|
}
|
|
|
|
// Block validation error. If any validation fails, this error will be thrown
|
|
type ValidationErr struct {
|
|
Message string
|
|
}
|
|
|
|
func (err *ValidationErr) Error() string {
|
|
return err.Message
|
|
}
|
|
|
|
func ValidationError(format string, v ...interface{}) *ValidationErr {
|
|
return &ValidationErr{Message: fmt.Sprintf(format, v...)}
|
|
}
|
|
|
|
func IsValidationErr(err error) bool {
|
|
_, ok := err.(*ValidationErr)
|
|
|
|
return ok
|
|
}
|
|
|