messagequeue

package
v0.0.0-...-2745a11 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DontHaveTimeoutManager

type DontHaveTimeoutManager interface {
	// Start the manager (idempotent)
	Start()
	// Shutdown the manager (Shutdown is final, manager cannot be restarted)
	Shutdown()
	// AddPending adds the wants as pending a response. If the are not
	// cancelled before the timeout, the OnDontHaveTimeout method will be called.
	AddPending([]cid.Cid)
	// CancelPending removes the wants
	CancelPending([]cid.Cid)
	// UpdateMessageLatency informs the manager of a new latency measurement
	UpdateMessageLatency(time.Duration)
}

DontHaveTimeoutManager pings a peer to estimate latency so it can set a reasonable upper bound on when to consider a DONT_HAVE request as timed out (when connected to a peer that doesn't support DONT_HAVE messages)

type MessageNetwork

type MessageNetwork interface {
	ConnectTo(context.Context, peer.ID) error
	NewMessageSender(context.Context, peer.ID, *bsnet.MessageSenderOpts) (bsnet.MessageSender, error)
	Latency(peer.ID) time.Duration
	Ping(context.Context, peer.ID) ping.Result
	Self() peer.ID
}

MessageNetwork is any network that can connect peers and generate a message sender.

type MessageQueue

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

MessageQueue implements queue of want messages to send to peers.

func New

func New(ctx context.Context, p peer.ID, network MessageNetwork, onDontHaveTimeout OnDontHaveTimeout) *MessageQueue

New creates a new MessageQueue.

func (*MessageQueue) AddBroadcastWantHaves

func (mq *MessageQueue) AddBroadcastWantHaves(wantHaves []cid.Cid)

Add want-haves that are part of a broadcast to all connected peers

func (*MessageQueue) AddCancels

func (mq *MessageQueue) AddCancels(cancelKs []cid.Cid)

Add cancel messages for the given keys.

func (*MessageQueue) AddWants

func (mq *MessageQueue) AddWants(wantBlocks []cid.Cid, wantHaves []cid.Cid)

Add want-haves and want-blocks for the peer for this message queue.

func (*MessageQueue) ResponseReceived

func (mq *MessageQueue) ResponseReceived(ks []cid.Cid)

ResponseReceived is called when a message is received from the network. ks is the set of blocks, HAVEs and DONT_HAVEs in the message Note that this is just used to calculate latency.

func (*MessageQueue) SetRebroadcastInterval

func (mq *MessageQueue) SetRebroadcastInterval(delay time.Duration)

SetRebroadcastInterval sets a new interval on which to rebroadcast the full wantlist

func (*MessageQueue) Shutdown

func (mq *MessageQueue) Shutdown()

Shutdown stops the processing of messages for a message queue.

func (*MessageQueue) Startup

func (mq *MessageQueue) Startup()

Startup starts the processing of messages and rebroadcasting.

type OnDontHaveTimeout

type OnDontHaveTimeout func(peer.ID, []cid.Cid)

Fires when a timeout occurs waiting for a response from a peer running an older version of Bitswap that doesn't support DONT_HAVE messages.

type PeerConnection

type PeerConnection interface {
	// Ping the peer
	Ping(context.Context) ping.Result
	// The average latency of all pings
	Latency() time.Duration
}

PeerConnection is a connection to a peer that can be pinged, and the average latency measured

Jump to

Keyboard shortcuts

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