decision

package
v0.4.15-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

package decision implements the decision engine for the bitswap service.

Index

Constants

This section is empty.

Variables

View Source
var FIFO = func(a, b *peerRequestTask) bool {
	return a.created.Before(b.created)
}

FIFO is a basic task comparator that returns tasks in the order created.

View Source
var V1 = func(a, b *peerRequestTask) bool {
	if a.Target == b.Target {
		return a.Entry.Priority > b.Entry.Priority
	}
	return FIFO(a, b)
}

V1 respects the target peer's wantlist priority. For tasks involving different peers, the oldest task is prioritized.

Functions

This section is empty.

Types

type Engine

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

func NewEngine

func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine

func (*Engine) AddBlock added in v0.4.2

func (e *Engine) AddBlock(block blocks.Block)

func (*Engine) LedgerForPeer added in v0.4.5

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

func (*Engine) MessageReceived

func (e *Engine) MessageReceived(p peer.ID, m bsmsg.BitSwapMessage) error

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

func (*Engine) MessageSent

func (e *Engine) MessageSent(p peer.ID, m bsmsg.BitSwapMessage) error

func (*Engine) Outbox

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

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

func (*Engine) PeerConnected added in v0.4.10

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

func (*Engine) PeerDisconnected

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

func (*Engine) Peers

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

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

func (*Engine) WantlistForPeer added in v0.3.4

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

type Envelope

type Envelope struct {
	// Peer is the intended recipient
	Peer peer.ID

	// Block is the payload
	Block blocks.Block

	// A callback to notify the decision queue that the task is complete
	Sent func()
}

Envelope contains a message for a Peer

type Receipt added in v0.4.5

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

Jump to

Keyboard shortcuts

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