dspinner

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Overview

Package dspinner implements structures and methods to keep track of which objects a user wants to keep stored locally. This implementation stores pin data in a datastore.

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotDeleteSomeBlocks = errors.New("garbage collection incomplete: could not delete some blocks")

ErrCannotDeleteSomeBlocks is returned when removing blocks marked for deletion fails as the last Result in GC output channel.

View Source
var ErrCannotFetchAllLinks = errors.New("garbage collection aborted: could not retrieve some links")

ErrCannotFetchAllLinks is returned as the last Result in the GC output channel when there was an error creating the marked set because of a problem when finding descendants.

Functions

func New

func New(ctx context.Context, dstore ds.Datastore, bs blockstore.Blockstore, dserv ipld.DAGService, bfOptions *ipfspinner.BloomFilterOptions) (*pinner, error)

New creates a new pinner and loads its keysets from the given datastore. If there is no data present in the datastore, then an empty pinner is returned.

By default, changes are automatically flushed to the datastore. This can be disabled by calling SetAutosync(false), which will require that Flush be called explicitly. bfOptions: bloom filter options, if nil, default options will be used,use for gc

func PrintMemUsage added in v0.2.7

func PrintMemUsage()

PrintMemUsage outputs the current, total and OS memory being used. As well as the number of garage collection cycles completed.

Types

type CannotDeleteBlockError

type CannotDeleteBlockError struct {
	Key cid.Cid
	Err error
}

CannotDeleteBlockError provides detailed information about which blocks could not be deleted and can appear as a Result in the GC output channel.

func (*CannotDeleteBlockError) Error

func (e *CannotDeleteBlockError) Error() string

Error implements the error interface for this type with a useful message.

type CannotFetchLinksError

type CannotFetchLinksError struct {
	Key cid.Cid
	Err error
}

CannotFetchLinksError provides detailed information about which links could not be fetched and can appear as a Result in the GC output channel.

func (*CannotFetchLinksError) Error

func (e *CannotFetchLinksError) Error() string

Error implements the error interface for this type with a useful message.

type Set

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

Set is a implementation of a set of Cids, that is, a structure to which holds a single copy of every Cids with encoded cid.Hash() with base58 that is added to it. use cid.Hash() with base58 to avoid collisions with different cid versions

func NewSet

func NewSet() *Set

NewSet initializes and returns a new Set.

func (*Set) Add

func (s *Set) Add(c cid.Cid)

Add puts a Cid in the Set.

func (*Set) ForEach

func (s *Set) ForEach(f func(c cid.Cid) error) error

ForEach allows to run a custom function on each Cid in the set.

func (*Set) Has

func (s *Set) Has(c cid.Cid) bool

Has returns if the Set contains a given Cid.

func (*Set) Keys

func (s *Set) Keys() []cid.Cid

Keys returns the Cids in the set.

func (*Set) Len

func (s *Set) Len() int

Len returns how many elements the Set has.

func (*Set) Remove

func (s *Set) Remove(c cid.Cid)

Remove deletes a Cid from the Set.

func (*Set) Visit

func (s *Set) Visit(c cid.Cid) bool

Visit adds a Cid to the set only if it is not in it already.

Jump to

Keyboard shortcuts

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