store

package
v0.0.0-...-3303c59 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VirtualReadOption

func VirtualReadOption(ctx context.Context, enabled bool) context.Context

VirtualReadOption sets the virtual read option in the context

Types

type BlockDownloader

type BlockDownloader interface {
	Get(ctx context.Context, c cid.Cid) (blocks.Block, error)
}

type BlockStore

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

A BlockStore is a blockstore backed by a renterd node.

func NewBlockStore

func NewBlockStore(ctx core.Context, downloader BlockDownloader, metadata MetadataStore) (*BlockStore, error)

NewBlockStore creates a new blockstore backed by a renterd node

func (*BlockStore) AllKeysChan

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

AllKeysChan returns a channel from which the CIDs in the Blockstore can be read. It should respect the given context, closing the channel if it becomes Done.

func (*BlockStore) DeleteBlock

func (bs *BlockStore) DeleteBlock(ctx context.Context, c cid.Cid) error

DeleteBlock removes a given block from the blockstore.

func (*BlockStore) Get

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

Get returns a block by CID

func (*BlockStore) GetSize

func (bs *BlockStore) GetSize(ctx context.Context, c cid.Cid) (int, error)

GetSize returns the CIDs mapped BlockSize

func (*BlockStore) Has

func (bs *BlockStore) Has(ctx context.Context, c cid.Cid) (bool, error)

Has returns whether or not a given block is in the blockstore.

func (*BlockStore) HashOnRead

func (bs *BlockStore) HashOnRead(enabled bool)

HashOnRead specifies if every read block should be rehashed to make sure it matches its CID.

func (*BlockStore) Put

func (bs *BlockStore) Put(ctx context.Context, b blocks.Block) error

Put puts a given block to the underlying datastore

func (*BlockStore) PutMany

func (bs *BlockStore) PutMany(ctx context.Context, blocks []blocks.Block) error

PutMany puts a slice of blocks at the same time using batching capabilities of the underlying datastore whenever possible.

type ContextKey

type ContextKey string

ContextKey is a type for context keys

const (
	// VirtualReadKey is the context key for the virtual read option
	VirtualReadKey ContextKey = "virtualRead"
)

type MetadataStore

type MetadataStore interface {
	BlockExists(c cid.Cid) (err error)
	Pin(PinnedBlock) error
	Unpin(c cid.Cid) error
	Pinned(offset, limit int) (roots []cid.Cid, err error)
	Size(c cid.Cid) (uint64, error)
}

type MetadataStoreDefault

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

func NewMetadataStore

func NewMetadataStore(ctx core.Context) *MetadataStoreDefault

NewMetadataStore creates a new blockstore backed by a renterd node

func (*MetadataStoreDefault) BlockChildren

func (s *MetadataStoreDefault) BlockChildren(c cid.Cid, max *int) (children []cid.Cid, err error)

func (*MetadataStoreDefault) BlockExists

func (s *MetadataStoreDefault) BlockExists(c cid.Cid) error

func (*MetadataStoreDefault) BlockSiblings

func (s *MetadataStoreDefault) BlockSiblings(c cid.Cid, max int) (siblings []cid.Cid, err error)

func (*MetadataStoreDefault) GetUnixFSMetadata

func (s *MetadataStoreDefault) GetUnixFSMetadata(c cid.Cid) (*pluginDb.UnixFSNode, error)

func (*MetadataStoreDefault) MarkBlockReady

func (s *MetadataStoreDefault) MarkBlockReady(c cid.Cid, ready bool) error

func (*MetadataStoreDefault) Pin

Pin adds a block to the store.

func (*MetadataStoreDefault) Pinned

func (s *MetadataStoreDefault) Pinned(offset, limit int) (roots []cid.Cid, err error)

func (*MetadataStoreDefault) ProvideCIDs

func (s *MetadataStoreDefault) ProvideCIDs(limit int) (cids []ipfs.PinnedCID, err error)

func (*MetadataStoreDefault) SetLastAnnouncement

func (s *MetadataStoreDefault) SetLastAnnouncement(cids []cid.Cid, t time.Time) error

func (*MetadataStoreDefault) Size

func (s *MetadataStoreDefault) Size(c cid.Cid) (uint64, error)

func (*MetadataStoreDefault) Unpin

func (s *MetadataStoreDefault) Unpin(c cid.Cid) error

func (*MetadataStoreDefault) UpdateUnixFSMetadata

func (s *MetadataStoreDefault) UpdateUnixFSMetadata(c cid.Cid, metadata *pluginDb.UnixFSNode) error

type PinnedBlock

type PinnedBlock struct {
	Cid   cid.Cid   `json:"cid"`
	Links []cid.Cid `json:"links"`
	Size  uint64    `json:"size"`
	Node  format.Node
}

type VirtualBlockStore

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

VirtualBlockStore is a wrapper around a CachedBlockstore that can bypass the cache

func NewVirtualBlockStore

func NewVirtualBlockStore(ctx core.Context, directBS blockstore.Blockstore, cacheOpts blockstore.CacheOpts) (*VirtualBlockStore, error)

NewVirtualBlockStore creates a new VirtualBlockStore

func (*VirtualBlockStore) AllKeysChan

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

AllKeysChan returns a channel from which the CIDs in the Blockstore can be read

func (*VirtualBlockStore) DeleteBlock

func (v *VirtualBlockStore) DeleteBlock(ctx context.Context, c cid.Cid) error

DeleteBlock removes a given block from the blockstore

func (*VirtualBlockStore) Get

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

Get returns a block by CID

func (*VirtualBlockStore) GetSize

func (v *VirtualBlockStore) GetSize(ctx context.Context, c cid.Cid) (int, error)

GetSize returns the CIDs mapped BlockSize

func (*VirtualBlockStore) Has

func (v *VirtualBlockStore) Has(ctx context.Context, c cid.Cid) (bool, error)

Has returns whether or not a given block is in the blockstore

func (*VirtualBlockStore) HashOnRead

func (v *VirtualBlockStore) HashOnRead(enabled bool)

HashOnRead specifies if every read block should be rehashed to make sure it matches its CID

func (*VirtualBlockStore) Put

Put puts a given block to the underlying datastore

func (*VirtualBlockStore) PutMany

func (v *VirtualBlockStore) PutMany(ctx context.Context, bs []blocks.Block) error

PutMany puts a slice of blocks at the same time using batching

Directories

Path Synopsis
package downloader contains a cache for downloading blocks from a renterd node.
package downloader contains a cache for downloading blocks from a renterd node.

Jump to

Keyboard shortcuts

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