peer

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSubnet        = id.Hash{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
	DefaultAlpha         = 5
	DefaultTimeout       = time.Second
	DefaultGossipTimeout = 3 * time.Second
)
View Source
var (
	ErrPeerNotFound = errors.New("peer not found")
)

Functions

This section is empty.

Types

type DiscoveryClient

type DiscoveryClient struct {
	// contains filtered or unexported fields
}

func NewDiscoveryClient

func NewDiscoveryClient(opts DiscoveryOptions, transport *transport.Transport) *DiscoveryClient

func (*DiscoveryClient) DidReceiveMessage

func (dc *DiscoveryClient) DidReceiveMessage(from id.Signatory, ipAddr net.Addr, msg wire.Msg) error

func (*DiscoveryClient) DiscoverPeers

func (dc *DiscoveryClient) DiscoverPeers(ctx context.Context)

type DiscoveryOptions

type DiscoveryOptions struct {
	Logger           *zap.Logger
	Alpha            int
	MaxExpectedPeers int
	PingTimePeriod   time.Duration
}

func DefaultDiscoveryOptions

func DefaultDiscoveryOptions() DiscoveryOptions

func (DiscoveryOptions) WithAlpha

func (opts DiscoveryOptions) WithAlpha(alpha int) DiscoveryOptions

func (DiscoveryOptions) WithLogger

func (opts DiscoveryOptions) WithLogger(logger *zap.Logger) DiscoveryOptions

func (DiscoveryOptions) WithMaxExpectedPeers

func (opts DiscoveryOptions) WithMaxExpectedPeers(max int) DiscoveryOptions

func (DiscoveryOptions) WithPingTimePeriod

func (opts DiscoveryOptions) WithPingTimePeriod(period time.Duration) DiscoveryOptions

type Gossiper

type Gossiper struct {
	// contains filtered or unexported fields
}

func NewGossiper

func NewGossiper(opts GossiperOptions, filter *channel.SyncFilter, transport *transport.Transport) *Gossiper

func (*Gossiper) DidReceiveMessage

func (g *Gossiper) DidReceiveMessage(from id.Signatory, msg wire.Msg) error

func (*Gossiper) Gossip

func (g *Gossiper) Gossip(ctx context.Context, contentID []byte, subnet *id.Hash)

func (*Gossiper) Resolve

func (g *Gossiper) Resolve(resolver dht.ContentResolver)

type GossiperOptions

type GossiperOptions struct {
	Logger  *zap.Logger
	Alpha   int
	Timeout time.Duration
}

func DefaultGossiperOptions

func DefaultGossiperOptions() GossiperOptions

func (GossiperOptions) WithAlpha

func (opts GossiperOptions) WithAlpha(alpha int) GossiperOptions

func (GossiperOptions) WithLogger

func (opts GossiperOptions) WithLogger(logger *zap.Logger) GossiperOptions

func (GossiperOptions) WithTimeout

func (opts GossiperOptions) WithTimeout(timeout time.Duration) GossiperOptions

type Options

type Options struct {
	SyncerOptions
	GossiperOptions
	DiscoveryOptions

	Logger  *zap.Logger
	PrivKey *id.PrivKey
}

func DefaultOptions

func DefaultOptions() Options

func (Options) WithDiscoveryOptions

func (opts Options) WithDiscoveryOptions(discoveryOptions DiscoveryOptions) Options

func (Options) WithGossiperOptions

func (opts Options) WithGossiperOptions(gossiperOptions GossiperOptions) Options

func (Options) WithLogger

func (opts Options) WithLogger(logger *zap.Logger) Options

func (Options) WithPrivKey

func (opts Options) WithPrivKey(privKey *id.PrivKey) Options

func (Options) WithSyncerOptions

func (opts Options) WithSyncerOptions(syncerOptions SyncerOptions) Options

type Peer

type Peer struct {
	// contains filtered or unexported fields
}

func New

func New(opts Options, transport *transport.Transport) *Peer

func (*Peer) DiscoverPeers

func (p *Peer) DiscoverPeers(ctx context.Context)

func (*Peer) Gossip

func (p *Peer) Gossip(ctx context.Context, contentID []byte, subnet *id.Hash)

func (*Peer) Gossiper

func (p *Peer) Gossiper() *Gossiper

func (*Peer) ID

func (p *Peer) ID() id.Signatory
func (p *Peer) Link(remote id.Signatory)

func (*Peer) Ping

func (p *Peer) Ping(ctx context.Context) error

func (*Peer) Receive

func (p *Peer) Receive(ctx context.Context, f func(id.Signatory, wire.Packet) error)

func (*Peer) Resolve

func (p *Peer) Resolve(ctx context.Context, contentResolver dht.ContentResolver)

func (*Peer) Run

func (p *Peer) Run(ctx context.Context)

func (*Peer) Send

func (p *Peer) Send(ctx context.Context, to id.Signatory, msg wire.Msg) error

func (*Peer) Sync

func (p *Peer) Sync(ctx context.Context, contentID []byte, hint *id.Signatory) ([]byte, error)

func (*Peer) Syncer

func (p *Peer) Syncer() *Syncer

func (*Peer) Transport

func (p *Peer) Transport() *transport.Transport
func (p *Peer) Unlink(remote id.Signatory)

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

func NewSyncer

func NewSyncer(opts SyncerOptions, filter *channel.SyncFilter, transport *transport.Transport) *Syncer

func (*Syncer) DidReceiveMessage

func (syncer *Syncer) DidReceiveMessage(from id.Signatory, msg wire.Msg) error

func (*Syncer) Sync

func (syncer *Syncer) Sync(ctx context.Context, contentID []byte, hint *id.Signatory) ([]byte, error)

type SyncerOptions

type SyncerOptions struct {
	Logger        *zap.Logger
	Alpha         int
	WiggleTimeout time.Duration
}

func DefaultSyncerOptions

func DefaultSyncerOptions() SyncerOptions

func (SyncerOptions) WithAlpha

func (opts SyncerOptions) WithAlpha(alpha int) SyncerOptions

func (SyncerOptions) WithLogger

func (opts SyncerOptions) WithLogger(logger *zap.Logger) SyncerOptions

func (SyncerOptions) WithWiggleTimeout

func (opts SyncerOptions) WithWiggleTimeout(timeout time.Duration) SyncerOptions

Jump to

Keyboard shortcuts

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