gossip

package
v0.4.0-3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAlpha   = 10
	DefaultBias    = 0.25
	DefaultTimeout = 5 * time.Second
)

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	ReceiveContent func(hash id.Hash, content []byte)
}

Callbacks implements the Listener interface by deferring all logic to closures. Closures that are nil will be gracefully ignored.

func (Callbacks) DidReceiveContent

func (cb Callbacks) DidReceiveContent(hash id.Hash, content []byte)

type ContentListener

type ContentListener interface {
	DidReceiveContent(hash id.Hash, content []byte)
}

type Gossiper

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

func New

func New(opts Options, dht dht.DHT, trans *transport.Transport, listener Listener) *Gossiper

func (*Gossiper) DidReceivePull

func (g *Gossiper) DidReceivePull(version uint8, data []byte, from id.Signatory) (wire.Message, error)

func (*Gossiper) DidReceivePullAck

func (g *Gossiper) DidReceivePullAck(version uint8, data []byte, from id.Signatory) error

func (*Gossiper) DidReceivePush

func (g *Gossiper) DidReceivePush(version uint8, data []byte, from id.Signatory) (wire.Message, error)

func (*Gossiper) DidReceivePushAck

func (g *Gossiper) DidReceivePushAck(version uint8, data []byte, from id.Signatory) error

func (*Gossiper) Gossip

func (g *Gossiper) Gossip(target, hash id.Hash)

Gossip a message throughout the network. The target can be the signatory in the DHT, or it can be a subnet in the DHT. If the target is a subnet, then the gossiper will attempt to deliver the message to all peers in the subnet. If the target is a signatory, then the gossiper will attempt to deliver the message to that specific peer. If the target is neither, the message will be dropped.

func (*Gossiper) Run

func (g *Gossiper) Run(ctx context.Context)

func (*Gossiper) Sync

func (g *Gossiper) Sync(subnet, hash id.Hash)

Sync a message from members of a particular Subnet.

type Listener

type Listener interface {
	ContentListener
}

type Options

type Options struct {
	Logger logrus.FieldLogger

	Alpha   int
	Bias    float64
	Timeout time.Duration
}

func DefaultOptions

func DefaultOptions() Options

func (Options) WithAlpha

func (opts Options) WithAlpha(alpha int) Options

func (Options) WithBias

func (opts Options) WithBias(bias float64) Options

func (Options) WithLogger

func (opts Options) WithLogger(logger logrus.FieldLogger) Options

func (Options) WithTimeout

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

Jump to

Keyboard shortcuts

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