basicserver

package
v0.0.0-...-20ef9fc Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotNetworkedEndpoint = errors.New("endpoint is not a NetworkedEndpoint")
	ErrUnknownMessageFormat = errors.New("unknown message format")
	ErrIpfsV1InvalidPeerID  = errors.New("IpfsV1 Message contains invalid peer.ID")
	ErrIpfsV1InvalidRequest = errors.New("IpfsV1 Message unknown request type")
	ErrSimMessageNilTarget  = errors.New("SimMessage target is nil")
)
View Source
var DefaultConfig = func(cfg *Config) error {
	cfg.PeerstoreTTL = 30 * time.Minute
	cfg.NumberUsefulCloserPeers = 20

	return nil
}

DefaultConfig is the default options for BasicServer. This option is always prepended to the list of options passed to the BasicServer constructor.

Functions

This section is empty.

Types

type BasicServer

type BasicServer[A kad.Address[A]] struct {
	// contains filtered or unexported fields
}

func NewBasicServer

func NewBasicServer[A kad.Address[A]](rt kad.RoutingTable[key.Key256, kad.NodeID[key.Key256]], endpoint endpoint.Endpoint[key.Key256, A],
	options ...Option,
) *BasicServer[A]

func (*BasicServer[A]) HandleFindNodeRequest

func (s *BasicServer[A]) HandleFindNodeRequest(ctx context.Context,
	rpeer kad.NodeID[key.Key256], msg kad.Message,
) (kad.Message, error)

func (*BasicServer[A]) HandleRequest

func (s *BasicServer[A]) HandleRequest(ctx context.Context, rpeer kad.NodeID[key.Key256],
	msg kad.Message,
) (kad.Message, error)

type Config

type Config struct {
	PeerstoreTTL            time.Duration
	NumberUsefulCloserPeers int
}

Config is a structure containing all the options that can be used when constructing a BasicServer.

func (*Config) Apply

func (cfg *Config) Apply(opts ...Option) error

Apply applies the BasicServer options to this Option

type Option

type Option func(*Config) error

Option type for BasicServer

func WithNumberUsefulCloserPeers

func WithNumberUsefulCloserPeers(n int) Option

func WithPeerstoreTTL

func WithPeerstoreTTL(ttl time.Duration) Option

Jump to

Keyboard shortcuts

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