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.

89 lines
2.1 KiB

  1. package pex
  2. import (
  3. "errors"
  4. "fmt"
  5. "github.com/tendermint/tendermint/internal/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 errAddrBookOldAddressNewBucket struct {
  14. Addr *p2p.NetAddress
  15. BucketID int
  16. }
  17. func (err errAddrBookOldAddressNewBucket) Error() string {
  18. return fmt.Sprintf("failed consistency check!"+
  19. " Cannot add pre-existing address %v into new bucket %v",
  20. err.Addr, err.BucketID)
  21. }
  22. type ErrAddrBookSelf struct {
  23. Addr *p2p.NetAddress
  24. }
  25. func (err ErrAddrBookSelf) Error() string {
  26. return fmt.Sprintf("Cannot add ourselves with address %v", err.Addr)
  27. }
  28. type ErrAddrBookPrivate struct {
  29. Addr *p2p.NetAddress
  30. }
  31. func (err ErrAddrBookPrivate) Error() string {
  32. return fmt.Sprintf("Cannot add private peer with address %v", err.Addr)
  33. }
  34. func (err ErrAddrBookPrivate) PrivateAddr() bool {
  35. return true
  36. }
  37. type ErrAddrBookPrivateSrc struct {
  38. Src *p2p.NetAddress
  39. }
  40. func (err ErrAddrBookPrivateSrc) Error() string {
  41. return fmt.Sprintf("Cannot add peer coming from private peer with address %v", err.Src)
  42. }
  43. func (err ErrAddrBookPrivateSrc) PrivateAddr() bool {
  44. return true
  45. }
  46. type ErrAddrBookNilAddr struct {
  47. Addr *p2p.NetAddress
  48. Src *p2p.NetAddress
  49. }
  50. func (err ErrAddrBookNilAddr) Error() string {
  51. return fmt.Sprintf("Cannot add a nil address. Got (addr, src) = (%v, %v)", err.Addr, err.Src)
  52. }
  53. type ErrAddrBookInvalidAddr struct {
  54. Addr *p2p.NetAddress
  55. AddrErr error
  56. }
  57. func (err ErrAddrBookInvalidAddr) Error() string {
  58. return fmt.Sprintf("Cannot add invalid address %v: %v", err.Addr, err.AddrErr)
  59. }
  60. // ErrAddressBanned is thrown when the address has been banned and therefore cannot be used
  61. type ErrAddressBanned struct {
  62. Addr *p2p.NetAddress
  63. }
  64. func (err ErrAddressBanned) Error() string {
  65. return fmt.Sprintf("Address: %v is currently banned", err.Addr)
  66. }
  67. // ErrUnsolicitedList is thrown when a peer provides a list of addresses that have not been asked for.
  68. var ErrUnsolicitedList = errors.New("unsolicited pexAddrsMessage")