discovery

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContinuousKadDhtDiscoverer

func NewContinuousKadDhtDiscoverer(arg ArgKadDht) (*continuousKadDhtDiscoverer, error)

NewContinuousKadDhtDiscoverer creates a new kad-dht discovery type implementation initialPeersList can be nil or empty, no initial connection will be attempted, a warning message will appear

func NewHostWithConnectionManagement

func NewHostWithConnectionManagement(args ArgsHostWithConnectionManagement) (*hostWithConnectionManagement, error)

NewHostWithConnectionManagement returns a host wrapper able to decide if connection initiated to a peer will actually be kept or not

func NewOptimizedKadDhtDiscoverer

func NewOptimizedKadDhtDiscoverer(arg ArgKadDht) (*optimizedKadDhtDiscoverer, error)

NewOptimizedKadDhtDiscoverer creates an optimized kad-dht discovery type implementation initialPeersList can be nil or empty, no initial connection will be attempted, a warning message will appear This implementation uses a single process loop function able to carry multiple tasks synchronously

Types

type ArgKadDht

type ArgKadDht struct {
	Context                     context.Context
	Host                        ConnectableHost
	PeersRefreshInterval        time.Duration
	SeedersReconnectionInterval time.Duration
	ProtocolID                  string
	InitialPeersList            []string
	BucketSize                  uint32
	RoutingTableRefresh         time.Duration
	KddSharder                  p2p.Sharder
	ConnectionWatcher           p2p.ConnectionsWatcher
	NetworkType                 p2p.NetworkType
	Logger                      p2p.Logger
}

ArgKadDht represents the kad-dht config argument DTO

type ArgsHostWithConnectionManagement

type ArgsHostWithConnectionManagement struct {
	ConnectableHost    ConnectableHost
	Sharder            Sharder
	ConnectionsWatcher p2p.ConnectionsWatcher
}

ArgsHostWithConnectionManagement is the argument DTO used in the NewHostWithConnectionManagement function

type ConnectableHost

type ConnectableHost interface {
	host.Host
	ConnectToPeer(ctx context.Context, address string) error
	AddressToPeerInfo(address string) (*peer.AddrInfo, error)
	IsInterfaceNil() bool
}

ConnectableHost is an enhanced Host interface that has the ability to connect to a string address

type KadDhtHandler

type KadDhtHandler interface {
	Bootstrap(ctx context.Context) error
}

KadDhtHandler defines the behavior of a component that can find new peers in a p2p network through kad dht mechanism

type NilDiscoverer

type NilDiscoverer struct {
}

NilDiscoverer is the non-functional peer discoverer aimed to be used when peer discovery options are all disabled

func NewNilDiscoverer

func NewNilDiscoverer() *NilDiscoverer

NewNilDiscoverer creates a new NullDiscoverer implementation

func (*NilDiscoverer) Bootstrap

func (nd *NilDiscoverer) Bootstrap() error

Bootstrap will return nil. There is no implementation.

func (*NilDiscoverer) IsInterfaceNil

func (nd *NilDiscoverer) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*NilDiscoverer) Name

func (nd *NilDiscoverer) Name() string

Name returns a message which says no peer discovery mechanism is used

func (*NilDiscoverer) ReconnectToNetwork

func (nd *NilDiscoverer) ReconnectToNetwork(_ context.Context)

ReconnectToNetwork does nothing

type Sharder

type Sharder interface {
	ComputeEvictionList(pidList []peer.ID) []peer.ID
	Has(pid peer.ID, list []peer.ID) bool
	SetSeeders(addresses []string)
	IsSeeder(pid core.PeerID) bool
	IsInterfaceNil() bool
}

Sharder defines the eviction computing process of unwanted peers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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