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.

43 lines
1.5 KiB

  1. package provider
  2. import (
  3. "errors"
  4. "fmt"
  5. )
  6. var (
  7. // ErrHeightTooHigh is returned when the height is higher than the last
  8. // block that the provider has. The light client will not remove the provider
  9. ErrHeightTooHigh = errors.New("height requested is too high")
  10. // ErrLightBlockNotFound is returned when a provider can't find the
  11. // requested header (i.e. it has been pruned).
  12. // The light client will not remove the provider
  13. ErrLightBlockNotFound = errors.New("light block not found")
  14. // ErrNoResponse is returned if the provider doesn't respond to the
  15. // request in a given time. The light client will not remove the provider
  16. ErrNoResponse = errors.New("client failed to respond")
  17. // ErrConnectionClosed is returned if the provider closes the connection.
  18. // In this case we remove the provider.
  19. ErrConnectionClosed = errors.New("client closed connection")
  20. )
  21. // ErrBadLightBlock is returned when a provider returns an invalid
  22. // light block. The light client will remove the provider.
  23. type ErrBadLightBlock struct {
  24. Reason error
  25. }
  26. func (e ErrBadLightBlock) Error() string {
  27. return fmt.Sprintf("client provided bad signed header: %s", e.Reason.Error())
  28. }
  29. // ErrUnreliableProvider is a generic error that indicates that the provider isn't
  30. // behaving in a reliable manner to the light client. The light client will
  31. // remove the provider
  32. type ErrUnreliableProvider struct {
  33. Reason string
  34. }
  35. func (e ErrUnreliableProvider) Error() string {
  36. return fmt.Sprintf("client deemed unreliable: %s", e.Reason)
  37. }