Documentation ¶
Overview ¶
Package decision implements the decision engine for the bitswap service.
Index ¶
- type Engine
- func (e *Engine) LedgerForPeer(p peer.ID) *Receipt
- func (e *Engine) MessageReceived(ctx context.Context, p peer.ID, m bsmsg.BitSwapMessage)
- func (e *Engine) MessageSent(p peer.ID, m bsmsg.BitSwapMessage)
- func (e *Engine) Outbox() <-chan (<-chan *Envelope)
- func (e *Engine) PeerConnected(p peer.ID)
- func (e *Engine) PeerDisconnected(p peer.ID)
- func (e *Engine) Peers() []peer.ID
- func (e *Engine) ReceiveFrom(from peer.ID, blks []blocks.Block, haves []cid.Cid)
- func (e *Engine) SetSendDontHaves(send bool)
- func (e *Engine) StartWorkers(ctx context.Context, px process.Process)
- func (e *Engine) WantlistForPeer(p peer.ID) []wl.Entry
- type Envelope
- type PeerTagger
- type Receipt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine manages sending requested blocks to peers.
func NewEngine ¶
func NewEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger, self peer.ID) *Engine
NewEngine creates a new block sending engine for the given block store
func (*Engine) LedgerForPeer ¶
LedgerForPeer returns aggregated data about blocks swapped and communication with a given peer.
func (*Engine) MessageReceived ¶
MessageReceived is called when a message is received from a remote peer. For each item in the wantlist, add a want-have or want-block entry to the request queue (this is later popped off by the workerTasks)
func (*Engine) MessageSent ¶
func (e *Engine) MessageSent(p peer.ID, m bsmsg.BitSwapMessage)
MessageSent is called when a message has successfully been sent out, to record changes.
func (*Engine) PeerConnected ¶
PeerConnected is called when a new peer connects, meaning we should start sending blocks.
func (*Engine) PeerDisconnected ¶
PeerDisconnected is called when a peer disconnects.
func (*Engine) ReceiveFrom ¶
ReceiveFrom is called when new blocks are received and added to the block store, meaning there may be peers who want those blocks, so we should send the blocks to them.
func (*Engine) SetSendDontHaves ¶
SetSendDontHaves indicates what to do when the engine receives a want-block for a block that is not in the blockstore. Either - Send a DONT_HAVE message - Simply don't respond Older versions of Bitswap did not respond, so this allows us to simulate those older versions for testing.
func (*Engine) StartWorkers ¶
Start up workers to handle requests from other nodes for the data on this node
type Envelope ¶
type Envelope struct { // Peer is the intended recipient. Peer peer.ID // Message is the payload. Message bsmsg.BitSwapMessage // A callback to notify the decision queue that the task is complete Sent func() }
Envelope contains a message for a Peer.
type PeerTagger ¶
PeerTagger covers the methods on the connection manager used by the decision engine to tag peers