Documentation ¶
Overview ¶
Package bitswap implements the IPFS exchange interface with the BitSwap bilateral exchange protocol.
Index ¶
- Variables
- func New(parent context.Context, network bsnet.BitSwapNetwork, ...) exchange.Interface
- type Bitswap
- func (bs *Bitswap) Close() error
- func (bs *Bitswap) GetBlock(parent context.Context, k cid.Cid) (blocks.Block, error)
- func (bs *Bitswap) GetBlocks(ctx context.Context, keys []cid.Cid) (<-chan blocks.Block, error)
- func (bs *Bitswap) GetWantlist() []cid.Cid
- func (bs *Bitswap) HasBlock(blk blocks.Block) error
- func (bs *Bitswap) IsOnline() bool
- func (bs *Bitswap) LedgerForPeer(p peer.ID) *decision.Receipt
- func (bs *Bitswap) NewSession(ctx context.Context) exchange.Fetcher
- func (bs *Bitswap) PeerConnected(p peer.ID)
- func (bs *Bitswap) PeerDisconnected(p peer.ID)
- func (bs *Bitswap) ReceiveError(err error)
- func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg.BitSwapMessage)
- func (bs *Bitswap) Stat() (*Stat, error)
- func (bs *Bitswap) WantlistForPeer(p peer.ID) []cid.Cid
- type Option
- type Stat
Constants ¶
This section is empty.
Variables ¶
var ( // HasBlockBufferSize is the buffer size of the channel for new blocks // that need to be provided. They should get pulled over by the // provideCollector even before they are actually provided. // TODO: Does this need to be this large givent that? HasBlockBufferSize = 256 )
var TaskWorkerCount = 8
TaskWorkerCount is the total number of simultaneous threads sending outgoing messages
var TicketWorkerCount = 4
TicketWorkerCount is the total number of si,ultaneous threads sending outgoing messages TODO: Judge the number of ticketworkers - Riften
Functions ¶
func New ¶
func New(parent context.Context, network bsnet.BitSwapNetwork, bstore blockstore.Blockstore, options ...Option) exchange.Interface
New initializes a BitSwap instance that communicates over the provided BitSwapNetwork. This function registers the returned instance as the network delegate. Runs until context is cancelled or bitswap.Close is called.
Types ¶
type Bitswap ¶
type Bitswap struct {
// contains filtered or unexported fields
}
Bitswap instances implement the bitswap protocol.
func (*Bitswap) GetBlock ¶
GetBlock attempts to retrieve a particular block from peers within the deadline enforced by the context.
func (*Bitswap) GetBlocks ¶
GetBlocks returns a channel where the caller may receive blocks that correspond to the provided |keys|. Returns an error if BitSwap is unable to begin this request within the deadline enforced by the context.
NB: Your request remains open until the context expires. To conserve resources, provide a context with a reasonably short deadline (ie. not one that lasts throughout the lifetime of the server)
func (*Bitswap) GetWantlist ¶
GetWantlist returns the current local wantlist.
func (*Bitswap) HasBlock ¶
HasBlock announces the existence of a block to this bitswap service. The service will potentially notify its peers.
func (*Bitswap) LedgerForPeer ¶
LedgerForPeer returns aggregated data about blocks swapped and communication with a given peer.
func (*Bitswap) NewSession ¶
NewSession generates a new Bitswap session. You should use this, rather that calling Bitswap.GetBlocks, any time you intend to do several related block requests in a row. The session returned will have it's own GetBlocks method, but the session will use the fact that the requests are related to be more efficient in its requests to peers. If you are using a session from go-blockservice, it will create a bitswap session automatically.
func (*Bitswap) PeerConnected ¶
PeerConnected is called by the network interface when a peer initiates a new connection to bitswap.
func (*Bitswap) PeerDisconnected ¶
PeerDisconnected is called by the network interface when a peer closes a connection
func (*Bitswap) ReceiveError ¶
ReceiveError is called by the network interface when an error happens at the network layer. Currently just logs error.
func (*Bitswap) ReceiveMessage ¶
ReceiveMessage is called by the network interface when a new message is received.
type Option ¶
type Option func(*Bitswap)
Option defines the functional option type that can be used to configure bitswap instances
func ProvideEnabled ¶
ProvideEnabled is an option for enabling/disabling provide announcements
func ProviderSearchDelay ¶
ProviderSearchDelay overwrites the global provider search delay
func RebroadcastDelay ¶
RebroadcastDelay overwrites the global provider rebroadcast delay
type Stat ¶
type Stat struct { ProvideBufLen int Wantlist []cid.Cid Peers []string BlocksReceived uint64 DataReceived uint64 BlocksSent uint64 DataSent uint64 DupBlksReceived uint64 DupDataReceived uint64 MessagesReceived uint64 }
Stat is a struct that provides various statistics on bitswap operations
Directories ¶
Path | Synopsis |
---|---|
Package decision implements the decision engine for the bitswap service.
|
Package decision implements the decision engine for the bitswap service. |
Package wantlist implements an object for bitswap that contains the keys that a given peer wants.
|
Package wantlist implements an object for bitswap that contains the keys that a given peer wants. |