Versions in this module Expand all Collapse all v1 v1.1.2 Sep 16, 2021 Changes in this version + var ErrConnectSelf = errors.New("Connect self") + var ErrConnectSpvPeer = errors.New("Outbound connect spv peer") + var ErrDuplicatePeer = errors.New("Duplicate peer") + var PanicOnAddPeerErr = false + func Connect2Switches(switches []*Switch, i, j int) + func ExternalIPv4() (string, error) + type BaseReactor struct + Switch *Switch + func NewBaseReactor(name string, impl Reactor) *BaseReactor + func (*BaseReactor) AddPeer(peer *Peer) + func (*BaseReactor) GetChannels() []*connection.ChannelDescriptor + func (*BaseReactor) Receive(chID byte, peer *Peer, msgBytes []byte) + func (*BaseReactor) RemovePeer(peer *Peer, reason interface{}) + func (br *BaseReactor) SetSwitch(sw *Switch) + type DefaultListener struct + func (l *DefaultListener) Connections() <-chan net.Conn + func (l *DefaultListener) ExternalAddress() *NetAddress + func (l *DefaultListener) InternalAddress() *NetAddress + func (l *DefaultListener) NetListener() net.Listener + func (l *DefaultListener) OnStart() error + func (l *DefaultListener) OnStop() + func (l *DefaultListener) String() string + type IPeerSet interface + Get func(key string) *Peer + Has func(key string) bool + List func() []*Peer + Size func() int + type Listener interface + Connections func() <-chan net.Conn + ExternalAddress func() *NetAddress + InternalAddress func() *NetAddress + Stop func() bool + String func() string + func GetListener(config *cfg.P2PConfig) (Listener, string) + func NewDefaultListener(protocol string, lAddr string, skipUPNP bool) (Listener, bool) + type NetAddress struct + IP net.IP + Port uint16 + func CreateRoutableAddr() (addr string, netAddr *NetAddress) + func NewLANNetAddressIPPort(ip net.IP, port uint16) *NetAddress + func NewNetAddress(addr net.Addr) *NetAddress + func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress + func NewNetAddressString(addr string) (*NetAddress, error) + func NewNetAddressStrings(addrs []string) ([]*NetAddress, error) + func (na *NetAddress) Dial() (net.Conn, error) + func (na *NetAddress) DialString() string + func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) + func (na *NetAddress) DialTimeoutWithProxy(proxy *socks.Proxy, timeout time.Duration) (net.Conn, error) + func (na *NetAddress) Equals(other interface{}) bool + func (na *NetAddress) Local() bool + func (na *NetAddress) RFC1918() bool + func (na *NetAddress) RFC3849() bool + func (na *NetAddress) RFC3927() bool + func (na *NetAddress) RFC3964() bool + func (na *NetAddress) RFC4193() bool + func (na *NetAddress) RFC4380() bool + func (na *NetAddress) RFC4843() bool + func (na *NetAddress) RFC4862() bool + func (na *NetAddress) RFC6052() bool + func (na *NetAddress) RFC6145() bool + func (na *NetAddress) ReachabilityTo(o *NetAddress) int + func (na *NetAddress) Routable() bool + func (na *NetAddress) String() string + func (na *NetAddress) Valid() bool + type NodeInfo struct + ListenAddr string + Moniker string + Network string + Other []string + PubKey crypto.PubKeyEd25519 + RemoteAddr string + Version string + func NewNodeInfo(config *cfg.Config, pubkey crypto.PubKeyEd25519, listenAddr string) *NodeInfo + func (info *NodeInfo) CompatibleWith(other *NodeInfo) error + func (info *NodeInfo) GetNetwork() string + func (info *NodeInfo) RemoteAddrHost() string + func (info NodeInfo) DoFilter(ip string, pubKey string) error + func (info NodeInfo) String() string + type Peer struct + Key string + func CreateRandomPeer(outbound bool) *Peer + func (p *Peer) Addr() net.Addr + func (p *Peer) CanSend(chID byte) bool + func (p *Peer) Equals(other *Peer) bool + func (p *Peer) ID() string + func (p *Peer) IsLAN() bool + func (p *Peer) IsOutbound() bool + func (p *Peer) OnStart() error + func (p *Peer) OnStop() + func (p *Peer) PubKey() crypto.PubKeyEd25519 + func (p *Peer) Send(chID byte, msg interface{}) bool + func (p *Peer) ServiceFlag() consensus.ServiceFlag + func (p *Peer) String() string + func (p *Peer) TrafficStatus() (*flowrate.Status, *flowrate.Status) + func (p *Peer) TrySend(chID byte, msg interface{}) bool + func (pc Peer) CloseConn() + func (pc Peer) HandshakeTimeout(ourNodeInfo *NodeInfo, timeout time.Duration) (*NodeInfo, error) + type PeerConfig struct + DialTimeout time.Duration + HandshakeTimeout time.Duration + MConfig *connection.MConnConfig + ProxyAddress string + ProxyPassword string + ProxyUsername string + func DefaultPeerConfig(config *cfg.P2PConfig) *PeerConfig + type PeerSet struct + func NewPeerSet() *PeerSet + func (ps *PeerSet) Add(peer *Peer) error + func (ps *PeerSet) DoFilter(ip string, pubKey string) error + func (ps *PeerSet) Get(peerKey string) *Peer + func (ps *PeerSet) Has(peerKey string) bool + func (ps *PeerSet) List() []*Peer + func (ps *PeerSet) Remove(peer *Peer) + func (ps *PeerSet) Size() int + type Reactor interface + AddPeer func(peer *Peer) error + GetChannels func() []*connection.ChannelDescriptor + Receive func(chID byte, peer *Peer, msgBytes []byte) + RemovePeer func(peer *Peer, reason interface{}) + SetSwitch func(*Switch) + type Security interface + DoFilter func(ip string, pubKey string) error + IsBanned func(ip string, level byte, reason string) bool + RegisterFilter func(filter security.Filter) + Start func() error + type Switch struct + Config *cfg.Config + func MakeSwitch(cfg *cfg.Config, testdb dbm.DB, privKey crypto.PrivKeyEd25519, ...) *Switch + func NewSwitch(config *cfg.Config) (*Switch, error) + func (sw *Switch) AddListener(l Listener) + func (sw *Switch) AddPeer(pc *peerConn, isLAN bool) error + func (sw *Switch) AddReactor(name string, reactor Reactor) Reactor + func (sw *Switch) DialPeerWithAddress(addr *NetAddress) error + func (sw *Switch) IsBanned(ip string, level byte, reason string) bool + func (sw *Switch) IsDialing(addr *NetAddress) bool + func (sw *Switch) IsListening() bool + func (sw *Switch) Listeners() []Listener + func (sw *Switch) NodeInfo() *NodeInfo + func (sw *Switch) NumPeers() (lan, outbound, inbound, dialing int) + func (sw *Switch) OnStart() error + func (sw *Switch) OnStop() + func (sw *Switch) Peers() *PeerSet + func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) + func (sw *Switch) StopPeerGracefully(peerID string)