bitswaphelpers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyRegisterd = errors.New("already registered")

ErrAlreadyRegistered means something has already been registered for a retrieval id

View Source
var ErrNotRegistered = errors.New("not registered")

ErrAlreadyRegistered means there is nothing registered for a retrieval id

View Source
var ErrNotSupported = errors.New("not supported")

ErrNotSupported indicates an operation not supported by the MultiBlockstore

Functions

func NewByteCountingLinkSystem

func NewByteCountingLinkSystem(lsys *linking.LinkSystem, bytesWritten func(count uint64)) *linking.LinkSystem

Types

type InProgressCids

type InProgressCids struct {
	// contains filtered or unexported fields
}

func NewInProgressCids

func NewInProgressCids() *InProgressCids

func (*InProgressCids) Dec

func (ipc *InProgressCids) Dec(c cid.Cid, retrievalID types.RetrievalID)

func (*InProgressCids) Get

func (ipc *InProgressCids) Get(c cid.Cid) []types.RetrievalID

func (*InProgressCids) Inc

func (ipc *InProgressCids) Inc(c cid.Cid, retrievalID types.RetrievalID)

type IndexerRouting

type IndexerRouting struct {
	routinghelpers.Null
	// contains filtered or unexported fields
}

IndexerRouting provides an interface that satisfies routing.Routing but only returns provider records based on a preset set of providers read from the context key. Bitswap will potentially make multiple FindProvidersAsync requests, and the cid passed will not always be the root As a result, we have to rely on the retrieval id within a context key Also while there is a delegated routing client that talks to the indexer, we use this cause we run it on top of the processing we're doing at a higher level with multiprotocol filtering

func NewIndexerRouting

func NewIndexerRouting(toRetrievalID func(cid.Cid) []types.RetrievalID) *IndexerRouting

NewIndexerRouting makes a new indexer routing instance

func (*IndexerRouting) AddProviders

func (ir *IndexerRouting) AddProviders(retrievalID types.RetrievalID, providers []types.RetrievalCandidate)

AddProviders adds provider records to the total list for a given retrieval id

func (*IndexerRouting) FindProvidersAsync

func (ir *IndexerRouting) FindProvidersAsync(ctx context.Context, c cid.Cid, max int) <-chan peer.AddrInfo

FindProvidersAsync returns providers based on the retrieval id in a context key It returns a channel with up to `max` providers, keeping the others around for a future call TODO: there is a slight risk that go-bitswap, which dedups requests by CID across multiple sessions, could accidentally read the wrong retrieval id if two retrievals were running at the same time. Not sure how much of a risk this really is, cause when requests are deduped, both calls still receive the results. See go-bitswap ProviderQueryManager for more specifics

func (*IndexerRouting) RemoveProviders

func (ir *IndexerRouting) RemoveProviders(retrievalID types.RetrievalID)

RemoveProviders removes all provider records for a given retrieval id

type MultiBlockstore

type MultiBlockstore struct {
	// contains filtered or unexported fields
}

MultiBlockstore creates a blockstore based on one or more linkystems, extracting the target linksystem for each request from the retrieval id context key

func NewMultiblockstore

func NewMultiblockstore() *MultiBlockstore

NewMultiblockstore returns a new MultiBlockstore

func (*MultiBlockstore) AddLinkSystem

func (mbs *MultiBlockstore) AddLinkSystem(id types.RetrievalID, lsys *linking.LinkSystem) error

AddLinkSystem registers a linksystem to use for a given retrieval id

func (*MultiBlockstore) AllKeysChan

func (mbs *MultiBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

AllKeysChan is unsupported

func (*MultiBlockstore) DeleteBlock

func (mbs *MultiBlockstore) DeleteBlock(ctx context.Context, c cid.Cid) error

DeleteBlock is not supported

func (*MultiBlockstore) Get

func (mbs *MultiBlockstore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error)

Get returns a block only if the given ctx contains a retrieval ID as a value that references a known linksystem. If it does, it uses that linksystem to load the block

func (*MultiBlockstore) GetSize

func (mbs *MultiBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error)

GetSize is unsupported

func (*MultiBlockstore) Has

func (mbs *MultiBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)

Has is not supported

func (*MultiBlockstore) HashOnRead

func (mbs *MultiBlockstore) HashOnRead(enabled bool)

HashOnRead is unsupported

func (*MultiBlockstore) Put

func (mbs *MultiBlockstore) Put(ctx context.Context, blk blocks.Block) error

Put writes a block only if the given ctx contains a retrieval ID as a value that references a known linksystem. If it does, it uses that linksystem to save the block

func (*MultiBlockstore) PutMany

func (mbs *MultiBlockstore) PutMany(ctx context.Context, blks []blocks.Block) error

PutMany puts a slice of blocks at the same time, with the same rules as Put

func (*MultiBlockstore) RemoveLinkSystem

func (mbs *MultiBlockstore) RemoveLinkSystem(id types.RetrievalID)

RemoveLinkSystem unregisters the link system for a given retrieval id

Jump to

Keyboard shortcuts

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