bootstrap

package
v0.2300.10 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

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 NewClient

func NewClient(h host.Host, seed peer.AddrInfo, opts ...ClientOption) discovery.Discovery

NewClient creates a new bootstrap protocol client.

func NewServer

func NewServer(s *peerstore.Store) rpc.Server

NewServer creates a new bootstrap protocol server.

func ProtocolID

func ProtocolID() protocol.ID

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

type AdvertiseResponse struct {
	TTL time.Duration `json:"ttl,omitempty"`
}

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.

Jump to

Keyboard shortcuts

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