gossip

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0, BSD-2-Clause Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotRunning is returned when a neighbor is added to a stopped or not yet started gossip manager.
	ErrNotRunning = errors.New("manager not running")
)

Functions

This section is empty.

Types

type BlockReceivedEvent

type BlockReceivedEvent struct {
	// The raw block.
	Data []byte
	// The sender of the block.
	Peer *peer.Peer
}

BlockReceivedEvent holds data about a block received event.

type Events

type Events struct {
	// Fired when a new block was received via the gossip protocol.
	BlockReceived *event.Event[*BlockReceivedEvent]
}

Events defines all the events related to the gossip protocol.

type LoadBlockFunc

type LoadBlockFunc func(blockId mesh_old.BlockID) ([]byte, error)

LoadBlockFunc defines a function that returns the block for the given id.

type Manager

type Manager struct {
	Events *Events
	// contains filtered or unexported fields
}

The Manager handles the connected neighbors.

func NewManager

func NewManager(p2pManager *p2p.Manager, f LoadBlockFunc, log *logger.Logger, opts ...ManagerOption) *Manager

NewManager creates a new Manager.

func (*Manager) BlockRequestWorkerPoolStatus

func (m *Manager) BlockRequestWorkerPoolStatus() (name string, load uint64)

BlockRequestWorkerPoolStatus returns the name and the load of the workerpool.

func (*Manager) BlockRequestsRateLimiter

func (m *Manager) BlockRequestsRateLimiter() *ratelimiter.PeerRateLimiter

BlockRequestsRateLimiter returns the block requests rate limiter instance used in the gossip manager.

func (*Manager) BlockWorkerPoolStatus

func (m *Manager) BlockWorkerPoolStatus() (name string, load uint64)

BlockWorkerPoolStatus returns the name and the load of the workerpool.

func (*Manager) BlocksRateLimiter

func (m *Manager) BlocksRateLimiter() *ratelimiter.PeerRateLimiter

BlocksRateLimiter returns the blocks rate limiter instance used in the gossip manager.

func (*Manager) RequestBlock

func (m *Manager) RequestBlock(blockID []byte, to ...identity.ID)

RequestBlock requests the block with the given id from the neighbors. If no peer is provided, all neighbors are queried.

func (*Manager) SendBlock

func (m *Manager) SendBlock(blkData []byte, to ...identity.ID)

SendBlock adds the given block the send queue of the neighbors. The actual send then happens asynchronously. If no peer is provided, it is send to all neighbors.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the manager and closes all established connections.

type ManagerOption

type ManagerOption func(m *Manager)

ManagerOption configures the Manager instance.

func WithBlockRequestsRateLimiter

func WithBlockRequestsRateLimiter(prl *ratelimiter.PeerRateLimiter) ManagerOption

WithBlockRequestsRateLimiter allows to set a PeerRateLimiter instance to be used as blocks requests rate limiter in the gossip manager.

func WithBlocksRateLimiter

func WithBlocksRateLimiter(prl *ratelimiter.PeerRateLimiter) ManagerOption

WithBlocksRateLimiter allows to set a PeerRateLimiter instance to be used as blocks rate limiter in the gossip manager.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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