Documentation ¶
Overview ¶
Package discovery contains the p2p peer discovery service (Reactor). The purpose of the peer discovery service is to gather peer lists from known peers, and attempt to fill out open peer connection slots in order to build out a fuller mesh.
The implementation of the peer discovery protocol is relatively simple. In essence, it pings a random peer at a specific interval (3s), for a list of their known peers (max 30). After receiving the list, and verifying it, the node attempts to establish outbound connections to the given peers.
Index ¶
Constants ¶
const ( // Channel is the unique channel for the peer discovery protocol Channel = byte(0x50) )
Variables ¶
var Package = amino.RegisterPackage(amino.NewPackage( "github.com/gnolang/gno/tm2/pkg/p2p/discovery", "p2p", amino.GetCallersDirname(), ). WithTypes( &Request{}, &Response{}, ), )
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message interface {
ValidateBasic() error
}
Message is the wrapper for the discovery message
type Option ¶
type Option func(*Reactor)
func WithDiscoveryInterval ¶
WithDiscoveryInterval sets the discovery crawl interval
type Reactor ¶
type Reactor struct { // This embed and the usage of "services" // like the peer discovery reactor highlight the // flipped design of the p2p package. // The peer exchange service needs to be instantiated _outside_ // the p2p module, because of this flipped design. // Peers communicate with each other through Reactor channels, // which are instantiated outside the p2p module p2p.BaseReactor // contains filtered or unexported fields }
Reactor wraps the logic for the peer exchange protocol
func NewReactor ¶
NewReactor creates a new peer discovery reactor
func (*Reactor) GetChannels ¶
func (r *Reactor) GetChannels() []*conn.ChannelDescriptor
GetChannels returns the channels associated with peer discovery
type Request ¶
type Request struct{}
Request is the peer discovery request. It is empty by design, since it's used as a notification type
func (*Request) ValidateBasic ¶
type Response ¶
type Response struct {
Peers []*types.NetAddress // the peer set returned by the peer
}
Response is the peer discovery response