Versions in this module Expand all Collapse all v0 v0.0.2 May 13, 2020 v0.0.1 May 13, 2020 Changes in this version + const FuzzModeDelay + const FuzzModeDrop + const IDByteLength + const Version + var ErrSwitchConnectToSelf = errors.New("Connect to self") + var ErrSwitchDuplicatePeer = errors.New("Duplicate peer") + func AddPeerToSwitch(sw *Switch, peer Peer) + func Connect2Switches(switches []*Switch, i, j int) + func CreateRandomPeer(outbound bool) *peer + func FuzzConn(conn net.Conn) net.Conn + func FuzzConnAfter(conn net.Conn, d time.Duration) net.Conn + func FuzzConnAfterFromConfig(conn net.Conn, d time.Duration, config *FuzzConnConfig) net.Conn + func FuzzConnFromConfig(conn net.Conn, config *FuzzConnConfig) net.Conn + func IDAddressString(id ID, hostPort string) string + func MakePoWTarget(difficulty, targetBits uint) []byte + func MaxNodeInfoSize() int + func StartSwitches(switches []*Switch) error + type AddrBook interface + AddAddress func(addr *NetAddress, src *NetAddress) error + AddOurAddress func(*NetAddress) + HasAddress func(*NetAddress) bool + MarkGood func(*NetAddress) + OurAddress func(*NetAddress) bool + RemoveAddress func(*NetAddress) + Save func() + type BaseReactor struct + Switch *Switch + func NewBaseReactor(name string, impl Reactor) *BaseReactor + func (*BaseReactor) AddPeer(peer Peer) + func (*BaseReactor) GetChannels() []*conn.ChannelDescriptor + func (*BaseReactor) Receive(chID byte, peer Peer, msgBytes []byte) + func (*BaseReactor) RemovePeer(peer Peer, reason interface{}) + func (br *BaseReactor) SetSwitch(sw *Switch) + type ChannelDescriptor = conn.ChannelDescriptor + type ConnectionStatus = conn.ConnectionStatus + 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 ErrSwitchAuthenticationFailure struct + Dialed *NetAddress + Got ID + func (e ErrSwitchAuthenticationFailure) Error() string + type FuzzConnConfig struct + MaxDelay time.Duration + Mode int + ProbDropConn float64 + ProbDropRW float64 + ProbSleep float64 + func DefaultFuzzConnConfig() *FuzzConnConfig + type FuzzedConnection struct + func (fc *FuzzedConnection) Close() error + func (fc *FuzzedConnection) Config() *FuzzConnConfig + func (fc *FuzzedConnection) LocalAddr() net.Addr + 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 ID string + func PubKeyToID(pubKey crypto.PubKey) ID + type IPeerSet interface + Get func(key ID) Peer + Has func(key ID) bool + List func() []Peer + Size func() int + type Listener interface + Connections func() <-chan net.Conn + ExternalAddress func() *NetAddress + InternalAddress func() *NetAddress + Stop func() error + String func() string + func NewDefaultListener(protocol, lAddr, aAddr string, skipUPNP bool, logger log.Logger) Listener + type NetAddress struct + ID ID + IP net.IP + Port uint16 + func CreateRoutableAddr() (addr string, netAddr *NetAddress) + func NewNetAddress(id ID, addr net.Addr) *NetAddress + func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress + func NewNetAddressString(addr string) (*NetAddress, error) + func NewNetAddressStringWithOptionalID(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) 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) Same(other interface{}) bool + func (na *NetAddress) String() string + func (na *NetAddress) Valid() bool + type NodeInfo struct + BaseVersion string + Channels cmn.HexBytes + ID ID + ListenAddr string + Moniker string + Network string + Other []string + Version string + func (info NodeInfo) CompatibleWith(other NodeInfo) error + func (info NodeInfo) NetAddress() *NetAddress + func (info NodeInfo) String() string + func (info NodeInfo) Validate() error + type NodeKey struct + PrivKey crypto.PrivKey + func LoadNodeKey(filePath string) (*NodeKey, error) + func LoadOrGenNodeKey(filePath string) (*NodeKey, error) + func (nodeKey *NodeKey) ID() ID + func (nodeKey *NodeKey) PubKey() crypto.PubKey + type Peer interface + Get func(string) interface{} + ID func() ID + IsOutbound func() bool + IsPersistent func() bool + NodeInfo func() NodeInfo + Send func(byte, []byte) bool + Set func(string, interface{}) + Status func() tmconn.ConnectionStatus + TrySend func(byte, []byte) bool + type PeerConfig struct + AuthEnc bool + DialTimeout time.Duration + Fuzz bool + FuzzConfig *FuzzConnConfig + HandshakeTimeout time.Duration + MConfig *tmconn.MConnConfig + func DefaultPeerConfig() *PeerConfig + type PeerSet struct + func NewPeerSet() *PeerSet + func (ps *PeerSet) Add(peer Peer) error + func (ps *PeerSet) Get(peerKey ID) Peer + func (ps *PeerSet) Has(peerKey ID) bool + func (ps *PeerSet) List() []Peer + func (ps *PeerSet) Remove(peer Peer) + func (ps *PeerSet) Size() int + type Reactor interface + AddPeer func(peer Peer) + GetChannels func() []*conn.ChannelDescriptor + Receive func(chID byte, peer Peer, msgBytes []byte) + RemovePeer func(peer Peer, reason interface{}) + SetSwitch func(*Switch) + type Switch struct + func MakeConnectedSwitches(cfg *cfg.P2PConfig, n int, initSwitch func(int, *Switch) *Switch, ...) []*Switch + func MakeSwitch(cfg *cfg.P2PConfig, i int, network, version string, ...) *Switch + func NewSwitch(config *cfg.P2PConfig) *Switch + func (sw *Switch) AddListener(l Listener) + func (sw *Switch) AddReactor(name string, reactor Reactor) Reactor + func (sw *Switch) Broadcast(chID byte, msgBytes []byte) chan bool + func (sw *Switch) DialPeerWithAddress(addr *NetAddress, persistent bool) error + func (sw *Switch) DialPeersAsync(addrBook AddrBook, peers []string, persistent bool) error + func (sw *Switch) FilterConnByAddr(addr net.Addr) error + func (sw *Switch) FilterConnByID(id ID) error + func (sw *Switch) IsDialing(id ID) bool + func (sw *Switch) IsListening() bool + func (sw *Switch) Listeners() []Listener + func (sw *Switch) MarkPeerAsGood(peer Peer) + func (sw *Switch) NodeInfo() NodeInfo + 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) SetAddrBook(addrBook AddrBook) + func (sw *Switch) SetAddrFilter(f func(net.Addr) error) + func (sw *Switch) SetIDFilter(f func(ID) error) + func (sw *Switch) SetNodeInfo(nodeInfo NodeInfo) + func (sw *Switch) SetNodeKey(nodeKey *NodeKey) + func (sw *Switch) StopPeerForError(peer Peer, reason interface{}) + func (sw *Switch) StopPeerGracefully(peer Peer)