Back to

Package messagequeue

Latest Go to latest

The highest tagged major version is .

Published: Jun 1, 2020 | License: MIT | Module:


type DontHaveTimeoutManager

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier