Documentation
¶
Index ¶
- Constants
- Variables
- func ErrBadStream() lib.ErrorI
- func ErrBannedCountry(s string) lib.ErrorI
- func ErrBannedID(s string) lib.ErrorI
- func ErrBannedIP(s string) lib.ErrorI
- func ErrChunkLargerThanMax() lib.ErrorI
- func ErrConnDecryptFailed(err error) lib.ErrorI
- func ErrErrorGroup(err error) lib.ErrorI
- func ErrFailedChallenge() lib.ErrorI
- func ErrFailedDial(err error) lib.ErrorI
- func ErrFailedDiffieHellman(err error) lib.ErrorI
- func ErrFailedHKDF(err error) lib.ErrorI
- func ErrFailedListen(err error) lib.ErrorI
- func ErrFailedMetaSwap(err error) lib.ErrorI
- func ErrFailedRead(err error) lib.ErrorI
- func ErrFailedSignatureSwap(err error) lib.ErrorI
- func ErrFailedWrite(err error) lib.ErrorI
- func ErrIPLookup(err error) lib.ErrorI
- func ErrIncompatiblePeer() lib.ErrorI
- func ErrInvalidPublicKey(err error) lib.ErrorI
- func ErrIsBlacklisted() lib.ErrorI
- func ErrMaxInbound() lib.ErrorI
- func ErrMaxMessageSize() lib.ErrorI
- func ErrMaxOutbound() lib.ErrorI
- func ErrMismatchPeerPublicKey(expected, got []byte) lib.ErrorI
- func ErrNonTCPAddress() lib.ErrorI
- func ErrPeerAlreadyExists(s string) lib.ErrorI
- func ErrPeerNotFound(s string) lib.ErrorI
- func ErrPongTimeout() lib.ErrorI
- func ErrUnknownP2PMsg(t proto.Message) lib.ErrorI
- func PeerError(publicKey []byte, remoteAddr string, err error) string
- type BookPeer
- func (*BookPeer) Descriptor() ([]byte, []int)deprecated
- func (x *BookPeer) GetAddress() *lib.PeerAddress
- func (x *BookPeer) GetConsecutiveFailedDial() int32
- func (*BookPeer) ProtoMessage()
- func (x *BookPeer) ProtoReflect() protoreflect.Message
- func (x *BookPeer) Reset()
- func (x *BookPeer) String() string
- type EncryptedConn
- func (c *EncryptedConn) Close() error
- func (c *EncryptedConn) LocalAddr() net.Addr
- func (c *EncryptedConn) Read(data []byte) (n int, err error)
- func (c *EncryptedConn) RemoteAddr() net.Addr
- func (c *EncryptedConn) SetDeadline(t time.Time) error
- func (c *EncryptedConn) SetReadDeadline(t time.Time) error
- func (c *EncryptedConn) SetWriteDeadline(t time.Time) error
- func (c *EncryptedConn) Write(data []byte) (n int, err error)
- type Envelope
- type MultiConn
- type P2P
- func (p *P2P) AddPeer(conn net.Conn, info *lib.PeerInfo, disconnect, strictPublicKey bool) (err lib.ErrorI)
- func (p *P2P) Dial(address *lib.PeerAddress, disconnect, strictPublicKey bool) lib.ErrorI
- func (p *P2P) DialAndDisconnect(a *lib.PeerAddress, strictPublicKey bool) lib.ErrorI
- func (p *P2P) DialForOutboundPeers()
- func (p *P2P) DialWithBackoff(peerInfo *lib.PeerAddress, strictPublicKey bool)
- func (p *P2P) GetBookPeers() []*BookPeer
- func (p *P2P) GetInboxStats() map[lib.Topic]int
- func (p *P2P) ID() *lib.PeerAddress
- func (p *P2P) Inbox(topic lib.Topic) chan *lib.MessageAndMetadata
- func (p *P2P) IsSelf(a *lib.PeerAddress) bool
- func (p *P2P) ListenForInboundPeers(listenAddress *lib.PeerAddress)
- func (p *P2P) ListenForMustConnects()
- func (p *P2P) ListenForPeerBookRequests()
- func (p *P2P) ListenForPeerBookResponses()
- func (p *P2P) MaxPossibleInbound() int
- func (p *P2P) MaxPossibleOutbound() int
- func (p *P2P) MaxPossiblePeers() int
- func (p *P2P) MonitorInboxStats(interval time.Duration)
- func (p *P2P) NewConnection(conn net.Conn) (*MultiConn, lib.ErrorI)
- func (p *P2P) NewStreams() (streams map[lib.Topic]*Stream)
- func (p *P2P) OnPeerError(err error, publicKey []byte, remoteAddr string, uuid uint64)
- func (p *P2P) SelfSend(fromPublicKey []byte, topic lib.Topic, payload proto.Message) lib.ErrorI
- func (p *P2P) SendPeerBookRequests()
- func (p *P2P) Start()
- func (p *P2P) StartPeerBookService()
- func (p *P2P) Stop()
- func (p *P2P) WaitForMinimumPeers()
- type Packet
- func (*Packet) Descriptor() ([]byte, []int)deprecated
- func (x *Packet) GetBytes() []byte
- func (x *Packet) GetEof() bool
- func (x *Packet) GetStreamId() lib.Topic
- func (*Packet) ProtoMessage()
- func (x *Packet) ProtoReflect() protoreflect.Message
- func (x *Packet) Reset()
- func (x *Packet) String() string
- type Peer
- type PeerBook
- func (p *PeerBook) Add(peer *BookPeer)
- func (p *PeerBook) AddFailedDialAttempt(address *lib.PeerAddress)
- func (p *PeerBook) DeleteAtIndex(address *lib.PeerAddress)
- func (p *PeerBook) GetAll() (res []*BookPeer)
- func (p *PeerBook) GetBookSize() int
- func (p *PeerBook) GetRandom() *BookPeer
- func (p *PeerBook) Remove(address *lib.PeerAddress)
- func (p *PeerBook) ResetFailedDialAttempts(address *lib.PeerAddress)
- func (p *PeerBook) SaveRoutine()
- func (p *PeerBook) StartChurnManagement(dialAndDisconnect func(a *lib.PeerAddress, strictPublicKey bool) lib.ErrorI)
- func (p *PeerBook) WriteToFile() error
- type PeerBookRequestMessage
- type PeerBookResponseMessage
- func (*PeerBookResponseMessage) Descriptor() ([]byte, []int)deprecated
- func (x *PeerBookResponseMessage) GetBook() []*BookPeer
- func (*PeerBookResponseMessage) ProtoMessage()
- func (x *PeerBookResponseMessage) ProtoReflect() protoreflect.Message
- func (x *PeerBookResponseMessage) Reset()
- func (x *PeerBookResponseMessage) String() string
- type PeerSet
- func (ps *PeerSet) Add(p *Peer) (err lib.ErrorI)
- func (ps *PeerSet) ChangeReputation(publicKey []byte, delta int32)
- func (ps *PeerSet) GetAllInfos() (res []*lib.PeerInfo, numInbound, numOutbound int)
- func (ps *PeerSet) GetPeerInfo(publicKey []byte) (*lib.PeerInfo, lib.ErrorI)
- func (ps *PeerSet) Has(publicKey []byte) bool
- func (ps *PeerSet) IsMustConnect(publicKey []byte) bool
- func (ps *PeerSet) PeerCount() int
- func (ps *PeerSet) Remove(publicKey []byte, uuid uint64) (err lib.ErrorI)
- func (ps *PeerSet) SendTo(publicKey []byte, topic lib.Topic, msg proto.Message) lib.ErrorI
- func (ps *PeerSet) SendToPeers(topic lib.Topic, msg proto.Message, excludeKeys ...string) lib.ErrorI
- func (ps *PeerSet) SendToRandPeer(topic lib.Topic, msg proto.Message) (*lib.PeerInfo, lib.ErrorI)
- func (ps *PeerSet) Stop()
- func (ps *PeerSet) UpdateMustConnects(mustConnect []*lib.PeerAddress) (toDial []*lib.PeerAddress)
- type Stream
Constants ¶
const ( // "Peer Reputation Points" are actively maintained for each peer the node is connected to // These points allow a node to track peer behavior over its lifetime, allowing it to disconnect from faulty peers PollMaxHeightTimeoutS = 1 // wait time for polling the maximum height of the peers SyncTimeoutS = 5 // wait time to receive an individual block (certificate) from a peer during syncing MaxBlockReqPerWindow = 20 // maximum block (certificate) requests per window per requester BlockReqWindowS = 2 // the 'window of time' before resetting limits for block (certificate) requests GoodPeerBookRespRep = 3 // reputation points for a good peer book response GoodBlockRep = 3 // rep boost for sending us a valid block (certificate) UnexpectedBlockRep = -1 // rep slash for sending us a block we weren't expecting InvalidMsgRep = -3 // slash for an invalid message ExceedMaxPBReqRep = -3 // slash for exceeding the max peer book requests UnknownMessageSlash = -3 // unknown message type is received BadStreamSlash = -3 // unknown stream id is received InvalidTxRep = -3 // rep slash for sending us an invalid transaction InvalidBlockRep = -3 // rep slash for sending an invalid block (certificate) message BlockReqExceededRep = -3 // rep slash for over-requesting blocks (certificates) MaxMessageExceededSlash = -10 // slash for sending a 'Message (sum of Packets)' above the allowed maximum size )
const ( ErrListenerClosed = "use of closed network connection" ErrConnReset = "connection reset by peer" ErrEOF = "EOF" ErrPeer = "Error peer" )
const ( MaxPeerReputation = 10 MinimumPeerReputation = -10 )
Variables ¶
var ( MaxFailedDialAttempts = int32(10) // maximum times a peer may fail a churn management dial attempt before evicted from the peer book MaxPeersExchanged = 1 // maximum number of peers per chain that may be sent/received during a peer exchange MaxPeerBookRequestsPerWindow = 2 // maximum peer book request per window PeerBookRequestWindowS = 30 // seconds in a peer book request CrawlAndCleanBookFrequency = time.Minute * 10 // how often the book is cleaned and crawled SaveBookFrequency = time.Minute * 5 // how often the book is saved to a file )
var ( ReadTimeout = 40 * time.Second // this is just the default; it gets set by config upon initialization WriteTimeout = 80 * time.Second // this is just the default; it gets set by config upon initialization )
var File_p2p_proto protoreflect.FileDescriptor
Functions ¶
func ErrBadStream ¶
func ErrBannedCountry ¶
func ErrBannedID ¶
func ErrBannedIP ¶
func ErrChunkLargerThanMax ¶
func ErrConnDecryptFailed ¶
func ErrErrorGroup ¶
func ErrFailedChallenge ¶
func ErrFailedDial ¶
func ErrFailedDiffieHellman ¶
func ErrFailedHKDF ¶
func ErrFailedListen ¶
func ErrFailedMetaSwap ¶
func ErrFailedRead ¶
func ErrFailedSignatureSwap ¶
func ErrFailedWrite ¶
func ErrIPLookup ¶
func ErrIncompatiblePeer ¶
func ErrInvalidPublicKey ¶
func ErrIsBlacklisted ¶
func ErrMaxInbound ¶
func ErrMaxMessageSize ¶
func ErrMaxOutbound ¶
func ErrNonTCPAddress ¶
func ErrPeerAlreadyExists ¶
func ErrPeerNotFound ¶
func ErrPongTimeout ¶
Types ¶
type BookPeer ¶
type BookPeer struct {
// address: is the peer address object that holds identification and metadata about the peer
Address *lib.PeerAddress `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` // @gotags: json:"address"
// consecutive_failed_dial: is a churn management counter that tracks the number of consecutive failures
// enough consecutive fails, the BookPeer is evicted from the book
ConsecutiveFailedDial int32 `protobuf:"varint,2,opt,name=consecutive_failed_dial,json=consecutiveFailedDial,proto3" json:"consecutiveFailedDial"` // @gotags: json:"consecutiveFailedDial"
// contains filtered or unexported fields
}
BookPeer is the peer object held and saved in the peer book for persisted peer connectivity and exchange Peer or Address book: A collection of peers or network addresses that a node uses to discover and connect with other nodes in the network. This book helps nodes keep track of available peers for communication and maintaining network connectivity.
func (*BookPeer) Descriptor
deprecated
func (*BookPeer) GetAddress ¶
func (x *BookPeer) GetAddress() *lib.PeerAddress
func (*BookPeer) GetConsecutiveFailedDial ¶
func (*BookPeer) ProtoMessage ¶
func (*BookPeer) ProtoMessage()
func (*BookPeer) ProtoReflect ¶
func (x *BookPeer) ProtoReflect() protoreflect.Message
type EncryptedConn ¶
type EncryptedConn struct {
Address *lib.PeerAddress // authenticated remote peer information
// contains filtered or unexported fields
}
EncryptedConn is made of the underlying tcp connection, send and receive AEAD ciphers, and the peer address NOTE: receiving and sending have two distinct AEAD state objects for key / nonce management and simultaneous send/receive
func NewHandshake ¶
func NewHandshake(conn net.Conn, meta *lib.PeerMeta, privateKey crypto.PrivateKeyI) (encryptedConn *EncryptedConn, e lib.ErrorI)
NewHandshake() executes the authentication protocol between two tcp connections to result in an encryption connection
func (*EncryptedConn) Close ¶
func (c *EncryptedConn) Close() error
EncryptedConn satisfies the net.conn interface
func (*EncryptedConn) LocalAddr ¶
func (c *EncryptedConn) LocalAddr() net.Addr
func (*EncryptedConn) Read ¶
func (c *EncryptedConn) Read(data []byte) (n int, err error)
Read() checks the connection for cipher data bytes, if found, the func decrypts and loads them into the 'data' buffer
func (*EncryptedConn) RemoteAddr ¶
func (c *EncryptedConn) RemoteAddr() net.Addr
func (*EncryptedConn) SetDeadline ¶
func (c *EncryptedConn) SetDeadline(t time.Time) error
func (*EncryptedConn) SetReadDeadline ¶
func (c *EncryptedConn) SetReadDeadline(t time.Time) error
func (*EncryptedConn) SetWriteDeadline ¶
func (c *EncryptedConn) SetWriteDeadline(t time.Time) error
type Envelope ¶
type Envelope struct {
// payload: is a generic proto.message
Payload *anypb.Any `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
// contains filtered or unexported fields
}
***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)
Protobuf is a language-neutral, platform-neutral serialization format. It allows users to define objects in a way that’s both efficient to store and fast to transmit over the network. These definitions are compiled into code that *enables different systems and programming languages to communicate in a byte-perfect manner*
To update these structures, make changes to the source .proto files, then recompile to regenerate this file. These auto-generated files are easily recognized by checking for a `.pb.go` ending ***************************************************************************************************** _ _ _ Enveloper is a generic wrapper over a proto.message for the P2P module to handle Envelopes are first used to wrap bytes into a Packet, Ping, or Pong Then later is used to wrap a Packet.bytes into proto.Message
func (*Envelope) Descriptor
deprecated
func (*Envelope) GetPayload ¶
func (*Envelope) ProtoMessage ¶
func (*Envelope) ProtoMessage()
func (*Envelope) ProtoReflect ¶
func (x *Envelope) ProtoReflect() protoreflect.Message
type MultiConn ¶
type MultiConn struct {
Address *lib.PeerAddress // authenticated peer information
// contains filtered or unexported fields
}
MultiConn: A rate-limited, multiplexed connection that utilizes a series streams with varying priority for sending and receiving
func (*MultiConn) Error ¶
Error() when an error occurs on the MultiConn execute a callback. Optionally pass a reputation delta to slash the peer
type P2P ¶
type P2P struct {
PeerSet // active set
MustConnectsReceiver chan []*lib.PeerAddress
// contains filtered or unexported fields
}
func New ¶
func New(p crypto.PrivateKeyI, maxMembersPerCommittee uint64, m *lib.Metrics, c lib.Config, l lib.LoggerI) *P2P
New() creates an initialized pointer instance of a P2P object
func (*P2P) AddPeer ¶
func (p *P2P) AddPeer(conn net.Conn, info *lib.PeerInfo, disconnect, strictPublicKey bool) (err lib.ErrorI)
AddPeer() takes an ephemeral tcp connection and an incomplete peerInfo and attempts to create a E2E encrypted channel with a fully authenticated peer and save it to the peer set and the peer book
func (*P2P) DialAndDisconnect ¶
DialAndDisconnect() dials the peer but disconnects once a fully authenticated connection is established
func (*P2P) DialForOutboundPeers ¶
func (p *P2P) DialForOutboundPeers()
DialForOutboundPeers() uses the config and peer book to try to max out the outbound peer connections
func (*P2P) DialWithBackoff ¶
func (p *P2P) DialWithBackoff(peerInfo *lib.PeerAddress, strictPublicKey bool)
DialWithBackoff() dials the peer with exponential backoff retry
func (*P2P) GetBookPeers ¶
GetBookPeers() returns all peers in the PeerBook
func (*P2P) GetInboxStats ¶
GetInboxStats returns the current message count for each inbox channel This operation is non-blocking and safe to call concurrently
func (*P2P) Inbox ¶
func (p *P2P) Inbox(topic lib.Topic) chan *lib.MessageAndMetadata
Inbox() is a getter for the multiplexed stream with a specific topic
func (*P2P) IsSelf ¶
func (p *P2P) IsSelf(a *lib.PeerAddress) bool
IsSelf() returns if the peer address public key equals the self public key
func (*P2P) ListenForInboundPeers ¶
func (p *P2P) ListenForInboundPeers(listenAddress *lib.PeerAddress)
ListenForInboundPeers() starts a rate-limited tcp listener service to accept inbound peers
func (*P2P) ListenForMustConnects ¶
func (p *P2P) ListenForMustConnects()
ListenForMustConnects() is an internal listener that receives 'must connect peers' updates from the controller
func (*P2P) ListenForPeerBookRequests ¶
func (p *P2P) ListenForPeerBookRequests()
ListenForPeerBookRequests()
func (*P2P) ListenForPeerBookResponses ¶
func (p *P2P) ListenForPeerBookResponses()
func (*P2P) MaxPossibleInbound ¶
MaxPossibleInbound() sums the MaxIn, MaxCommitteeConnects and trusted peer IDs
func (*P2P) MaxPossibleOutbound ¶
MaxPossibleOutbound() sums the MaxIn, MaxCommitteeConnects and trusted peer IDs
func (*P2P) MaxPossiblePeers ¶
MaxPossiblePeers() sums the MaxIn, MaxOut, MaxCommitteeConnects and trusted peer IDs
func (*P2P) MonitorInboxStats ¶
MonitorInboxStats continuously monitors and logs inbox channel depths without blocking message processing. Safe to run as a goroutine.
func (*P2P) NewConnection ¶
NewConnection() creates and starts a new instance of a MultiConn
func (*P2P) NewStreams ¶
NewStreams() creates map of streams for the multiplexing architecture
func (*P2P) OnPeerError ¶
OnPeerError() callback to P2P when a peer errors
func (*P2P) SendPeerBookRequests ¶
func (p *P2P) SendPeerBookRequests()
SendPeerBookRequests() is the requesting service of the peer exchange Sends a peer request out to a random peer and waits PeerBookRequestTimeoutS for a response
func (*P2P) StartPeerBookService ¶
func (p *P2P) StartPeerBookService()
StartPeerBookService() begins: - Peer Exchange service: exchange known peers with currently active set - Churn management service: evict inactive peers from the book - File save service: persist the book.json file periodically
func (*P2P) WaitForMinimumPeers ¶
func (p *P2P) WaitForMinimumPeers()
WaitForMinimumPeers() doesn't return until the minimum peer count is reached This may be useful when coordinating network starts
type Packet ¶
type Packet struct {
// stream_id: the identifier of the stream/topic that this packet belongs to, used for multiplexing
StreamId lib.Topic `protobuf:"varint,1,opt,name=stream_id,json=streamId,proto3,enum=types.Topic" json:"streamID"` // @gotags: json:"streamID"
// eof: indicates whether this is the last packet of the message (EOF = true) or if more packets will follow (EOF = false)
Eof bool `protobuf:"varint,2,opt,name=eof,proto3" json:"eof,omitempty"`
// bytes: the actual message data transferred in this packet. It could represent the entire message or just a part of it
Bytes []byte `protobuf:"bytes,3,opt,name=bytes,proto3" json:"bytes,omitempty"`
// contains filtered or unexported fields
}
A Packet is a part of a message (or the entire message) that is associated with a specific stream topic and includes an EOF signal
func (*Packet) Descriptor
deprecated
func (*Packet) GetStreamId ¶
func (*Packet) ProtoMessage ¶
func (*Packet) ProtoMessage()
func (*Packet) ProtoReflect ¶
func (x *Packet) ProtoReflect() protoreflect.Message
type Peer ¶
type Peer struct {
*lib.PeerInfo // authenticated information of the peer
// contains filtered or unexported fields
}
Peer is a multiplexed connection + authenticated peer information
type PeerBook ¶
type PeerBook struct {
Book []*BookPeer `json:"book"` // persisted list of peers
BookSize int `json:"bookSize"` // number of peers in the book
// contains filtered or unexported fields
}
PeerBook is a persisted structure that maintains information on potential peers
func NewPeerBook ¶
NewPeerBook() instantiates a PeerBook object from a file, it creates a file if none exist
func (*PeerBook) AddFailedDialAttempt ¶
func (p *PeerBook) AddFailedDialAttempt(address *lib.PeerAddress)
AddFailedDialAttempt() increments the failed dial attempt counter for a BookPeer
func (*PeerBook) DeleteAtIndex ¶
func (p *PeerBook) DeleteAtIndex(address *lib.PeerAddress)
AddFailedDialAttempt() increments the failed dial attempt counter for a BookPeer
func (*PeerBook) GetBookSize ¶
GetBookSize() returns the book peer count
func (*PeerBook) GetRandom ¶
GetRandom() returns a random peer from the Book that has a specific chain in the Meta
func (*PeerBook) Remove ¶
func (p *PeerBook) Remove(address *lib.PeerAddress)
Remove() a peer from the book
func (*PeerBook) ResetFailedDialAttempts ¶
func (p *PeerBook) ResetFailedDialAttempts(address *lib.PeerAddress)
ResetFailedDialAttempts() resets the failed dial attempt count for the peer
func (*PeerBook) SaveRoutine ¶
func (p *PeerBook) SaveRoutine()
SaveRoutine() periodically saves the book to a json file
func (*PeerBook) StartChurnManagement ¶
func (p *PeerBook) StartChurnManagement(dialAndDisconnect func(a *lib.PeerAddress, strictPublicKey bool) lib.ErrorI)
StartChurnManagement() evicts inactive peers from the PeerBook by periodically attempting to connect with each peer
func (*PeerBook) WriteToFile ¶
WriteToFile() saves the peer book object to a json file
type PeerBookRequestMessage ¶
type PeerBookRequestMessage struct {
// contains filtered or unexported fields
}
PeerBookRequest is a peer exchange request message that enables new peer discovery via swapping
func (*PeerBookRequestMessage) Descriptor
deprecated
func (*PeerBookRequestMessage) Descriptor() ([]byte, []int)
Deprecated: Use PeerBookRequestMessage.ProtoReflect.Descriptor instead.
func (*PeerBookRequestMessage) ProtoMessage ¶
func (*PeerBookRequestMessage) ProtoMessage()
func (*PeerBookRequestMessage) ProtoReflect ¶
func (x *PeerBookRequestMessage) ProtoReflect() protoreflect.Message
func (*PeerBookRequestMessage) Reset ¶
func (x *PeerBookRequestMessage) Reset()
func (*PeerBookRequestMessage) String ¶
func (x *PeerBookRequestMessage) String() string
type PeerBookResponseMessage ¶
type PeerBookResponseMessage struct {
// book: randomly selected peers to exchange with the requester peer
Book []*BookPeer `protobuf:"bytes,1,rep,name=book,proto3" json:"book,omitempty"`
// contains filtered or unexported fields
}
PeerBookResponseMessage is a peer exchange response message sent back after receiving a PeerBookRequestMessage The peer will select some random peers from their PeerBook to reply with
func (*PeerBookResponseMessage) Descriptor
deprecated
func (*PeerBookResponseMessage) Descriptor() ([]byte, []int)
Deprecated: Use PeerBookResponseMessage.ProtoReflect.Descriptor instead.
func (*PeerBookResponseMessage) GetBook ¶
func (x *PeerBookResponseMessage) GetBook() []*BookPeer
func (*PeerBookResponseMessage) ProtoMessage ¶
func (*PeerBookResponseMessage) ProtoMessage()
func (*PeerBookResponseMessage) ProtoReflect ¶
func (x *PeerBookResponseMessage) ProtoReflect() protoreflect.Message
func (*PeerBookResponseMessage) Reset ¶
func (x *PeerBookResponseMessage) Reset()
func (*PeerBookResponseMessage) String ¶
func (x *PeerBookResponseMessage) String() string
type PeerSet ¶
type PeerSet struct {
sync.RWMutex // read / write mutex
// contains filtered or unexported fields
}
PeerSet is the structure that maintains the connections and metadata of connected peers
func NewPeerSet ¶
func (*PeerSet) ChangeReputation ¶
ChangeReputation() updates the peer reputation +/- based on the int32 delta
func (*PeerSet) GetAllInfos ¶
GetAllInfos() returns the information on connected peers and the total inbound / outbound counts
func (*PeerSet) GetPeerInfo ¶
GetPeerInfo() returns a copy of the authenticated information from the peer structure
func (*PeerSet) IsMustConnect ¶
IsMustConnect() checks if a peer is on the must-connect list
func (*PeerSet) SendToPeers ¶
func (ps *PeerSet) SendToPeers(topic lib.Topic, msg proto.Message, excludeKeys ...string) lib.ErrorI
SendToPeers() sends a message to all peers
func (*PeerSet) SendToRandPeer ¶
SendToRandPeer() sends a message to any random peer on the list
func (*PeerSet) UpdateMustConnects ¶
func (ps *PeerSet) UpdateMustConnects(mustConnect []*lib.PeerAddress) (toDial []*lib.PeerAddress)
UpdateMustConnects() updates the list of peers that 'must be connected to' Ex. the peers needed to complete committee consensus