Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
NodeID string
ListenAddr string
Transport transport.StreamTransport
Codec codec.Codec // defaults to JSON; all peers must use the same codec
Handshaker Handshaker
MaxPeers int // default: 128
MaxInboundPeers int // inbound sub-limit within MaxPeers; default: MaxPeers * 2/3
MaxPendingPeers int // concurrent in-flight handshakes; default: 32
OnPeerConnected func(peerID string)
OnPeerDisconnected func(peerID string)
// OnPeerCapabilitiesKnown fires when capabilities become known for a connected peer. Optional.
OnPeerCapabilitiesKnown func(peerID string, protocols []string)
ProtocolLimits map[string]uint32 // per-protocol frame size limits; must be ≤ transport limit
}
type HandshakeConfig ¶
type HandshakeConfig = p2p.HandshakeConfig
HandshakeConfig is an alias for p2p.HandshakeConfig.
type HandshakeResult ¶
type HandshakeResult = p2p.HandshakeResult
HandshakeResult is an alias for p2p.HandshakeResult.
type Node ¶
type Node interface {
Start() error
Stop() error
Register(protocol string, handler p2p.Handler) // must be called before Start
Send(peerID string, protocol string, msgType string, payload any) (int, error)
Peers() []string
ConnectionInfo(peerID string) (p2p.ConnInfo, bool)
BoundAddr() string // reflects OS-assigned port when ListenAddr was ":0"
PeerProtocols(peerID string) ([]string, bool) // bool=true if capabilities are known
RegisteredProtocols() []string
}
type PeerSource ¶
type ProtocolHandler ¶
ProtocolHandler is an alias for p2p.Handler.
Click to show internal directories.
Click to hide internal directories.