protocols

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PeerExchangeProtocol protocol.ID = "/nexuscore/peerexchange/1.0.0"
)

Protocol IDs (local copy to avoid import cycle)

Variables

This section is empty.

Functions

This section is empty.

Types

type HeightExchangeHandler

type HeightExchangeHandler struct{}

HeightExchangeHandler handles height exchange protocol

func NewHeightExchangeHandler

func NewHeightExchangeHandler() *HeightExchangeHandler

func (*HeightExchangeHandler) HandleMessage

func (h *HeightExchangeHandler) HandleMessage(ctx context.Context, peerID peer.ID, data []byte) error

func (*HeightExchangeHandler) Protocol

func (h *HeightExchangeHandler) Protocol() protocol.ID

type PeerExchangeHandler

type PeerExchangeHandler struct {
	// contains filtered or unexported fields
}

PeerExchangeHandler handles peer exchange protocol

func NewPeerExchangeHandler

func NewPeerExchangeHandler(h host.Host) *PeerExchangeHandler

func (*PeerExchangeHandler) HandleMessage

func (h *PeerExchangeHandler) HandleMessage(ctx context.Context, peerID peer.ID, data []byte) error

func (*PeerExchangeHandler) Protocol

func (h *PeerExchangeHandler) Protocol() protocol.ID

func (*PeerExchangeHandler) RequestPeers

func (h *PeerExchangeHandler) RequestPeers(ctx context.Context, peerID peer.ID) error

RequestPeers requests peers from a specific peer

type PeerInfo

type PeerInfo struct {
	ID       peer.ID               `json:"id"`
	Addrs    []multiaddr.Multiaddr `json:"addrs"`
	LastSeen time.Time             `json:"last_seen"`
}

PeerInfo represents information about a peer (local copy)

type PingHandler

type PingHandler struct{}

PingHandler handles ping/pong protocol for connectivity testing

func NewPingHandler

func NewPingHandler() *PingHandler

func (*PingHandler) HandleMessage

func (h *PingHandler) HandleMessage(ctx context.Context, peerID peer.ID, data []byte) error

func (*PingHandler) Protocol

func (h *PingHandler) Protocol() protocol.ID

type ProtocolHandler

type ProtocolHandler interface {
	HandleMessage(ctx context.Context, peerID peer.ID, data []byte) error
	Protocol() protocol.ID
}

ProtocolHandler handles custom protocol messages

type ProtocolManager

type ProtocolManager struct {
	// contains filtered or unexported fields
}

ProtocolManager manages all custom protocols

func NewProtocolManager

func NewProtocolManager(h host.Host) *ProtocolManager

NewProtocolManager creates a new protocol manager

func (*ProtocolManager) RegisterHandler

func (pm *ProtocolManager) RegisterHandler(handler ProtocolHandler)

RegisterHandler registers a protocol handler

func (*ProtocolManager) SendMessage

func (pm *ProtocolManager) SendMessage(ctx context.Context, peerID peer.ID, protocolID protocol.ID, data []byte) error

SendMessage sends a message to a peer using a specific protocol

type StatusHandler

type StatusHandler struct {
	// contains filtered or unexported fields
}

StatusHandler handles node status exchange

func NewStatusHandler

func NewStatusHandler(getStatusFunc func() map[string]interface{}) *StatusHandler

func (*StatusHandler) HandleMessage

func (h *StatusHandler) HandleMessage(ctx context.Context, peerID peer.ID, data []byte) error

func (*StatusHandler) Protocol

func (h *StatusHandler) Protocol() protocol.ID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址