bitswap

package module
v0.0.0-...-3979291 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0, MIT Imports: 15 Imported by: 0

README

Selfish Bitswap Client

A minimal retrieve-only bitswap client

This client implements a minimal bitswap session that allows retrieval of CIDs from a single known peer.

Documentation

Usage
import (
	bitswap "github.com/willscott/go-selfish-bitswap-client"
)


session := bitswap.New(libp2p.Host, peer.ID)
defer session.Close()
bytes, err := session.Get(cid.Cid)

Lead Maintainer

willscott

Contributing

Contributions are welcome! This repository is governed by the ipfs contributing guidelines.

License

SPDX-License-Identifier: Apache-2.0 OR MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProtocolBitswapNoVers is a legacy bitswap protocol id
	ProtocolBitswapNoVers protocol.ID = "/ipfs/bitswap"
	// ProtocolBitswapOneZero is the prefix for the legacy bitswap protocol
	ProtocolBitswapOneZero protocol.ID = "/ipfs/bitswap/1.0.0"
	// ProtocolBitswapOneOne is the the prefix for version 1.1.0
	ProtocolBitswapOneOne protocol.ID = "/ipfs/bitswap/1.1.0"
	// ProtocolBitswap is the current version of the bitswap protocol: 1.2.0
	ProtocolBitswap protocol.ID = "/ipfs/bitswap/1.2.0"
)

Functions

This section is empty.

Types

type Session

type Session struct {
	host.Host
	// contains filtered or unexported fields
}

Session holds state for a related set of CID requests from a single remote peer

func New

func New(h host.Host, peer peer.ID) *Session

New initiates a bitswap retrieval session

func (*Session) Close

func (s *Session) Close() error

Close stops the session.

func (*Session) Get

func (s *Session) Get(c cid.Cid) ([]byte, error)

Get a specific block of data in this session.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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