github.com/DFWallet/tendermint-cosmos@v0.0.2/p2p/pex/errors.go (about)

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