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.

65 lines
1.4 KiB

  1. package pex
  2. import (
  3. "fmt"
  4. "github.com/tendermint/tendermint/p2p"
  5. )
  6. type ErrAddrBookNonRoutable struct {
  7. Addr *p2p.NetAddress
  8. }
  9. func (err ErrAddrBookNonRoutable) Error() string {
  10. return fmt.Sprintf("Cannot add non-routable address %v", err.Addr)
  11. }
  12. type ErrAddrBookSelf struct {
  13. Addr *p2p.NetAddress
  14. }
  15. func (err ErrAddrBookSelf) Error() string {
  16. return fmt.Sprintf("Cannot add ourselves with address %v", err.Addr)
  17. }
  18. type ErrAddrBookPrivate struct {
  19. Addr *p2p.NetAddress
  20. }
  21. func (err ErrAddrBookPrivate) Error() string {
  22. return fmt.Sprintf("Cannot add private peer with address %v", err.Addr)
  23. }
  24. func (err ErrAddrBookPrivate) PrivateAddr() bool {
  25. return true
  26. }
  27. type ErrAddrBookPrivateSrc struct {
  28. Src *p2p.NetAddress
  29. }
  30. func (err ErrAddrBookPrivateSrc) Error() string {
  31. return fmt.Sprintf("Cannot add peer coming from private peer with address %v", err.Src)
  32. }
  33. func (err ErrAddrBookPrivateSrc) PrivateAddr() bool {
  34. return true
  35. }
  36. type ErrAddrBookNilAddr struct {
  37. Addr *p2p.NetAddress
  38. Src *p2p.NetAddress
  39. }
  40. func (err ErrAddrBookNilAddr) Error() string {
  41. return fmt.Sprintf("Cannot add a nil address. Got (addr, src) = (%v, %v)", err.Addr, err.Src)
  42. }
  43. type ErrAddrBookInvalidAddr struct {
  44. Addr *p2p.NetAddress
  45. AddrErr error
  46. }
  47. func (err ErrAddrBookInvalidAddr) Error() string {
  48. return fmt.Sprintf("Cannot add invalid address %v: %v", err.Addr, err.AddrErr)
  49. }