Documentation ¶
Overview ¶
Package bitswap implements the IPFS exchange interface with the BitSwap bilateral exchange protocol.
Index ¶
- type BlockReceivedNotifier
- type Client
- func (bs *Client) Close() error
- func (bs *Client) GetBlock(ctx context.Context, k cid.Cid) (blocks.Block, error)
- func (bs *Client) GetBlocks(ctx context.Context, keys []cid.Cid) (<-chan blocks.Block, error)
- func (bs *Client) GetWantBlocks() []cid.Cid
- func (bs *Client) GetWantHaves() []cid.Cid
- func (bs *Client) GetWantlist() []cid.Cid
- func (bs *Client) IsOnline() bool
- func (bs *Client) NewSession(ctx context.Context) exchange.Fetcher
- func (bs *Client) NotifyNewBlocks(ctx context.Context, blks ...blocks.Block) error
- func (bs *Client) PeerConnected(p peer.ID)
- func (bs *Client) PeerDisconnected(p peer.ID)
- func (bs *Client) ReceiveError(err error)
- func (bs *Client) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg.BitSwapMessage)
- func (bs *Client) Stat() (st Stat, err error)
- type Option
- type Stat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockReceivedNotifier ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client instances implement the bitswap protocol.
func New ¶
func New(parent context.Context, network bsnet.BitSwapNetwork, bstore blockstore.Blockstore, options ...Option) *Client
New initializes a Bitswap client that runs until client.Close is called.
func (*Client) GetBlock ¶
GetBlock attempts to retrieve a particular block from peers within the deadline enforced by the context.
func (*Client) 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 (*Client) GetWantBlocks ¶
func (bs *Client) GetWantBlocks() []cid.Cid
GetWantBlocks returns the current list of want-blocks.
func (*Client) GetWantHaves ¶
func (bs *Client) GetWantHaves() []cid.Cid
GetWanthaves returns the current list of want-haves.
func (*Client) GetWantlist ¶
func (bs *Client) GetWantlist() []cid.Cid
GetWantlist returns the current local wantlist (both want-blocks and want-haves).
func (*Client) NewSession ¶
NewSession generates a new Bitswap session. You should use this, rather that calling Client.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 (*Client) NotifyNewBlocks ¶
NotifyNewBlocks announces the existence of blocks to this bitswap service. 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 (*Client) PeerConnected ¶
PeerConnected is called by the network interface when a peer initiates a new connection to bitswap.
func (*Client) PeerDisconnected ¶
PeerDisconnected is called by the network interface when a peer closes a connection
func (*Client) ReceiveError ¶
ReceiveError is called by the network interface when an error happens at the network layer. Currently just logs error.
func (*Client) ReceiveMessage ¶
ReceiveMessage is called by the network interface when a new message is received.
type Option ¶
type Option func(*Client)
Option defines the functional option type that can be used to configure bitswap instances
func ProviderSearchDelay ¶
ProviderSearchDelay overwrites the global provider search delay
func RebroadcastDelay ¶
RebroadcastDelay overwrites the global provider rebroadcast delay
func WithBlockReceivedNotifier ¶
func WithBlockReceivedNotifier(brn BlockReceivedNotifier) Option
func WithTracer ¶
Configures the Client to use given tracer. This provides methods to access all messages sent and received by the Client. This interface can be used to implement various statistics (this is original intent).
Directories ¶
Path | Synopsis |
---|---|
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. |