Documentation ¶
Index ¶
- Constants
- Variables
- func NewClient(h host.Host, seed peer.AddrInfo, opts ...ClientOption) discovery.Discovery
- func NewServer(s *peerstore.Store) rpc.Server
- func ProtocolID() protocol.ID
- type AdvertiseRequest
- type AdvertiseResponse
- type ClientOption
- type ClientOptions
- type DiscoverRequest
- type DiscoverResponse
Constants ¶
View Source
const ( // ModuleName is a unique module name for the bootstrap discovery module. ModuleName = "p2p/discovery/bootstrap" // BootstrapProtocolName is the name for the bootstrap protocol. BootstrapProtocolName = "bootstrap" // MethodDiscover is the method name for the peer discovery handler. MethodDiscover = "discover" // MethodAdvertise is the method name for the service advertisement handler. MethodAdvertise = "advertise" // MaxPeers is the maximum number of peers the seed node will return. MaxPeers = 100 )
Variables ¶
View Source
var ( // ErrMethodNotSupported is an error raised when a given method is not supported. ErrMethodNotSupported = errors.New(ModuleName, 1, "bootstrap: method not supported") // ErrBadRequest is an error raised when a given request is malformed. ErrBadRequest = errors.New(ModuleName, 2, "bootstrap: bad request") // ErrMaliciousSeed is an error raised when a seed doesn't follow the bootstrap protocol. ErrMaliciousSeed = errors.New(ModuleName, 3, "bootstrap: malicious seed") // BootstrapProtocolVersion is the supported version of the bootstrap protocol. BootstrapProtocolVersion = version.Version{Major: 1, Minor: 0, Patch: 0} )
Functions ¶
func ProtocolID ¶
ProtocolID is a unique protocol identifier for the bootstrap protocol.
Types ¶
type AdvertiseRequest ¶
type AdvertiseRequest struct {
Namespace string `json:"namespace,omitempty"`
}
AdvertiseRequest is a message requesting seed to register the peer.
type AdvertiseResponse ¶
AdvertiseResponse is a message response with a deadline for the next registration.
type ClientOption ¶
type ClientOption func(opts *ClientOptions)
ClientOption is a client peer discovery option setter.
func WithRetentionPeriod ¶
func WithRetentionPeriod(retentionPeriod time.Duration) ClientOption
WithRetentionPeriod configures peer retention period.
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
ClientOptions are client's peer discovery options.
func DefaultClientOptions ¶
func DefaultClientOptions() *ClientOptions
DefaultClientOptions returns the default client options.
type DiscoverRequest ¶
type DiscoverRequest struct { Namespace string `json:"namespace,omitempty"` Limit int `json:"limit,omitempty"` }
DiscoverRequest is a message requesting peers.
type DiscoverResponse ¶
type DiscoverResponse struct {
Peers [][]byte `json:"peers,omitempty"`
}
DiscoverResponse is a message response with a list of json encoded peer addresses.
Click to show internal directories.
Click to hide internal directories.