Documentation ¶
Overview ¶
package bitswap implements the IPFS Exchange interface with the BitSwap bilateral exchange protocol.
Index ¶
- Constants
- Variables
- func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork, ...) exchange.Interface
- type Bitswap
- func (bs *Bitswap) Close() error
- func (bs *Bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, error)
- func (bs *Bitswap) GetBlocks(ctx context.Context, keys []u.Key) (<-chan *blocks.Block, error)
- func (bs *Bitswap) GetWantlist() []u.Key
- func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error
- 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) (peer.ID, bsmsg.BitSwapMessage)
- func (bs *Bitswap) Stat() (*Stat, error)
- func (bs *Bitswap) WantlistForPeer(p peer.ID) []u.Key
- type Instance
- type SessionGenerator
- type Stat
Constants ¶
const (
HasBlockBufferSize = 256
)
Variables ¶
var TaskWorkerCount = 8
Functions ¶
func New ¶
func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork, bstore blockstore.Blockstore, nice bool) 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.
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 ¶
func (*Bitswap) HasBlock ¶
HasBlock announces the existance of a block to this bitswap service. The service will potentially notify its peers.
func (*Bitswap) PeerConnected ¶
Connected/Disconnected warns bitswap about peer connections
func (*Bitswap) PeerDisconnected ¶
Connected/Disconnected warns bitswap about peer connections
func (*Bitswap) ReceiveError ¶
func (*Bitswap) ReceiveMessage ¶
func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg.BitSwapMessage) ( peer.ID, bsmsg.BitSwapMessage)
TODO(brian): handle errors
type Instance ¶
type Instance struct { Peer peer.ID Exchange exchange.Interface // contains filtered or unexported fields }
func (*Instance) Blockstore ¶
func (i *Instance) Blockstore() blockstore.Blockstore
type SessionGenerator ¶
type SessionGenerator struct {
// contains filtered or unexported fields
}
TODO move this SessionGenerator to the core package and export it as the core generator
func NewTestSessionGenerator ¶
func NewTestSessionGenerator( net tn.Network) SessionGenerator
WARNING: this uses RandTestBogusIdentity DO NOT USE for NON TESTS!
func (*SessionGenerator) Close ¶
func (g *SessionGenerator) Close() error
func (*SessionGenerator) Instances ¶
func (g *SessionGenerator) Instances(n int) []Instance
func (*SessionGenerator) Next ¶
func (g *SessionGenerator) Next() Instance
Directories ¶
Path | Synopsis |
---|---|
package decision implements the decision engine for the bitswap service.
|
package decision implements the decision engine for the bitswap service. |
internal/pb
Package bitswap_message_pb is a generated protocol buffer package.
|
Package bitswap_message_pb is a generated protocol buffer package. |
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. |