Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockAnnouncer ¶
type Peer ¶
type Peer struct {
// ProtoConn handles protocol-specific operations
ProtoConn *protocol.ProtocolConn
Address *net.UDPAddr
Ed25519Key ed25519.PublicKey
BAnnouncer BlockAnnouncer
// Optional validator index if this peer is a validator
ValidatorIndex *uint16
// contains filtered or unexported fields
}
Peer represents a remote peer and provides high-level protocol operations. It wraps the underlying transport and protocol connections with a simpler interface.
func MergeValidators ¶
MergeValidators returns a deduplicated set of validator peers from slices a and b, including only peers that are validators (ValidatorIndex != nil) Deduplication is performed based on Ed25519 public keys
func NewPeer ¶
func NewPeer(pConn *protocol.ProtocolConn) *Peer
NewPeer creates a new peer instance from an established transport connection.
func (*Peer) IsValidator ¶
IsValidator returns true if the peer is a validator, false otherwise A validator peer should have a non-nil ValidatorIndex field.
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
PeerSet maintains mappings between peer identifiers (Ed25519 keys, network addresses, validator indices) and Peer objects.
func NewPeerSet ¶
func NewPeerSet() *PeerSet
NewPeerSet creates a new PeerSet instance with initialized internal maps.
func (*PeerSet) AddPeer ¶
AddPeer adds a peer to all relevant lookup maps in the PeerSet. If the peer is a validator index, it will also have a validator index.
func (*PeerSet) GetAllPeers ¶
GetAllPeers returns all peers currently in the peer set
func (*PeerSet) GetByAddress ¶
GetByAddress looks up a peer by their network address. Returns nil if no peer is found with the given address.
func (*PeerSet) GetByEd25519Key ¶
GetByEd25519Key looks up a peer by their Ed25519 public key. Returns nil if no peer is found with the given key.
func (*PeerSet) GetByValidatorIndex ¶
GetByValidatorIndex looks up a peer by their validator index. Returns nil if no peer is found with the given validator index.
func (*PeerSet) RemovePeer ¶
RemovePeer removes a peer from all lookup maps in the PeerSet.