Documentation ¶
Index ¶
- func NewHostDecorator(h host.Host, ctx context.Context, cps uint32, timeout time.Duration) (*hostDecorator, error)
- func NewHostWithConnectionManagement(ch ConnectableHost, sharder Sharder) (*hostWithConnectionManagement, error)
- type ArgKadDht
- type ConnectableHost
- type ContinuousKadDhtDiscoverer
- func (ckdd *ContinuousKadDhtDiscoverer) Bootstrap() error
- func (ckdd *ContinuousKadDhtDiscoverer) IsInterfaceNil() bool
- func (ckdd *ContinuousKadDhtDiscoverer) Name() string
- func (ckdd *ContinuousKadDhtDiscoverer) ReconnectToNetwork() <-chan struct{}
- func (ckdd *ContinuousKadDhtDiscoverer) UpdateRandezVous(s string) error
- type KadDhtDiscoverer
- func (kdd *KadDhtDiscoverer) Bootstrap() error
- func (kdd *KadDhtDiscoverer) IsDiscoveryPaused() bool
- func (kdd *KadDhtDiscoverer) IsInterfaceNil() bool
- func (kdd *KadDhtDiscoverer) KickWatchdog() error
- func (kdd *KadDhtDiscoverer) Name() string
- func (kdd *KadDhtDiscoverer) Pause()
- func (kdd *KadDhtDiscoverer) ReconnectToNetwork() <-chan struct{}
- func (kdd *KadDhtDiscoverer) Resume()
- func (kdd *KadDhtDiscoverer) StartWatchdog(timeout time.Duration) error
- func (kdd *KadDhtDiscoverer) StopWatchdog() error
- func (kdd *KadDhtDiscoverer) UpdateRandezVous(s string) error
- type NilDiscoverer
- type Sharder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHostDecorator ¶
func NewHostDecorator(h host.Host, ctx context.Context, cps uint32, timeout time.Duration) (*hostDecorator, error)
NewHostDecorator creates a new decorator around an existing host (h) that will only allow cps connections per second and drop the connection request upon timeout expiration
func NewHostWithConnectionManagement ¶
func NewHostWithConnectionManagement(ch ConnectableHost, sharder Sharder) (*hostWithConnectionManagement, error)
NewHostWithConnectionManagement returns a host wrapper able to decide if connection initiated to a peer will actually be kept or not
Types ¶
type ArgKadDht ¶
type ArgKadDht struct { Context context.Context Host ConnectableHost PeersRefreshInterval time.Duration RandezVous string InitialPeersList []string BucketSize uint32 RoutingTableRefresh time.Duration KddSharder p2p.CommonSharder }
ArgKadDht represents the kad-dht config argument DTO
type ConnectableHost ¶
type ConnectableHost interface { host.Host ConnectToPeer(ctx context.Context, address string) error IsInterfaceNil() bool }
ConnectableHost is an enhanced Host interface that has the ability to connect to a string address
type ContinuousKadDhtDiscoverer ¶
type ContinuousKadDhtDiscoverer struct {
// contains filtered or unexported fields
}
ContinuousKadDhtDiscoverer is the kad-dht discovery type implementation This implementation does not support pausing and resuming of the discovery process
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 (*ContinuousKadDhtDiscoverer) Bootstrap ¶
func (ckdd *ContinuousKadDhtDiscoverer) Bootstrap() error
Bootstrap will start the bootstrapping new peers process
func (*ContinuousKadDhtDiscoverer) IsInterfaceNil ¶
func (ckdd *ContinuousKadDhtDiscoverer) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*ContinuousKadDhtDiscoverer) Name ¶
func (ckdd *ContinuousKadDhtDiscoverer) Name() string
Name returns the name of the kad dht peer discovery implementation
func (*ContinuousKadDhtDiscoverer) ReconnectToNetwork ¶
func (ckdd *ContinuousKadDhtDiscoverer) ReconnectToNetwork() <-chan struct{}
ReconnectToNetwork will try to connect to one peer from the initial peer list
func (*ContinuousKadDhtDiscoverer) UpdateRandezVous ¶
func (ckdd *ContinuousKadDhtDiscoverer) UpdateRandezVous(s string) error
UpdateRandezVous change the randezVous string, and restart the discovery with the new protocols
type KadDhtDiscoverer ¶
type KadDhtDiscoverer struct {
// contains filtered or unexported fields
}
KadDhtDiscoverer is the kad-dht discovery type implementation
func NewKadDhtPeerDiscoverer ¶
func NewKadDhtPeerDiscoverer(arg ArgKadDht) (*KadDhtDiscoverer, error)
NewKadDhtPeerDiscoverer 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 (*KadDhtDiscoverer) Bootstrap ¶
func (kdd *KadDhtDiscoverer) Bootstrap() error
Bootstrap will start the bootstrapping new peers process
func (*KadDhtDiscoverer) IsDiscoveryPaused ¶
func (kdd *KadDhtDiscoverer) IsDiscoveryPaused() bool
IsDiscoveryPaused will return true if the discoverer is initiating connections
func (*KadDhtDiscoverer) IsInterfaceNil ¶
func (kdd *KadDhtDiscoverer) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*KadDhtDiscoverer) KickWatchdog ¶
func (kdd *KadDhtDiscoverer) KickWatchdog() error
KickWatchdog extends the discovery resume timeout
func (*KadDhtDiscoverer) Name ¶
func (kdd *KadDhtDiscoverer) Name() string
Name returns the name of the kad dht peer discovery implementation
func (*KadDhtDiscoverer) Pause ¶
func (kdd *KadDhtDiscoverer) Pause()
Pause will suspend the discovery process
func (*KadDhtDiscoverer) ReconnectToNetwork ¶
func (kdd *KadDhtDiscoverer) ReconnectToNetwork() <-chan struct{}
ReconnectToNetwork will try to connect to one peer from the initial peer list
func (*KadDhtDiscoverer) Resume ¶
func (kdd *KadDhtDiscoverer) Resume()
Resume will resume the discovery process
func (*KadDhtDiscoverer) StartWatchdog ¶
func (kdd *KadDhtDiscoverer) StartWatchdog(timeout time.Duration) error
StartWatchdog start the watchdog
func (*KadDhtDiscoverer) StopWatchdog ¶
func (kdd *KadDhtDiscoverer) StopWatchdog() error
StopWatchdog stops the discovery watchdog
func (*KadDhtDiscoverer) UpdateRandezVous ¶
func (kdd *KadDhtDiscoverer) UpdateRandezVous(s string) error
UpdateRandezVous change the randezVous string, and restart the discovery with the new protocols
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() <-chan struct{}
ReconnectToNetwork returns an empty channel