Documentation ¶
Overview ¶
Copyright 2014 The go-ethereum Authors This file is part of the go-ethereum library.
The go-ethereum library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The go-ethereum library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package p2p implements the Ethereum p2p network protocols.
Index ¶
- Constants
- Variables
- func ExpectMsg(r MsgReader, code MsgCodeType, content msgp.Marshaler) error
- func InitLoggers(logger *logrus.Logger, logdir string)
- func MsgPipe() (*MsgPipeRW, *MsgPipeRW)
- func Send(w MsgWriter, msgCode MsgCodeType, data []byte) error
- type AuthMsgV4
- type AuthRespV4
- type Cap
- func (z *Cap) DecodeMsg(dc *msgp.Reader) (err error)
- func (z Cap) EncodeMsg(en *msgp.Writer) (err error)
- func (z Cap) MarshalMsg(b []byte) (o []byte, err error)
- func (z Cap) Msgsize() (s int)
- func (cap Cap) RlpData() interface{}
- func (cap Cap) String() string
- func (z *Cap) UnmarshalMsg(bts []byte) (o []byte, err error)
- type CapsByNameAndVersion
- func (z *CapsByNameAndVersion) DecodeMsg(dc *msgp.Reader) (err error)
- func (CapsByNameAndVersion) ENRKey() string
- func (z CapsByNameAndVersion) EncodeMsg(en *msgp.Writer) (err error)
- func (cs CapsByNameAndVersion) Len() int
- func (cs CapsByNameAndVersion) Less(i, j int) bool
- func (z CapsByNameAndVersion) MarshalMsg(b []byte) (o []byte, err error)
- func (z CapsByNameAndVersion) Msgsize() (s int)
- func (cs CapsByNameAndVersion) Swap(i, j int)
- func (z *CapsByNameAndVersion) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Config
- type DiscReason
- func (z *DiscReason) DecodeMsg(dc *msgp.Reader) (err error)
- func (z DiscReason) EncodeMsg(en *msgp.Writer) (err error)
- func (d DiscReason) Error() string
- func (z DiscReason) MarshalMsg(b []byte) (o []byte, err error)
- func (z DiscReason) Msgsize() (s int)
- func (d DiscReason) String() string
- func (z *DiscReason) UnmarshalMsg(bts []byte) (o []byte, err error)
- type MeteredPeerEvent
- type MeteredPeerEventType
- type Msg
- type MsgCodeType
- type MsgPipeRW
- type MsgReadWriter
- type MsgReader
- type MsgWriter
- type NodeDialer
- type NodeInfo
- type Peer
- func (p *Peer) Caps() []Cap
- func (p *Peer) Disconnect(reason DiscReason)
- func (p *Peer) ID() onode.ID
- func (p *Peer) Inbound() bool
- func (p *Peer) Info() *PeerInfo
- func (p *Peer) LocalAddr() net.Addr
- func (p *Peer) Name() string
- func (p *Peer) Node() *onode.Node
- func (p *Peer) RemoteAddr() net.Addr
- func (p *Peer) String() string
- type PeerEvent
- type PeerEventType
- type PeerInfo
- type ProtoHandshake
- func (z *ProtoHandshake) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *ProtoHandshake) EncodeMsg(en *msgp.Writer) (err error)
- func (z *ProtoHandshake) MarshalMsg(b []byte) (o []byte, err error)
- func (z *ProtoHandshake) Msgsize() (s int)
- func (z *ProtoHandshake) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Protocol
- type RawHandshakeMsg
- func (z *RawHandshakeMsg) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *RawHandshakeMsg) EncodeMsg(en *msgp.Writer) (err error)
- func (z *RawHandshakeMsg) MarshalMsg(b []byte) (o []byte, err error)
- func (z *RawHandshakeMsg) Msgsize() (s int)
- func (z *RawHandshakeMsg) UnmarshalMsg(bts []byte) (o []byte, err error)
- type RawHandshakeResponseMsg
- func (z *RawHandshakeResponseMsg) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *RawHandshakeResponseMsg) EncodeMsg(en *msgp.Writer) (err error)
- func (z *RawHandshakeResponseMsg) MarshalMsg(b []byte) (o []byte, err error)
- func (z *RawHandshakeResponseMsg) Msgsize() (s int)
- func (z *RawHandshakeResponseMsg) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Server
- func (srv *Server) AddPeer(node *onode.Node)
- func (srv *Server) AddTrustedPeer(node *onode.Node)
- func (srv *Server) Name() string
- 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 *onode.Node)
- func (srv *Server) RemoveTrustedPeer(node *onode.Node)
- func (srv *Server) Self() *onode.Node
- func (srv *Server) SetupConn(fd net.Conn, flags connFlag, dialDest *onode.Node) error
- func (srv *Server) Start()
- func (srv *Server) Stop()
- type TCPDialer
Constants ¶
const ( MetricsInboundConnects = "p2p/InboundConnects" // Name for the registered inbound connects meter MetricsInboundTraffic = "p2p/InboundTraffic" // Name for the registered inbound traffic meter MetricsOutboundConnects = "p2p/OutboundConnects" // Name for the registered outbound connects meter MetricsOutboundTraffic = "p2p/OutboundTraffic" // Name for the registered outbound traffic meter MeteredPeerLimit = 1024 // This amount of peers are individually metered )
Variables ¶
var ErrPipeClosed = errors.New("p2p: read or write on closed message pipe")
ErrPipeClosed is returned from pipe operations after the pipe has been closed.
var (
ErrShuttingDown = errors.New("shutting down")
)
Functions ¶
func InitLoggers ¶
Types ¶
type AuthMsgV4 ¶
type AuthMsgV4 struct { Signature [sigLen]byte InitiatorPubkey [pubLen]byte Nonce [shaLen]byte Version uint32 // contains filtered or unexported fields }
RLPx v4 handshake auth (defined in EIP-8).
func (*AuthMsgV4) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type AuthRespV4 ¶
RLPx v4 handshake response (defined in EIP-8).
func (*AuthRespV4) DecodeMsg ¶
func (z *AuthRespV4) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*AuthRespV4) EncodeMsg ¶
func (z *AuthRespV4) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*AuthRespV4) MarshalMsg ¶
func (z *AuthRespV4) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*AuthRespV4) Msgsize ¶
func (z *AuthRespV4) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*AuthRespV4) UnmarshalMsg ¶
func (z *AuthRespV4) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Cap ¶
Cap is the structure of a peer capability.
func (Cap) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type CapsByNameAndVersion ¶
type CapsByNameAndVersion []Cap
func (*CapsByNameAndVersion) DecodeMsg ¶
func (z *CapsByNameAndVersion) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (CapsByNameAndVersion) ENRKey ¶
func (CapsByNameAndVersion) ENRKey() string
func (CapsByNameAndVersion) EncodeMsg ¶
func (z CapsByNameAndVersion) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (CapsByNameAndVersion) Len ¶
func (cs CapsByNameAndVersion) Len() int
func (CapsByNameAndVersion) Less ¶
func (cs CapsByNameAndVersion) Less(i, j int) bool
func (CapsByNameAndVersion) MarshalMsg ¶
func (z CapsByNameAndVersion) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (CapsByNameAndVersion) Msgsize ¶
func (z CapsByNameAndVersion) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (CapsByNameAndVersion) Swap ¶
func (cs CapsByNameAndVersion) Swap(i, j int)
func (*CapsByNameAndVersion) UnmarshalMsg ¶
func (z *CapsByNameAndVersion) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Config ¶
type Config struct { // This field must be set to a valid secp256k1 private key. PrivateKey *ecdsa.PrivateKey `toml:"-"` // MaxPeers is the maximum number of peers that can be // connected. It must be greater than zero. MaxPeers int // MaxPendingPeers is the maximum number of peers that can be pending in the // handshake phase, counted separately for inbound and outbound connections. // Zero defaults to preset values. MaxPendingPeers int `toml:",omitempty"` // DialRatio controls the ratio of inbound to dialed connections. // Example: a DialRatio of 2 allows 1/2 of connections to be dialed. // Setting DialRatio to zero defaults it to 3. DialRatio int `toml:",omitempty"` // NoDiscovery can be used to disable the peer discovery mechanism. // Disabling is useful for protocol debugging (manual topology). NoDiscovery bool // DiscoveryV5 specifies whether the new topic-discovery based V5 discovery // protocol should be started or not. DiscoveryV5 bool `toml:",omitempty"` // Name sets the node name of this server. // Use common.MakeName to create a name that follows existing conventions. NodeName string `toml:"-"` // BootstrapNodes are used to establish connectivity // with the rest of the network. BootstrapNodes []*onode.Node // BootstrapNodesV5 are used to establish connectivity // with the rest of the network using the V5 discovery // protocol. BootstrapNodesV5 []*discv5.Node `toml:",omitempty"` // Static nodes are used as pre-configured connections which are always // maintained and re-connected on disconnects. StaticNodes []*onode.Node // Trusted nodes are used as pre-configured connections which are always // allowed to connect, even above the peer limit. TrustedNodes []*onode.Node // Connectivity can be restricted to certain IP networks. // If this option is set to a non-nil value, only hosts which match one of the // IP networks contained in the list are considered. NetRestrict *netutil.Netlist `toml:",omitempty"` // NodeDatabase is the path to the database containing the previously seen // live nodes in the network. NodeDatabase string `toml:",omitempty"` // Protocols should contain the protocols supported // by the server. Matching protocols are launched for // each peer. Protocols []Protocol `toml:"-"` // If ListenAddr is set to a non-nil address, the server // will listen for incoming connections. // // If the port is zero, the operating system will pick a port. The // ListenAddr field will be updated with the actual address when // the server is started. ListenAddr string // If set to a non-nil value, the given NAT port mapper // is used to make the listening port available to the // Internet. NAT nat.Interface `toml:",omitempty"` // If Dialer is set to a non-nil value, the given Dialer // is used to dial outbound peer connections. Dialer NodeDialer `toml:"-"` // If NoDial is true, the server will not dial any peers. NoDial bool `toml:",omitempty"` // If EnableMsgEvents is set then the server will emit PeerEvents // whenever a message is sent to or received from a peer EnableMsgEvents bool NoEncryption bool // plain text transport using tcp , no encryption }
Config holds Server options.
type DiscReason ¶
type DiscReason uint16
const ( DiscRequested DiscReason = iota DiscNetworkError DiscProtocolError DiscUselessPeer DiscTooManyPeers DiscAlreadyConnected DiscIncompatibleVersion DiscInvalidIdentity DiscQuitting DiscUnexpectedIdentity DiscSelf DiscReadTimeout DiscSubprotocolError = 0x10 )
func (*DiscReason) DecodeMsg ¶
func (z *DiscReason) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (DiscReason) EncodeMsg ¶
func (z DiscReason) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (DiscReason) Error ¶
func (d DiscReason) Error() string
func (DiscReason) MarshalMsg ¶
func (z DiscReason) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (DiscReason) Msgsize ¶
func (z DiscReason) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (DiscReason) String ¶
func (d DiscReason) String() string
func (*DiscReason) UnmarshalMsg ¶
func (z *DiscReason) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type MeteredPeerEvent ¶
type MeteredPeerEvent struct { Type MeteredPeerEventType // Type of peer event IP net.IP // IP address of the peer ID onode.ID // NodeID of the peer Elapsed time.Duration // Time elapsed between the connection and the handshake/disconnection Ingress uint64 // Ingress count at the moment of the event Egress uint64 // Egress count at the moment of the event }
MeteredPeerEvent is an event emitted when peers connect or disconnect.
type MeteredPeerEventType ¶
type MeteredPeerEventType int
MeteredPeerEventType is the type of peer events emitted by a metered connection.
const ( // PeerConnected is the type of event emitted when a peer successfully // made the handshake. PeerConnected MeteredPeerEventType = iota // PeerDisconnected is the type of event emitted when a peer disconnects. PeerDisconnected // PeerHandshakeFailed is the type of event emitted when a peer fails to // make the handshake or disconnects before the handshake. PeerHandshakeFailed )
type Msg ¶
type Msg struct { Code MsgCodeType Size uint32 // size of the payload Payload io.Reader ReceivedAt time.Time }
func (Msg) GetPayLoad ¶
type MsgCodeType ¶
type MsgCodeType uint16
func (*MsgCodeType) DecodeMsg ¶
func (z *MsgCodeType) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (MsgCodeType) EncodeMsg ¶
func (z MsgCodeType) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (MsgCodeType) MarshalMsg ¶
func (z MsgCodeType) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (MsgCodeType) Msgsize ¶
func (z MsgCodeType) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*MsgCodeType) UnmarshalMsg ¶
func (z *MsgCodeType) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type MsgPipeRW ¶
type MsgPipeRW struct {
// contains filtered or unexported fields
}
MsgPipeRW is an endpoint of a MsgReadWriter pipe.
func (*MsgPipeRW) Close ¶
Close unblocks any pending ReadMsg and WriteMsg calls on both ends of the pipe. They will return ErrPipeClosed. Close also interrupts any reads from a message payload.
type MsgReadWriter ¶
MsgReadWriter provides reading and writing of encoded messages. Implementations should ensure that ReadMsg and WriteMsg can be called simultaneously from multiple goroutines.
type NodeDialer ¶
NodeDialer is used to connect to nodes in the network, typically by using an underlying net.Dialer but also using net.Pipe in tests
type NodeInfo ¶
type NodeInfo struct { ID string `json:"id"` // Unique node identifier (also the encryption key) ShortId string `json:"short_id"` Name string `json:"name"` // Name of the node, including client type, version, OS, custom data Onode string `json:"onode"` // Onode URL for adding this peer from remote peers ENR string `json:"enr"` // og Node Record IP string `json:"ip"` // IP address of the node Ports struct { Discovery int `json:"discovery"` // UDP listening port for discovery protocol Listener int `json:"listener"` // TCP listening port for RLPx } `json:"ports"` ListenAddr string `json:"listenAddr"` Protocols map[string]interface{} `json:"protocols"` }
NodeInfo represents a short summary of the information known about the host.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Sender represents a connected remote node.
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect(reason DiscReason)
Disconnect terminates the peer connection with the given reason. It returns immediately and does not wait until the connection is closed.
func (*Peer) RemoteAddr ¶
RemoteAddr returns the remote address of the network connection.
type PeerEvent ¶
type PeerEvent struct { Type PeerEventType `json:"type"` Peer onode.ID `json:"peer"` Error string `json:"error,omitempty"` Protocol string `json:"protocol,omitempty"` MsgCode *uint64 `json:"msg_code,omitempty"` MsgSize *uint32 `json:"msg_size,omitempty"` }
PeerEvent is an event emitted when peers are either added or dropped from a p2p.Server or when a message is sent or received on a peer connection
type PeerEventType ¶
type PeerEventType string
PeerEventType is the type of peer events emitted by a p2p.Server
const ( // PeerEventTypeAdd is the type of event emitted when a peer is added // to a p2p.Server PeerEventTypeAdd PeerEventType = "add" // PeerEventTypeDrop is the type of event emitted when a peer is // dropped from a p2p.Server PeerEventTypeDrop PeerEventType = "drop" // PeerEventTypeMsgSend is the type of event emitted when a // message is successfully sent to a peer PeerEventTypeMsgSend PeerEventType = "msgsend" // PeerEventTypeMsgRecv is the type of event emitted when a // message is received from a peer PeerEventTypeMsgRecv PeerEventType = "msgrecv" )
type PeerInfo ¶
type PeerInfo struct { Onode string `json:"onode"` //node url ID string `json:"id"` // Unique node identifier (also the encryption key) ShortId string `json:"short_id"` Name string `json:"name"` // Name of the node, including client type, version, OS, custom data Caps []string `json:"caps"` // Sum-protocols advertised by this particular peer Network struct { LocalAddress string `json:"localAddress"` // Local endpoint of the TCP data connection RemoteAddress string `json:"remoteAddress"` // Remote endpoint of the TCP data connection Inbound bool `json:"inbound"` Trusted bool `json:"trusted"` Static bool `json:"static"` } `json:"network"` Protocols map[string]interface{} `json:"protocols"` // Sub-protocol specific metadata fields }
PeerInfo represents a short summary of the information known about a connected peer. Sub-protocol independent fields are contained and initialized here, with protocol specifics delegated to all connected sub-protocols.
type ProtoHandshake ¶
type ProtoHandshake struct { Version uint32 `msg:"version"` Name string `msg:"name"` Caps []Cap `msg:"caps"` ListenPort uint16 `msg:"listen_port"` ID []byte `msg:"id"` // secp256k1 public key }
protoHandshake is the RLP structure of the protocol handshake.
func (*ProtoHandshake) DecodeMsg ¶
func (z *ProtoHandshake) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*ProtoHandshake) EncodeMsg ¶
func (z *ProtoHandshake) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*ProtoHandshake) MarshalMsg ¶
func (z *ProtoHandshake) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*ProtoHandshake) Msgsize ¶
func (z *ProtoHandshake) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ProtoHandshake) UnmarshalMsg ¶
func (z *ProtoHandshake) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Protocol ¶
type Protocol struct { // Name should contain the official protocol name, // often a three-letter word. Name string // Version should contain the version number of the protocol. Version uint32 // Length should contain the number of message codes used // by the protocol. Length MsgCodeType // Run is called in a new groutine when the protocol has been // negotiated with a peer. It should read and write messages from // rw. The Payload for each message must be fully consumed. // // The peer connection is closed when Start returns. It should return // any protocol-level error (suc01h as an I/O error) that is // encountered. Run func(peer *Peer, rw MsgReadWriter) error // NodeInfo is an optional helper method to retrieve protocol specific metadata // about the host node. NodeInfo func() interface{} // PeerInfo is an optional helper method to retrieve protocol specific metadata // about a certain peer in the network. If an info retrieval function is set, // but returns nil, it is assumed that the protocol handshake is still running. PeerInfo func(id onode.ID) interface{} }
Protocol represents a P2P subprotocol implementation.
func (Protocol) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type RawHandshakeMsg ¶
func (*RawHandshakeMsg) DecodeMsg ¶
func (z *RawHandshakeMsg) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*RawHandshakeMsg) EncodeMsg ¶
func (z *RawHandshakeMsg) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*RawHandshakeMsg) MarshalMsg ¶
func (z *RawHandshakeMsg) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*RawHandshakeMsg) Msgsize ¶
func (z *RawHandshakeMsg) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*RawHandshakeMsg) UnmarshalMsg ¶
func (z *RawHandshakeMsg) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type RawHandshakeResponseMsg ¶
type RawHandshakeResponseMsg struct { //RemotePubkey [pubLen]byte Nonce [shaLen]byte //Signature [sigLen]byte Version uint32 }
RLPx v4 handshake response (defined in EIP-8).
func (*RawHandshakeResponseMsg) DecodeMsg ¶
func (z *RawHandshakeResponseMsg) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*RawHandshakeResponseMsg) EncodeMsg ¶
func (z *RawHandshakeResponseMsg) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*RawHandshakeResponseMsg) MarshalMsg ¶
func (z *RawHandshakeResponseMsg) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*RawHandshakeResponseMsg) Msgsize ¶
func (z *RawHandshakeResponseMsg) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*RawHandshakeResponseMsg) UnmarshalMsg ¶
func (z *RawHandshakeResponseMsg) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Server ¶
type Server struct { // Config fields may not be modified while the server is running. Config DiscV5 *discv5.Network // contains filtered or unexported fields }
Server manages all peer connections.
func (*Server) AddPeer ¶
AddPeer connects to the given node and maintains the connection until the server is shut down. If the connection fails for any reason, the server will attempt to reconnect the peer.
func (*Server) AddTrustedPeer ¶
AddTrustedPeer adds the given node to a reserved whitelist which allows the node to always connect, even if the slot are full.
func (*Server) NodeInfo ¶
NodeInfo gathers and returns a collection of metadata known about the host.
func (*Server) PeersInfo ¶
PeersInfo returns an array of metadata objects describing connected peers.
func (*Server) RemovePeer ¶
RemovePeer disconnects from the given node
func (*Server) RemoveTrustedPeer ¶
RemoveTrustedPeer removes the given node from the trusted peer set.
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 Ethereum Node Records as defined in EIP-778.
|
Package enr implements Ethereum Node Records as defined in EIP-778. |
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. |