decision

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package decision implements the decision engine for the bitswap service.

Index

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, ts tickets.TicketStore) *Engine

NewEngine creates a new block sending engine for the given block store

func (*Engine) AddBlocks

func (e *Engine) AddBlocks(ctx context.Context, ks []cid.Cid)

AddBlocks is called when new blocks are received and added to a block store, meaning there may be peers who want those blocks, so we should send the blocks to them.

func (*Engine) LedgerForPeer

func (e *Engine) LedgerForPeer(p peer.ID) *Receipt

LedgerForPeer returns aggregated data about blocks swapped and communication with a given peer.

func (*Engine) MessageReceived

func (e *Engine) MessageReceived(ctx context.Context, p peer.ID, m bsmsg.BitSwapMessage)

MessageReceived performs book-keeping. Returns error if passed invalid arguments.

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) Outbox

func (e *Engine) Outbox() <-chan (<-chan *Envelope)

Outbox returns a channel of one-time use Envelope channels.

func (*Engine) PeerConnected

func (e *Engine) PeerConnected(p peer.ID)

PeerConnected is called when a new peer connects, meaning we should start sending blocks.

func (*Engine) PeerDisconnected

func (e *Engine) PeerDisconnected(p peer.ID)

PeerDisconnected is called when a peer disconnects.

func (*Engine) Peers

func (e *Engine) Peers() []peer.ID

Peers returns a slice of Peers with whom the local node has active sessions.

func (*Engine) SendTicketAcks

func (e *Engine) SendTicketAcks(target peer.ID, ticketAcks []tickets.TicketAck)

func (*Engine) SendTickets

func (e *Engine) SendTickets(target peer.ID, tickets []tickets.Ticket)

func (*Engine) StartWorkers

func (e *Engine) StartWorkers(ctx context.Context, px process.Process)

Start up workers to handle requests from other nodes for the data on this node

func (*Engine) TicketAckOutbox

func (e *Engine) TicketAckOutbox() chan *Envelope

func (*Engine) TicketOutbox

func (e *Engine) TicketOutbox() chan *Envelope

func (*Engine) WantlistForPeer

func (e *Engine) WantlistForPeer(p peer.ID) (out []wl.Entry)

WantlistForPeer returns the currently understood want list for a given peer

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

type PeerTagger interface {
	TagPeer(peer.ID, string, int)
	UntagPeer(p peer.ID, tag string)
}

PeerTagger covers the methods on the connection manager used by the decision engine to tag peers

type Receipt

type Receipt struct {
	Peer      string
	Value     float64
	Sent      uint64
	Recv      uint64
	Exchanged uint64
}

Receipt is a summary of the ledger for a given peer collecting various pieces of aggregated data for external reporting purposes.

Jump to

Keyboard shortcuts

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