Documentation ¶
Index ¶
- Constants
- Variables
- func ExpectMsg(r MsgReader, code uint64, content interface{}) error
- func MsgPipe() (*MsgPipeRW, *MsgPipeRW)
- func Send(w MsgWriter, msgcode uint64, data interface{}) error
- func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error
- type Cap
- type Config
- type DiscReason
- type Msg
- type MsgPipeRW
- type MsgReadWriter
- type MsgReader
- type MsgWriter
- type NodeDialer
- type NodeInfo
- type NodeInfoToSend
- type P2PValidator
- type P2PValidatorNodeInfo
- type Peer
- func (p *Peer) Caps() []Cap
- func (p *Peer) Disconnect(reason DiscReason)
- func (p *Peer) ID() discover.NodeID
- func (p *Peer) Inbound() bool
- func (p *Peer) Info() *PeerInfo
- func (p *Peer) LocalAddr() net.Addr
- func (p *Peer) Log() log.Logger
- func (p *Peer) Name() string
- func (p *Peer) RemoteAddr() net.Addr
- func (p *Peer) String() string
- type PeerEvent
- type PeerEventType
- type PeerInfo
- type Protocol
- type Server
- func (srv *Server) AddChildProtocolCaps(sideProtocols []Protocol)
- func (srv *Server) AddLocalValidator(chainId string, address common.Address)
- func (srv *Server) AddPeer(node *discover.Node)
- func (srv *Server) BroadcastMsg(msgCode uint64, data interface{})
- func (srv *Server) NodeInfo() *NodeInfo
- func (srv *Server) PeerCount() int
- func (srv *Server) Peers() []*Peer
- func (srv *Server) PeersInfo() []*PeerInfo
- func (srv *Server) RemoveLocalValidator(chainId string, address common.Address)
- func (srv *Server) RemovePeer(node *discover.Node)
- func (srv *Server) Self() *discover.Node
- func (srv *Server) SetupConn(fd net.Conn, flags connFlag, dialDest *discover.Node) error
- func (srv *Server) Start() (err error)
- func (srv *Server) Stop()
- func (srv *Server) SubscribeEvents(ch chan *PeerEvent) event.Subscription
- type TCPDialer
Examples ¶
Constants ¶
View Source
const ( BroadcastNewSideChainMsg = 0x04 ConfirmNewSideChainMsg = 0x05 RefreshValidatorNodeInfoMsg = 0x06 RemoveValidatorNodeInfoMsg = 0x07 )
Variables ¶
View Source
var ErrPipeClosed = errors.New("p2p: read or write on closed message pipe")
Functions ¶
Types ¶
type Config ¶
type Config struct { PrivateKey *ecdsa.PrivateKey `toml:"-"` MaxPeers int MaxPendingPeers int `toml:",omitempty"` DialRatio int `toml:",omitempty"` NoDiscovery bool DiscoveryV5 bool `toml:",omitempty"` Name string `toml:"-"` BootstrapNodes []*discover.Node BootstrapNodesV5 []*discv5.Node `toml:",omitempty"` StaticNodes []*discover.Node TrustedNodes []*discover.Node LocalValidators []P2PValidator Validators map[P2PValidator]*P2PValidatorNodeInfo NetRestrict *netutil.Netlist `toml:",omitempty"` NodeDatabase string `toml:",omitempty"` Protocols []Protocol `toml:"-"` ListenAddr string NAT nat.Interface `toml:",omitempty"` Dialer NodeDialer `toml:"-"` NoDial bool `toml:",omitempty"` EnableMsgEvents bool Logger log.Logger `toml:",omitempty"` }
type DiscReason ¶
type DiscReason uint
const ( DiscRequested DiscReason = iota DiscNetworkError DiscProtocolError DiscUselessPeer DiscTooManyPeers DiscAlreadyConnected DiscIncompatibleVersion DiscInvalidIdentity DiscQuitting DiscUnexpectedIdentity DiscSelf DiscReadTimeout DiscSubprotocolError = 0x10 )
func (DiscReason) Error ¶
func (d DiscReason) Error() string
func (DiscReason) String ¶
func (d DiscReason) String() string
type MsgReadWriter ¶
type NodeInfo ¶
type NodeInfo struct { ID string `json:"id"` Name string `json:"name"` Enode string `json:"enode"` IP string `json:"ip"` Ports struct { Discovery int `json:"discovery"` Listener int `json:"listener"` } `json:"ports"` ListenAddr string `json:"listenAddr"` Protocols map[string]interface{} `json:"protocols"` }
type NodeInfoToSend ¶
type NodeInfoToSend struct {
// contains filtered or unexported fields
}
type P2PValidator ¶
type P2PValidatorNodeInfo ¶
type P2PValidatorNodeInfo struct { Node discover.Node TimeStamp time.Time Validator P2PValidator Original bool }
func (*P2PValidatorNodeInfo) Hash ¶
func (vni *P2PValidatorNodeInfo) Hash() common.Hash
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect(reason DiscReason)
func (*Peer) RemoteAddr ¶
type PeerEventType ¶
type PeerEventType string
const ( PeerEventTypeAdd PeerEventType = "add" PeerEventTypeDrop PeerEventType = "drop" PeerEventTypeMsgSend PeerEventType = "msgsend" PeerEventTypeMsgRecv PeerEventType = "msgrecv" PeerEventTypeRefreshValidator PeerEventType = "refreshvalidator" PeerEventTypeRemoveValidator PeerEventType = "removevalidator" )
type PeerInfo ¶
type PeerInfo struct { ID string `json:"id"` Name string `json:"name"` Caps []string `json:"caps"` Network struct { LocalAddress string `json:"localAddress"` RemoteAddress string `json:"remoteAddress"` Inbound bool `json:"inbound"` Trusted bool `json:"trusted"` Static bool `json:"static"` } `json:"network"` Protocols map[string]interface{} `json:"protocols"` }
type Server ¶
func (*Server) AddChildProtocolCaps ¶
func (*Server) AddLocalValidator ¶
func (*Server) BroadcastMsg ¶
func (*Server) RemoveLocalValidator ¶
func (*Server) RemovePeer ¶
func (*Server) SubscribeEvents ¶
func (srv *Server) SubscribeEvents(ch chan *PeerEvent) event.Subscription
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package discv5 implements the RLPx v5 Topic Discovery Protocol.
|
Package discv5 implements the RLPx v5 Topic Discovery Protocol. |
Package enr implements Ligo Chain Node Records as defined in EIP-778.
|
Package enr implements Ligo Chain Node Records as defined in EIP-778. |
Click to show internal directories.
Click to hide internal directories.