Documentation
¶
Index ¶
- Constants
- Variables
- func BroadcastAll(mux *PeerMuxer, message wire.Message) ([]crypto.Hash, []error)
- func BroadcastRandom(mux *PeerMuxer, size int, message wire.Message) ([]crypto.Hash, []error)
- func GossipAll(mux *PeerMuxer, message wire.Message) ([]crypto.Hash, []error)
- func HandleIncomingHandshake(ctx context.Context, cfg *HandshakeConfig) (crypto.Hash, error)
- func HandleOutgoingHandshake(ctx context.Context, cfg *HandshakeConfig) (crypto.Hash, error)
- func ResolveDNSSeeds(domain string) ([]string, error)
- func ValidateEnvelope(expMagic uint32, expPeerID crypto.Hash, envelope *wire.Envelope) error
- func WriteEnvelope(ctx context.Context, peer Peer, signer crypto.Signer, magic uint32, ...) error
- type CountingReader
- type CountingWriter
- type HandshakeConfig
- type Listener
- type Peer
- type PeerDialer
- type PeerDirection
- type PeerImpl
- func (p *PeerImpl) BandwidthUsage() (uint64, uint64)
- func (p *PeerImpl) Close() error
- func (p *PeerImpl) CloseChan() <-chan struct{}
- func (p *PeerImpl) CloseReason() error
- func (p *PeerImpl) Direction() PeerDirection
- func (p *PeerImpl) LocalAddr() string
- func (p *PeerImpl) Receive() (*wire.Envelope, error)
- func (p *PeerImpl) ReceiveCtx(ctx context.Context) (*wire.Envelope, error)
- func (p *PeerImpl) RemoteAddr() string
- func (p *PeerImpl) RemoteIP() string
- func (p *PeerImpl) RemotePort() int
- func (p *PeerImpl) Send(envelope *wire.Envelope) error
- func (p *PeerImpl) SendCtx(ctx context.Context, envelope *wire.Envelope) error
- type PeerManager
- type PeerManagerOpts
- type PeerMessageHandler
- type PeerMeta
- type PeerMuxer
- func (p *PeerMuxer) AddMessageHandler(handler PeerMessageHandler) util.Unsubscriber
- func (p *PeerMuxer) AddPeer(id crypto.Hash, peer Peer) error
- func (p *PeerMuxer) AddPeerOpenHandler(handler PeerStateHandler) util.Unsubscriber
- func (p *PeerMuxer) BandwidthUsage() (uint64, uint64)
- func (p *PeerMuxer) ClosePeer(id crypto.Hash) error
- func (p *PeerMuxer) GossipPeerIDs(message wire.Message) []crypto.Hash
- func (p *PeerMuxer) HasOutboundPeerIP(ip string) bool
- func (p *PeerMuxer) HasPeerID(id crypto.Hash) bool
- func (p *PeerMuxer) PeerByID(id crypto.Hash) (Peer, error)
- func (p *PeerMuxer) PeerByIP(ip string) (Peer, error)
- func (p *PeerMuxer) PeerCount() (int, int)
- func (p *PeerMuxer) PeerIDs() []crypto.Hash
- func (p *PeerMuxer) Peers() map[crypto.Hash]Peer
- func (p *PeerMuxer) PeersByIP(ip string) []Peer
- func (p *PeerMuxer) Send(id crypto.Hash, message wire.Message) error
- type PeerStateHandler
- type SeedPeer
Constants ¶
View Source
const ( DefaultPeerRecvRateLimit = 64 DefaultPeerRecvRateLimitBurst = 192 MaxPeerPacketSize = 5 * 1024 * 1024 IdleTimeout = 10 * time.Second ValidMessageDeadline = 2 * time.Hour Inbound PeerDirection = 0 Outbound PeerDirection = 1 )
View Source
const ( StandardPort = 9097 MainnetMagic = 0xcafecafe ProtocolVersion = 1 MaxPendingInbound = 12 MaxPendingOutbound = 5 DayBan = 24 * time.Hour YearBan = 365 * DayBan )
View Source
const (
DefaultPeerMuxerGossipTimeoutMS = 5 * 60 * 1000
)
Variables ¶
View Source
var ( ErrInvalidEnvelopeMagic = errors.New("envelope has invalid magic") ErrInvalidEnvelopeTimestamp = errors.New("envelope has stale timestamp") ErrInvalidEnvelopeSignature = errors.New("envelope has invalid signature") )
View Source
var ( ErrUnexpectedMessage = errors.New("unexpected handshake message") ErrIncompatibleProtocol = errors.New("incompatible protocol version") ErrInvalidNonce = errors.New("invalid nonce on hello message") )
View Source
var ( ErrPeerSendBufferFull = errors.New("peer send buffer full") ErrPeerRecvBufferFull = errors.New("peer receive buffer full") )
View Source
var ( ErrPeerClosed = errors.New("peer closed") ErrPeerHangup = errors.New("remote hung up") )
View Source
var ( ErrMaxOutbound = errors.New("reached maximum outbound peers") ErrMaxInbound = errors.New("reached maximum inbound peers") ErrAlreadyConnecting = errors.New("already connecting to this peer") ErrPeerIDMismatch = errors.New("peer IDs do not match after handshake") ErrSelfDial = errors.New("self-dial after handshake") ErrAlreadyConnected = errors.New("already connected to this peer") ErrPeerBanned = errors.New("peer is banned") ErrInboundBusy = errors.New("all inbound connections busy") ErrOutboundBusy = errors.New("all outbound connections busy") )
Functions ¶
func BroadcastAll ¶
func BroadcastRandom ¶
func HandleIncomingHandshake ¶
func HandleOutgoingHandshake ¶
func ResolveDNSSeeds ¶
func ValidateEnvelope ¶
Types ¶
type CountingReader ¶
type CountingReader struct {
// contains filtered or unexported fields
}
func NewCountingReader ¶
func NewCountingReader(r io.Reader) *CountingReader
func (*CountingReader) Count ¶
func (c *CountingReader) Count() uint64
func (*CountingReader) Reset ¶
func (c *CountingReader) Reset()
type CountingWriter ¶
type CountingWriter struct {
// contains filtered or unexported fields
}
func NewCountingWriter ¶
func NewCountingWriter(w io.Writer) *CountingWriter
func (*CountingWriter) Count ¶
func (c *CountingWriter) Count() uint64
func (*CountingWriter) Reset ¶
func (c *CountingWriter) Reset()
type HandshakeConfig ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
func NewListener(host string, manager PeerManager) *Listener
type Peer ¶
type Peer interface { Direction() PeerDirection LocalAddr() string RemoteIP() string RemoteAddr() string RemotePort() int SendCtx(ctx context.Context, envelope *wire.Envelope) error Send(envelope *wire.Envelope) error ReceiveCtx(ctx context.Context) (*wire.Envelope, error) Receive() (*wire.Envelope, error) CloseChan() <-chan struct{} Close() error BandwidthUsage() (uint64, uint64) CloseReason() error }
type PeerDialer ¶
type PeerDirection ¶
type PeerDirection int
func (PeerDirection) String ¶
func (p PeerDirection) String() string
type PeerImpl ¶
type PeerImpl struct {
// contains filtered or unexported fields
}
func (*PeerImpl) BandwidthUsage ¶
func (*PeerImpl) CloseReason ¶
func (*PeerImpl) Direction ¶
func (p *PeerImpl) Direction() PeerDirection
func (*PeerImpl) ReceiveCtx ¶
func (*PeerImpl) RemoteAddr ¶
func (*PeerImpl) RemotePort ¶
type PeerManager ¶
func NewPeerManager ¶
func NewPeerManager(opts *PeerManagerOpts) PeerManager
type PeerManagerOpts ¶
type PeerMessageHandler ¶
func PeerMessageHandlerForType ¶
func PeerMessageHandlerForType(msgType wire.MessageType, hdlr func(id crypto.Hash, envelope *wire.Envelope)) PeerMessageHandler
type PeerMuxer ¶
type PeerMuxer struct { GossipTimeoutMS int // contains filtered or unexported fields }
func (*PeerMuxer) AddMessageHandler ¶
func (p *PeerMuxer) AddMessageHandler(handler PeerMessageHandler) util.Unsubscriber
func (*PeerMuxer) AddPeerOpenHandler ¶
func (p *PeerMuxer) AddPeerOpenHandler(handler PeerStateHandler) util.Unsubscriber
func (*PeerMuxer) BandwidthUsage ¶
func (*PeerMuxer) GossipPeerIDs ¶
func (*PeerMuxer) HasOutboundPeerIP ¶
type PeerStateHandler ¶
Click to show internal directories.
Click to hide internal directories.