Documentation ¶
Index ¶
- type DontHaveTimeoutManager
- type MessageNetwork
- type MessageQueue
- func (mq *MessageQueue) AddBroadcastWantHaves(wantHaves []cid.Cid)
- func (mq *MessageQueue) AddCancels(cancelKs []cid.Cid)
- func (mq *MessageQueue) AddWants(wantBlocks []cid.Cid, wantHaves []cid.Cid)
- func (mq *MessageQueue) RebroadcastNow()
- func (mq *MessageQueue) ResponseReceived(ks []cid.Cid)
- func (mq *MessageQueue) Shutdown()
- func (mq *MessageQueue) Startup()
- type OnDontHaveTimeout
- type PeerConnection
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 { Connect(context.Context, peer.AddrInfo) 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) RebroadcastNow ¶ added in v0.24.3
func (mq *MessageQueue) RebroadcastNow()
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) 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 ¶
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.