server

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

func EngineBlockstoreWorkerCount

func EngineBlockstoreWorkerCount(count int) Option

EngineBlockstoreWorkerCount sets the number of worker threads used for blockstore operations in the decision engine

func EngineTaskWorkerCount

func EngineTaskWorkerCount(count int) Option

EngineTaskWorkerCount sets the number of worker threads used inside the engine

func HasBlockBufferSize

func HasBlockBufferSize(count int) Option

HasBlockBufferSize configure how big the new blocks buffer should be.

func MaxCidSize added in v0.4.1

func MaxCidSize(n uint) Option

MaxCidSize limits how big CIDs we are willing to serve. We will ignore CIDs over this limit. It defaults to defaults.MaxCidSize. If it is 0 no limit is applied.

func MaxOutstandingBytesPerPeer

func MaxOutstandingBytesPerPeer(count int) Option

MaxOutstandingBytesPerPeer describes approximately how much work we are will to have outstanding to a peer at any given time. Setting it to 0 will disable any limiting.

func MaxQueuedWantlistEntriesPerPeer added in v0.4.1

func MaxQueuedWantlistEntriesPerPeer(count uint) Option

MaxQueuedWantlistEntriesPerPeer limits how much individual entries each peer is allowed to send. If a peer send us more than this we will truncate newest entries. It defaults to defaults.MaxQueuedWantlistEntiresPerPeer.

func ProvideEnabled

func ProvideEnabled(enabled bool) Option

ProvideEnabled is an option for enabling/disabling provide announcements

func SetSendDontHaves

func SetSendDontHaves(send bool) Option

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 This option is only used for testing.

func TaskWorkerCount

func TaskWorkerCount(count int) Option

func WithPeerBlockRequestFilter

func WithPeerBlockRequestFilter(pbrf decision.PeerBlockRequestFilter) Option

func WithScoreLedger

func WithScoreLedger(scoreLedger decision.ScoreLedger) Option

Configures the engine to use the given score decision logic.

func WithTargetMessageSize

func WithTargetMessageSize(tms int) Option

func WithTaskComparator

func WithTaskComparator(comparator decision.TaskComparator) Option

WithTaskComparator configures custom task prioritization logic.

func WithTracer

func WithTracer(tap tracer.Tracer) Option

type PeerBlockRequestFilter

type PeerBlockRequestFilter = decision.PeerBlockRequestFilter

type Receipt

type Receipt = decision.Receipt

type ScoreLedger

type ScoreLedger = decision.ScoreLedger

type ScorePeerFunc

type ScorePeerFunc = decision.ScorePeerFunc

type Server

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

func New

func New(ctx context.Context, network bsnet.BitSwapNetwork, bstore blockstore.Blockstore, options ...Option) *Server

func (*Server) Close

func (bs *Server) Close() error

Close is called to shutdown the Client

func (*Server) LedgerForPeer

func (bs *Server) LedgerForPeer(p peer.ID) *decision.Receipt

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

func (*Server) NotifyNewBlocks

func (bs *Server) NotifyNewBlocks(ctx context.Context, blks ...blocks.Block) error

NotifyNewBlocks announces the existence of blocks to this bitswap service. The service will potentially notify its peers. Bitswap itself doesn't store new blocks. It's the caller responsibility to ensure that those blocks are available in the blockstore before calling this function.

func (*Server) PeerConnected

func (bs *Server) PeerConnected(p peer.ID)

func (*Server) PeerDisconnected

func (bs *Server) PeerDisconnected(p peer.ID)

func (*Server) ReceiveError

func (*Server) ReceiveError(err error)

func (*Server) ReceiveMessage

func (bs *Server) ReceiveMessage(ctx context.Context, p peer.ID, incoming message.BitSwapMessage)

func (*Server) ReceivedBlocks

func (bs *Server) ReceivedBlocks(from peer.ID, blks []blocks.Block)

ReceivedBlocks notify the decision engine that a peer is well behaving and gave us usefull data, potentially increasing it's score and making us send them more data in exchange.

func (*Server) Stat

func (bs *Server) Stat() (Stat, error)

Stat returns aggregated statistics about bitswap operations

func (*Server) WantlistForPeer

func (bs *Server) WantlistForPeer(p peer.ID) []cid.Cid

WantlistForPeer returns the currently understood list of blocks requested by a given peer.

type Stat

type Stat struct {
	Peers         []string
	ProvideBufLen int
	BlocksSent    uint64
	DataSent      uint64
}

type TaskComparator

type TaskComparator = decision.TaskComparator

type TaskInfo

type TaskInfo = decision.TaskInfo

Directories

Path Synopsis
internal
decision
Package decision implements the decision engine for the bitswap service.
Package decision implements the decision engine for the bitswap service.

Jump to

Keyboard shortcuts

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