gossip

package
v0.2.1-beta.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gossip implements simple protocol to send new validated messages to all peers and ignore old or not valid messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocol

type Protocol struct {
	log.Log
	// contains filtered or unexported fields
}

Protocol runs the gossip protocol using the given peers and service.

func NewProtocol

func NewProtocol(ctx context.Context, config config.SwarmConfig, base baseNetwork, peersManager peersManager, localNodePubkey p2pcrypto.PublicKey, logger log.Log) *Protocol

NewProtocol creates a new gossip protocol instance.

func (*Protocol) Broadcast

func (p *Protocol) Broadcast(ctx context.Context, payload []byte, nextProt string) error

Broadcast is the actual broadcast procedure - process the message internally and loop on peers and add the message to their queues

func (*Protocol) Close

func (p *Protocol) Close()

Close stops the protocol and waits for background workers to exit.

func (*Protocol) Relay

func (p *Protocol) Relay(ctx context.Context, sender p2pcrypto.PublicKey, protocol string, msg service.Data) error

Relay processes a message, if the message is new, it is passed for the protocol to validate and then propagated.

func (*Protocol) SetPriority

func (p *Protocol) SetPriority(protoName string, priority priorityq.Priority)

SetPriority sets the priority for protoName in the queue.

func (*Protocol) Start

func (p *Protocol) Start(ctx context.Context)

Start a loop that process peers events

Jump to

Keyboard shortcuts

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