downloader

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

package downloader contains a cache for downloading blocks from a renterd node. A cache optimizes the number of in-flight requests to avoid overloading the node and caches blocks to avoid redundant downloads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockDownloader

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

BlockDownloader is a cache for downloading blocks from a renterd node. It limits the number of in-flight requests to avoid overloading the node and caches blocks to avoid redundant downloads.

For UnixFS nodes, it also prefetches linked blocks.

func NewBlockDownloader

func NewBlockDownloader(store MetadataStore, bucket string, cacheSize, workers int, workerClient *worker.Client, log *zap.Logger) (*BlockDownloader, error)

NewBlockDownloader creates a new BlockDownloader.

func (*BlockDownloader) Get

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

Get returns a block by CID.

type MetadataStore

type MetadataStore interface {
	BlockLocation(c cid.Cid) (bucket, key string, err error)
	BlockSiblings(c cid.Cid, max int) (siblings []cid.Cid, err error)
	BlockChildren(c cid.Cid, max int) (siblings []cid.Cid, err error)
}

A MetadataStore is a store for IPFS block metadata. It is used to optimize block downloads by prefetching linked blocks.

Jump to

Keyboard shortcuts

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