Documentation
¶
Index ¶
- func SendMessage(w MsgWriter, code uint64, data interface{}) error
- type Config
- type Dialer
- type DialerManager
- type DialerTask
- type DiscoverTask
- type Message
- type MsgReadWriter
- type MsgReader
- type MsgWriter
- type NodeInfo
- type Peer
- type PeerInfo
- type ProtoHandshake
- type Protocol
- type ProtocolKey
- type ProtocolKeys
- type QuitReason
- type Server
- func (srv *Server) AddPeer(node *discover.Node)
- func (srv *Server) NodeInfo() *NodeInfo
- func (srv *Server) PeerCount() int
- func (srv *Server) Peers() []*Peer
- func (srv *Server) PeersInfo() []*PeerInfo
- func (srv *Server) RemovePeer(node *discover.Node)
- func (srv *Server) Self() *discover.Node
- func (srv *Server) SetupConn(fd net.Conn, dest *discover.Node) error
- func (srv *Server) Start() (err error)
- func (srv *Server) Stop()
- type TCPDialer
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendMessage ¶
Types ¶
type Config ¶
type Config struct { PrivateKey *ecdsa.PrivateKey MaxPeers int `mapstructure:"p2p-maxpeers"` MaxAcceptConns int Name string NetworkID uint64 BootNodeStrs []string `mapstructure:"�p2p-bootnodes"` BootNodes []*discover.Node ListenAddr string `mapstructure:"p2p-listenaddr"` Protocols []*Protocol NodeDatabase string `mapstructure:"p2p-nodes"` }
Config server options.
type DialerManager ¶
type DialerManager struct {
// contains filtered or unexported fields
}
DialerManager schedules dials and discovery lookups.
func NewDialerManager ¶
func NewDialerManager(maxdialers int, bootnodes []*discover.Node, ntab *discover.Table) *DialerManager
NewDialerManager
func (*DialerManager) AddStatic ¶
func (dm *DialerManager) AddStatic(n *discover.Node)
func (*DialerManager) RemoveStatic ¶
func (dm *DialerManager) RemoveStatic(n *discover.Node)
type DialerTask ¶
type DialerTask struct {
// contains filtered or unexported fields
}
DialerTask is generated for node to dial.
func (*DialerTask) Do ¶
func (t *DialerTask) Do(srv *Server) error
type DiscoverTask ¶
type DiscoverTask struct {
// contains filtered or unexported fields
}
DiscoverTask runs discovery operations for lookup.
func (*DiscoverTask) Do ¶
func (t *DiscoverTask) Do(srv *Server) error
type Message ¶
Message defines a p2p message.
func (*Message) DecodePayload ¶
DecodePayload parses the RLP content of a message
func (*Message) EncodePayload ¶
EncodePayload set the RLP content of a message
type MsgReadWriter ¶
MsgReadWriter provides reading and writing of messages.
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 Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represent a connected remote node
func (*Peer) Disconnect ¶
Disconnect terminates the peer connection with the given reason.
func (*Peer) Protocols ¶
func (p *Peer) Protocols() []*ProtocolKey
Protocols return supported subprotocols of the remote peer.
func (*Peer) RemoteAddr ¶
RemoteAddr returns the remote address of connection.
type ProtoHandshake ¶
type ProtoHandshake struct { Version uint64 Name string Protocols []*ProtocolKey ListenPort uint64 ID discover.NodeID }
ProtoHandshake defines the protocol handshake.
type Protocol ¶
type Protocol struct { Name string Version uint Offset uint64 Size uint64 Run func(peer *Peer, rw MsgReadWriter) error NodeInfo func() interface{} PeerInfo func(id discover.NodeID) interface{} }
Protocol defined a P2P subprotocol.
func (*Protocol) Key ¶
func (p *Protocol) Key() *ProtocolKey
type ProtocolKey ¶
ProtocolKey defines the structure of a protocol id.
type ProtocolKeys ¶
type ProtocolKeys []*ProtocolKey
ProtocolKeys
func (ProtocolKeys) Len ¶
func (ps ProtocolKeys) Len() int
func (ProtocolKeys) Less ¶
func (ps ProtocolKeys) Less(i, j int) bool
func (ProtocolKeys) Swap ¶
func (ps ProtocolKeys) Swap(i, j int)
type QuitReason ¶
type QuitReason uint
const ( QuitRequested QuitReason = iota QuitNetworkError QuitProtocolError QuitUselessPeer QuitTooManyPeers QuitAlreadyConnected QuitIncompatibleVersion QuitInvalidIdentity QuitQuitting QuitUnexpectedIdentity QuitSelf QuitReadTimeout QuitSubprotocolError = 0x10 )
func (QuitReason) Error ¶
func (d QuitReason) Error() string
Directories
¶
Path | Synopsis |
---|---|
Package discover implements the Node Discovery Protocol.
|
Package discover implements the Node Discovery Protocol. |
Package nat provides access to common network port mapping protocols.
|
Package nat provides access to common network port mapping protocols. |
Package netutil contains extensions to the net package.
|
Package netutil contains extensions to the net package. |