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