Documentation ¶
Index ¶
- type Option
- func EngineBlockstoreWorkerCount(count int) Option
- func EngineTaskWorkerCount(count int) Option
- func MaxCidSize(n uint) Option
- func MaxOutstandingBytesPerPeer(count int) Option
- func MaxQueuedWantlistEntriesPerPeer(count uint) Option
- func SetSendDontHaves(send bool) Option
- func TaskWorkerCount(count int) Option
- func WithPeerBlockRequestFilter(pbrf decision.PeerBlockRequestFilter) Option
- func WithPeerLedger(peerLedger decision.PeerLedger) Option
- func WithScoreLedger(scoreLedger decision.ScoreLedger) Option
- func WithTargetMessageSize(tms int) Option
- func WithTaskComparator(comparator decision.TaskComparator) Option
- func WithTracer(tap tracer.Tracer) Option
- func WithWantHaveReplaceSize(size int) Option
- type PeerBlockRequestFilter
- type PeerEntry
- type PeerLedger
- type Receipt
- type ScoreLedger
- type ScorePeerFunc
- type Server
- func (bs *Server) Close()
- func (bs *Server) LedgerForPeer(p peer.ID) *decision.Receipt
- func (bs *Server) NotifyNewBlocks(ctx context.Context, blks ...blocks.Block) error
- func (bs *Server) PeerConnected(p peer.ID)
- func (bs *Server) PeerDisconnected(p peer.ID)
- func (*Server) ReceiveError(err error)
- func (bs *Server) ReceiveMessage(ctx context.Context, p peer.ID, incoming message.BitSwapMessage)
- func (bs *Server) ReceivedBlocks(from peer.ID, blks []blocks.Block)
- func (bs *Server) Stat() (Stat, error)
- func (bs *Server) WantlistForPeer(p peer.ID) []cid.Cid
- type Stat
- type TaskComparator
- type TaskInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Server)
func EngineBlockstoreWorkerCount ¶
EngineBlockstoreWorkerCount sets the number of worker threads used for blockstore operations in the decision engine
func EngineTaskWorkerCount ¶
EngineTaskWorkerCount sets the number of worker threads used inside the engine
func MaxCidSize ¶
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 ¶
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 ¶
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 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 This option is only used for testing.
func TaskWorkerCount ¶
func WithPeerBlockRequestFilter ¶
func WithPeerBlockRequestFilter(pbrf decision.PeerBlockRequestFilter) Option
func WithPeerLedger ¶ added in v0.24.3
func WithPeerLedger(peerLedger decision.PeerLedger) Option
WithPeerLedger configures the engine with a custom decision.PeerLedger.
func WithScoreLedger ¶
func WithScoreLedger(scoreLedger decision.ScoreLedger) Option
Configures the engine to use the given score decision logic.
func WithTargetMessageSize ¶
func WithTaskComparator ¶
func WithTaskComparator(comparator decision.TaskComparator) Option
WithTaskComparator configures custom task prioritization logic.
func WithTracer ¶
func WithWantHaveReplaceSize ¶ added in v0.24.3
WithWantHaveReplaceSize sets the maximum size of a block in bytes up to which the bitswap server will replace a WantHave with a WantBlock response.
Behavior:
- If size > 0: The server may send full blocks instead of just confirming possession for blocks up to the specified size.
- If size = 0: WantHave replacement is disabled entirely. This allows the server to skip reading block sizes during WantHave request processing, which can be more efficient if the data storage bills "possession" checks and "reads" differently.
Performance considerations:
- Enabling replacement (size > 0) may reduce network round-trips but requires checking block sizes for each WantHave request to decide if replacement should occur.
- Disabling replacement (size = 0) optimizes server performance by avoiding block size checks, potentially reducing infrastructure costs if possession checks are less expensive than full reads.
It defaults to defaults.DefaultWantHaveReplaceSize and the value may change in future releases.
Use this option to set explicit behavior to balance between network efficiency, server performance, and potential storage cost optimizations based on your specific use case and storage backend.
type PeerBlockRequestFilter ¶
type PeerBlockRequestFilter = decision.PeerBlockRequestFilter
type PeerLedger ¶ added in v0.24.3
type PeerLedger = decision.PeerLedger
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()
Close is called to shutdown the Server. Returns when all workers and decision engine have finished. Safe to calling multiple times/concurrently.
func (*Server) LedgerForPeer ¶
LedgerForPeer returns aggregated data about blocks swapped and communication with a given peer.
func (*Server) NotifyNewBlocks ¶
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 (*Server) PeerDisconnected ¶
func (*Server) ReceiveError ¶
func (*Server) ReceiveMessage ¶
func (*Server) ReceivedBlocks ¶
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) WantlistForPeer ¶
WantlistForPeer returns the currently understood list of blocks requested by a given peer.
type TaskComparator ¶
type TaskComparator = decision.TaskComparator