Documentation ¶
Index ¶
- func Fetch(ctx context.Context, exchg exchange.Interface, root *share.AxisRoots, ...) error
- func NewClient(ctx context.Context, net network.BitSwapNetwork, bstore blockstore.Blockstore) *client.Client
- func NewNetwork(host host.Host, prefix protocol.ID) network.BitSwapNetwork
- func NewServer(ctx context.Context, net network.BitSwapNetwork, bstore blockstore.Blockstore) *server.Server
- type AccessorGetter
- type Bitswap
- type Block
- type Blockstore
- func (b *Blockstore) AllKeysChan(context.Context) (<-chan cid.Cid, error)
- func (b *Blockstore) DeleteBlock(context.Context, cid.Cid) error
- func (b *Blockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)
- func (b *Blockstore) GetSize(_ context.Context, cid cid.Cid) (int, error)
- func (b *Blockstore) Has(ctx context.Context, cid cid.Cid) (bool, error)
- func (b *Blockstore) HashOnRead(bool)
- func (b *Blockstore) Put(context.Context, blocks.Block) error
- func (b *Blockstore) PutMany(context.Context, []blocks.Block) error
- type FetchOption
- type Getter
- func (g *Getter) GetEDS(ctx context.Context, hdr *header.ExtendedHeader) (*rsmt2d.ExtendedDataSquare, error)
- func (g *Getter) GetNamespaceData(ctx context.Context, hdr *header.ExtendedHeader, ns libshare.Namespace) (shwap.NamespaceData, error)
- func (g *Getter) GetSamples(ctx context.Context, hdr *header.ExtendedHeader, indices []shwap.SampleCoords) ([]shwap.Sample, error)
- func (g *Getter) Start()
- func (g *Getter) Stop()
- type RowBlock
- type RowNamespaceDataBlock
- func (rndb *RowNamespaceDataBlock) CID() cid.Cid
- func (rndb *RowNamespaceDataBlock) Height() uint64
- func (rndb *RowNamespaceDataBlock) Marshal() ([]byte, error)
- func (rndb *RowNamespaceDataBlock) Populate(ctx context.Context, eds eds.Accessor) error
- func (rndb *RowNamespaceDataBlock) UnmarshalFn(root *share.AxisRoots) UnmarshalFn
- type SampleBlock
- type UnmarshalFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fetch ¶
func Fetch( ctx context.Context, exchg exchange.Interface, root *share.AxisRoots, blks []Block, opts ...FetchOption, ) error
Fetch fetches and populates given Blocks using Fetcher wrapping Bitswap.
Validates Block against the given AxisRoots and skips Blocks that are already populated. Gracefully synchronize identical Blocks requested simultaneously. Blocks until either context is canceled or all Blocks are fetched and populated.
func NewClient ¶
func NewClient( ctx context.Context, net network.BitSwapNetwork, bstore blockstore.Blockstore, ) *client.Client
NewClient constructs a Bitswap client with parameters optimized for Shwap protocol composition. Meant to be used by Full and Light nodes.
func NewNetwork ¶
NewNetwork constructs Bitswap network for Shwap protocol composition.
func NewServer ¶
func NewServer( ctx context.Context, net network.BitSwapNetwork, bstore blockstore.Blockstore, ) *server.Server
NewServer construct a Bitswap server with parameters optimized for Shwap protocol composition. Meant to be used by Full nodes.
Types ¶
type AccessorGetter ¶
type AccessorGetter interface { // GetByHeight returns an Accessor by its height. GetByHeight(ctx context.Context, height uint64) (eds.AccessorStreamer, error) // HasByHeight reports whether an Accessor for the height exists. HasByHeight(ctx context.Context, height uint64) (bool, error) }
AccessorGetter abstracts storage system that indexes and manages multiple eds.AccessorGetter by network height.
type Bitswap ¶
func New ¶
func New( ctx context.Context, net network.BitSwapNetwork, bstore blockstore.Blockstore, ) *Bitswap
type Block ¶
type Block interface { // CID returns Shwap ID of the Block formatted as CID. CID() cid.Cid // Height reports the Height of the Shwap container behind the Block. Height() uint64 // Populate fills up the Block with the Shwap container getting it out of the EDS // Accessor. Populate(context.Context, eds.Accessor) error // Marshal serializes bytes of the Shwap Container the Block holds. // MUST exclude the Shwap ID. Marshal() ([]byte, error) // UnmarshalFn returns closure that unmarshal the Block with the Shwap container. // Unmarshalling involves data validation against the given AxisRoots. UnmarshalFn(*share.AxisRoots) UnmarshalFn }
Block represents Bitswap compatible generalization over Shwap containers. All Shwap containers must have a registered wrapper implementing the interface in order to be compatible with Bitswap. NOTE: This is not a Blockchain block, but an IPFS/Bitswap block.
func EmptyBlock ¶
EmptyBlock constructs an empty Block with type in the given CID.
type Blockstore ¶
type Blockstore struct {
Getter AccessorGetter
}
Blockstore implements generalized Bitswap compatible storage over Shwap containers that operates with Block and accesses data through AccessorGetter.
func (*Blockstore) AllKeysChan ¶
func (b *Blockstore) AllKeysChan(context.Context) (<-chan cid.Cid, error)
func (*Blockstore) DeleteBlock ¶
func (b *Blockstore) DeleteBlock(context.Context, cid.Cid) error
func (*Blockstore) GetSize ¶
func (b *Blockstore) GetSize(_ context.Context, cid cid.Cid) (int, error)
func (*Blockstore) HashOnRead ¶
func (b *Blockstore) HashOnRead(bool)
type FetchOption ¶
type FetchOption func(*fetchOptions)
func WithFetcher ¶
func WithFetcher(session exchange.Fetcher) FetchOption
WithFetcher instructs Fetch to use the given Fetcher. Useful for reusable Fetcher sessions.
func WithStore ¶
func WithStore(store blockstore.Blockstore) FetchOption
WithStore instructs Fetch to store all the fetched Blocks into the given Blockstore.
type Getter ¶
type Getter struct {
// contains filtered or unexported fields
}
Getter implements share.Getter.
func NewGetter ¶
func NewGetter( exchange exchange.SessionExchange, bstore blockstore.Blockstore, availWndw time.Duration, ) *Getter
NewGetter constructs a new Getter.
func (*Getter) GetEDS ¶
func (g *Getter) GetEDS( ctx context.Context, hdr *header.ExtendedHeader, ) (*rsmt2d.ExtendedDataSquare, error)
GetEDS uses RowBlock and Fetch to get half of the first EDS quadrant(ODS) and recomputes the whole EDS from it. We fetch the ODS or Q1 to ensure better compatibility with archival nodes that only store ODS and do not recompute other quadrants.
func (*Getter) GetNamespaceData ¶
func (g *Getter) GetNamespaceData( ctx context.Context, hdr *header.ExtendedHeader, ns libshare.Namespace, ) (shwap.NamespaceData, error)
GetNamespaceData uses RowNamespaceDataBlock and Fetch to get all the data by the given namespace. If data spans over multiple rows, the request is split into parallel RowNamespaceDataID requests per each row and then assembled back into NamespaceData.
func (*Getter) GetSamples ¶ added in v0.20.4
func (g *Getter) GetSamples( ctx context.Context, hdr *header.ExtendedHeader, indices []shwap.SampleCoords, ) ([]shwap.Sample, error)
GetSamples uses SampleBlock and Fetch to get and verify samples for given coordinates.
func (*Getter) Start ¶
func (g *Getter) Start()
Start kicks off internal fetching sessions.
We keep Bitswap sessions for the whole Getter lifespan:
- Sessions retain useful heuristics about peers, like TTFB
- Sessions prefer peers that previously served us related content.
So reusing session is expected to improve fetching performance.
There are two sessions for archival and available data, so archival node peers aren't mixed with regular full node peers.
type RowBlock ¶
RowBlock is a Bitswap compatible block for Shwap's Row container.
func EmptyRowBlockFromCID ¶
EmptyRowBlockFromCID constructs an empty RowBlock out of the CID.
func NewEmptyRowBlock ¶
NewEmptyRowBlock constructs a new empty RowBlock.
func (*RowBlock) UnmarshalFn ¶
func (rb *RowBlock) UnmarshalFn(root *share.AxisRoots) UnmarshalFn
type RowNamespaceDataBlock ¶
type RowNamespaceDataBlock struct { ID shwap.RowNamespaceDataID Container shwap.RowNamespaceData }
RowNamespaceDataBlock is a Bitswap compatible block for Shwap's RowNamespaceData container.
func EmptyRowNamespaceDataBlockFromCID ¶
func EmptyRowNamespaceDataBlockFromCID(cid cid.Cid) (*RowNamespaceDataBlock, error)
EmptyRowNamespaceDataBlockFromCID constructs an empty RowNamespaceDataBlock out of the CID.
func NewEmptyRowNamespaceDataBlock ¶
func NewEmptyRowNamespaceDataBlock( height uint64, rowIdx int, namespace libshare.Namespace, edsSize int, ) (*RowNamespaceDataBlock, error)
NewEmptyRowNamespaceDataBlock constructs a new empty RowNamespaceDataBlock.
func (*RowNamespaceDataBlock) CID ¶
func (rndb *RowNamespaceDataBlock) CID() cid.Cid
func (*RowNamespaceDataBlock) Height ¶
func (rndb *RowNamespaceDataBlock) Height() uint64
func (*RowNamespaceDataBlock) Marshal ¶
func (rndb *RowNamespaceDataBlock) Marshal() ([]byte, error)
func (*RowNamespaceDataBlock) UnmarshalFn ¶
func (rndb *RowNamespaceDataBlock) UnmarshalFn(root *share.AxisRoots) UnmarshalFn
type SampleBlock ¶
SampleBlock is a Bitswap compatible block for Shwap's Sample container.
func EmptySampleBlockFromCID ¶
func EmptySampleBlockFromCID(cid cid.Cid) (*SampleBlock, error)
EmptySampleBlockFromCID constructs an empty SampleBlock out of the CID.
func NewEmptySampleBlock ¶
func NewEmptySampleBlock(height uint64, idx shwap.SampleCoords, edsSize int) (*SampleBlock, error)
NewEmptySampleBlock constructs a new empty SampleBlock.
func (*SampleBlock) CID ¶
func (sb *SampleBlock) CID() cid.Cid
func (*SampleBlock) Height ¶
func (sb *SampleBlock) Height() uint64
func (*SampleBlock) Marshal ¶
func (sb *SampleBlock) Marshal() ([]byte, error)
func (*SampleBlock) UnmarshalFn ¶
func (sb *SampleBlock) UnmarshalFn(root *share.AxisRoots) UnmarshalFn
type UnmarshalFn ¶
UnmarshalFn is a closure produced by a Block that unmarshalls and validates the given serialized bytes of a Shwap container with ID and populates the Block with it on success.