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.

78 lines
1.8 KiB

  1. package pex
  2. import (
  3. "errors"
  4. "fmt"
  5. "github.com/tendermint/tendermint/p2p"
  6. )
  7. type ErrAddrBookNonRoutable struct {
  8. Addr *p2p.NetAddress
  9. }
  10. func (err ErrAddrBookNonRoutable) Error() string {
  11. return fmt.Sprintf("Cannot add non-routable address %v", err.Addr)
  12. }
  13. type ErrAddrBookSelf struct {
  14. Addr *p2p.NetAddress
  15. }
  16. func (err ErrAddrBookSelf) Error() string {
  17. return fmt.Sprintf("Cannot add ourselves with address %v", err.Addr)
  18. }
  19. type ErrAddrBookPrivate struct {
  20. Addr *p2p.NetAddress
  21. }
  22. func (err ErrAddrBookPrivate) Error() string {
  23. return fmt.Sprintf("Cannot add private peer with address %v", err.Addr)
  24. }
  25. func (err ErrAddrBookPrivate) PrivateAddr() bool {
  26. return true
  27. }
  28. type ErrAddrBookPrivateSrc struct {
  29. Src *p2p.NetAddress
  30. }
  31. func (err ErrAddrBookPrivateSrc) Error() string {
  32. return fmt.Sprintf("Cannot add peer coming from private peer with address %v", err.Src)
  33. }
  34. func (err ErrAddrBookPrivateSrc) PrivateAddr() bool {
  35. return true
  36. }
  37. type ErrAddrBookNilAddr struct {
  38. Addr *p2p.NetAddress
  39. Src *p2p.NetAddress
  40. }
  41. func (err ErrAddrBookNilAddr) Error() string {
  42. return fmt.Sprintf("Cannot add a nil address. Got (addr, src) = (%v, %v)", err.Addr, err.Src)
  43. }
  44. type ErrAddrBookInvalidAddr struct {
  45. Addr *p2p.NetAddress
  46. AddrErr error
  47. }
  48. func (err ErrAddrBookInvalidAddr) Error() string {
  49. return fmt.Sprintf("Cannot add invalid address %v: %v", err.Addr, err.AddrErr)
  50. }
  51. // ErrAddressBanned is thrown when the address has been banned and therefore cannot be used
  52. type ErrAddressBanned struct {
  53. Addr *p2p.NetAddress
  54. }
  55. func (err ErrAddressBanned) Error() string {
  56. return fmt.Sprintf("Address: %v is currently banned", err.Addr)
  57. }
  58. // ErrUnsolicitedList is thrown when a peer provides a list of addresses that have not been asked for.
  59. var ErrUnsolicitedList = errors.New("unsolicited pexAddrsMessage")