Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockInfo ¶
type BlockInfo struct {
// contains filtered or unexported fields
}
BlockInfo keeps track of blocks in a CAR file
type BlockInfoCache ¶
type BlockInfoCache struct {
// contains filtered or unexported fields
}
BlockInfoCache keeps block info by cid
func NewBlockInfoCache ¶
func NewBlockInfoCache() *BlockInfoCache
func (*BlockInfoCache) Get ¶
func (bic *BlockInfoCache) Get(c cid.Cid) (*BlockInfo, bool)
func (*BlockInfoCache) Put ¶
func (bic *BlockInfoCache) Put(c cid.Cid, bi *BlockInfo)
type BlockInfoCacheManager ¶
type BlockInfoCacheManager interface { // Get the BlockInfoCache by payload cid Get(payloadCid cid.Cid) *BlockInfoCache // Unref is called when a request no longer needs the cache. // If err is not nil, the data transfer failed. Unref(payloadCid cid.Cid, err error) // Close the block info cache manager Close() error }
BlockInfoCacheManager gets a BlockInfoCache for a given payload cid. Implementations may wish to share the same cache between multiple requests for the same payload.
type CarOffsetWriter ¶
type CarOffsetWriter struct {
// contains filtered or unexported fields
}
CarOffsetWriter turns a blockstore and a root CID into a CAR file stream, starting from an offset. The traversal is depth-first. Other selectors are not yet supported.
func NewCarOffsetWriter ¶
func NewCarOffsetWriter(payloadCid cid.Cid, bstore blockstore.Blockstore, blockInfos *BlockInfoCache) *CarOffsetWriter
type CarReaderSeeker ¶
type CarReaderSeeker struct {
// contains filtered or unexported fields
}
CarReaderSeeker wraps CarOffsetWriter with a ReadSeeker implementation. Note that the Read and Seek methods are not thread-safe. They must not be called concurrently with each other, but may be called concurrently with Cancel.
func NewCarReaderSeeker ¶
func NewCarReaderSeeker(ctx context.Context, cow *CarOffsetWriter, size uint64) *CarReaderSeeker
func (*CarReaderSeeker) Cancel ¶
func (c *CarReaderSeeker) Cancel(ctx context.Context) error
Cancel aborts any read operation: Once Cancel returns, all subsequent calls to Read() will return context.Canceled Thread-safe to call concurrently with Read.
type DelayedUnrefBICM ¶
type DelayedUnrefBICM struct { *RefCountBICM // contains filtered or unexported fields }
DelayedUnrefBICM is like RefCountBCIM but if there was a data transfer error, the cache is not unrefed until after some delay. This is useful for the case where a connection goes down momentarily and then a new request is made (and we want to keep the cache for the new request).
func NewDelayedUnrefBICM ¶
func NewDelayedUnrefBICM(unrefDelay time.Duration) *DelayedUnrefBICM
func (*DelayedUnrefBICM) Close ¶
func (d *DelayedUnrefBICM) Close() error
func (*DelayedUnrefBICM) Unref ¶
func (d *DelayedUnrefBICM) Unref(payloadCid cid.Cid, err error)
type RefCountBICM ¶
type RefCountBICM struct {
// contains filtered or unexported fields
}
RefCountBICM keeps track of references to a BlockInfoCache by payload cid, and deletes the cache once references reach zero.
func NewRefCountBICM ¶
func NewRefCountBICM() *RefCountBICM
func (*RefCountBICM) Close ¶
func (bm *RefCountBICM) Close() error
func (*RefCountBICM) Get ¶
func (bm *RefCountBICM) Get(payloadCid cid.Cid) *BlockInfoCache
func (*RefCountBICM) Unref ¶
func (bm *RefCountBICM) Unref(payloadCid cid.Cid, err error)