Versions in this module Expand all Collapse all v1 v1.5.0 May 6, 2020 v1.4.4 Feb 7, 2020 v1.4.3 Jan 16, 2020 v1.4.2 Dec 27, 2019 Changes in this version type Peer + func (p *Peer) AuditLog(chID byte, msgBytes []byte, begin time.Time, reactorName string) v1.4.1 Nov 7, 2019 v1.4.0 Oct 15, 2019 v1.3.4 Sep 2, 2019 Changes in this version + const FuzzModeDelay + const FuzzModeDrop + const PexChannel + const Version + var ErrSwitchDuplicatePeer = errors.New("Duplicate peer") + var ErrSwitchMaxPeersPerIPRange = errors.New("IP range has too many peers") + var PanicOnAddPeerErr = false + func AddToIPRangeCounts(counts map[string]int, ip string) map[string]int + func CheckIPRangeCounts(counts map[string]int, limits []int) bool + func Connect2Switches(switches []*Switch, i, j int) + func FuzzConn(config *viper.Viper, conn net.Conn) net.Conn + func StartSwitches(switches []*Switch) error + type AddrBook struct + func NewAddrBook(filePath string, routabilityStrict bool) *AddrBook + func (a *AddrBook) AddAddress(addr *NetAddress, src *NetAddress) + func (a *AddrBook) AddOurAddress(addr *NetAddress) + func (a *AddrBook) GetSelection() []*NetAddress + func (a *AddrBook) MarkAttempt(addr *NetAddress) + func (a *AddrBook) MarkBad(addr *NetAddress) + func (a *AddrBook) MarkGood(addr *NetAddress) + func (a *AddrBook) NeedMoreAddrs() bool + func (a *AddrBook) OnStart() error + func (a *AddrBook) OnStop() + func (a *AddrBook) OurAddresses() []*NetAddress + func (a *AddrBook) PickAddress(newBias int) *NetAddress + func (a *AddrBook) Size() int + type AuthorizationFunc func(nodeinfo *NodeInfo) error + type BaseReactor struct + Switch *Switch + func NewBaseReactor(name string, impl Reactor) *BaseReactor + func (_ *BaseReactor) AddPeer(peer *Peer) + func (_ *BaseReactor) GetChannels() []*ChannelDescriptor + func (_ *BaseReactor) Receive(chID byte, peer *Peer, msgBytes []byte) + func (_ *BaseReactor) RemovePeer(peer *Peer, reason interface{}) + func (br *BaseReactor) SetSwitch(sw *Switch) + type Channel struct + type ChannelDescriptor struct + ID byte + Priority int + RecvBufferCapacity int + RecvMessageCapacity int + SendQueueCapacity int + func (chDesc *ChannelDescriptor) FillDefaults() + type ChannelStatus struct + ID byte + Priority int + RecentlySent int64 + SendQueueCapacity int + SendQueueSize int + type ConnectionStatus struct + Channels []ChannelStatus + RecvMonitor flow.Status + SendMonitor flow.Status + type DealExchangeDataFunc func(data *ExchangeData) error + 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 ExchangeData struct + GenesisJSON []byte + type FuzzedConnection struct + func (fc *FuzzedConnection) Active() bool + func (fc *FuzzedConnection) Close() error + func (fc *FuzzedConnection) Fuzz() bool + func (fc *FuzzedConnection) LocalAddr() net.Addr + func (fc *FuzzedConnection) MaxDelayMilliseconds() int + func (fc *FuzzedConnection) Mode() string + func (fc *FuzzedConnection) ProbDropConn() float64 + func (fc *FuzzedConnection) ProbDropRW() float64 + func (fc *FuzzedConnection) ProbSleep() float64 + func (fc *FuzzedConnection) Read(data []byte) (n int, err error) + func (fc *FuzzedConnection) RemoteAddr() net.Addr + func (fc *FuzzedConnection) SetDeadline(t time.Time) error + func (fc *FuzzedConnection) SetReadDeadline(t time.Time) error + func (fc *FuzzedConnection) SetWriteDeadline(t time.Time) error + func (fc *FuzzedConnection) Write(data []byte) (n int, err error) + type IPeerErrorReporter interface + ReportPeerError func(crypto.PubKey, interface{}) + 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 NewDefaultListener(protocol string, lAddr string, skipUPNP bool) (Listener, error) + type MConnection struct + LocalAddress *NetAddress + RemoteAddress *NetAddress + func NewMConnection(config *viper.Viper, conn net.Conn, chDescs []*ChannelDescriptor, ...) *MConnection + func (c *MConnection) CanSend(chID byte) bool + func (c *MConnection) OnStart() error + func (c *MConnection) OnStop() + func (c *MConnection) Send(chID byte, msg interface{}) bool + func (c *MConnection) Status() ConnectionStatus + func (c *MConnection) String() string + func (c *MConnection) TrySend(chID byte, msg interface{}) bool + type NetAddress struct + IP net.IP + Port uint16 + func NewNetAddress(addr net.Addr) *NetAddress + func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress + func NewNetAddressString(addr string) (*NetAddress, error) + func (na *NetAddress) Dial() (net.Conn, error) + func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) + func (na *NetAddress) Equals(other interface{}) bool + func (na *NetAddress) Less(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.PubKey + RemoteAddr string + SigndPubKey string + Version string + func (info *NodeInfo) CompatibleWith(other *NodeInfo) error + func (info *NodeInfo) ListenHost() string + func (info *NodeInfo) ListenPort() int + type PEXReactor struct + func NewPEXReactor(book *AddrBook) *PEXReactor + func (pexR *PEXReactor) AddPeer(peer *Peer) + func (pexR *PEXReactor) GetChannels() []*ChannelDescriptor + func (pexR *PEXReactor) OnStart() error + func (pexR *PEXReactor) OnStop() + func (pexR *PEXReactor) Receive(chID byte, src *Peer, msgBytes []byte) + func (pexR *PEXReactor) RemovePeer(peer *Peer, reason interface{}) + func (pexR *PEXReactor) RequestPEX(peer *Peer) + func (pexR *PEXReactor) SendAddrs(peer *Peer, addrs []*NetAddress) + type Peer struct + Data *gcmn.CMap + Key string + func (p *Peer) CanSend(chID byte) bool + func (p *Peer) Connection() *MConnection + func (p *Peer) Equals(other *Peer) bool + func (p *Peer) Get(key string) interface{} + func (p *Peer) IsOutbound() bool + func (p *Peer) OnStart() error + func (p *Peer) OnStop() + func (p *Peer) Send(chID byte, msg interface{}) bool + func (p *Peer) String() string + func (p *Peer) TrySend(chID byte, msg interface{}) bool + func (p *Peer) WriteTo(w io.Writer) (n int64, err error) + type PeerSet struct + func NewPeerSet() *PeerSet + func (ps *PeerSet) Add(peer *Peer) 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 PexMessage interface + func DecodeMessage(bz []byte) (msgType byte, msg PexMessage, err error) + type Reactor interface + AddPeer func(peer *Peer) + GetChannels func() []*ChannelDescriptor + Receive func(chID byte, peer *Peer, msgBytes []byte) + RemovePeer func(peer *Peer, reason interface{}) + SetSwitch func(*Switch) + type SecretConnection struct + func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKey) (*SecretConnection, error) + func (sc *SecretConnection) Close() error + func (sc *SecretConnection) LocalAddr() net.Addr + func (sc *SecretConnection) Read(data []byte) (n int, err error) + func (sc *SecretConnection) RemoteAddr() net.Addr + func (sc *SecretConnection) RemotePubKey() crypto.PubKey + func (sc *SecretConnection) SetDeadline(t time.Time) error + func (sc *SecretConnection) SetReadDeadline(t time.Time) error + func (sc *SecretConnection) SetWriteDeadline(t time.Time) error + func (sc *SecretConnection) Write(data []byte) (n int, err error) + type Switch struct + func MakeConnectedSwitches(cfg *viper.Viper, n int, initSwitch func(int, *Switch) *Switch, ...) []*Switch + func NewSwitch(config *viper.Viper) *Switch + func (sw *Switch) AddListener(l Listener) + func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, error) + func (sw *Switch) AddReactor(name string, reactor Reactor) Reactor + func (sw *Switch) AddToRefuselist(pk []byte) error + func (sw *Switch) AuthByCA(peerInfo *NodeInfo) error + func (sw *Switch) Broadcast(chID byte, msg interface{}) chan bool + func (sw *Switch) DealExchangeData(data *ExchangeData) error + func (sw *Switch) DialPeerWithAddress(addr *NetAddress) (*Peer, error) + func (sw *Switch) DialSeeds(seeds []string) + func (sw *Switch) FilterConnByAddr(addr net.Addr) error + func (sw *Switch) FilterConnByPubKey(pubkey crypto.PubKey) error + func (sw *Switch) FilterConnByRefuselist(pubkey crypto.PubKey) error + func (sw *Switch) GetExchangeData() *ExchangeData + 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) NodePrivkey() crypto.PrivKey + func (sw *Switch) NumPeers() (outbound, inbound, dialing int) + func (sw *Switch) OnStart() error + func (sw *Switch) OnStop() + func (sw *Switch) Peers() IPeerSet + func (sw *Switch) Reactor(name string) Reactor + func (sw *Switch) Reactors() map[string]Reactor + func (sw *Switch) SetAddToRefuselist(f func([]byte) error) + func (sw *Switch) SetAddrFilter(f func(net.Addr) error) + func (sw *Switch) SetAuthByCA(f AuthorizationFunc) + func (sw *Switch) SetDealExchangeDataFunc(f DealExchangeDataFunc) + func (sw *Switch) SetExchangeData(data *ExchangeData) + func (sw *Switch) SetNodeInfo(nodeInfo *NodeInfo) + func (sw *Switch) SetNodePrivKey(nodePrivKey crypto.PrivKey) + func (sw *Switch) SetPubKeyFilter(f func(crypto.PubKey) error) + func (sw *Switch) SetRefuseListFilter(cb func(crypto.PubKey) error) + func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) + func (sw *Switch) StopPeerGracefully(peer *Peer) + type SwitchEventDonePeer struct + Error interface{} + Peer *Peer + type SwitchEventNewPeer struct + Peer *Peer