gc

package
v0.0.0-...-8b9b725 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT Imports: 14 Imported by: 4

Documentation

Overview

Package gc provides garbage collection for go-ipfs.

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 a error creating the marked set because of a problem when finding descendants.

Functions

func ColoredSet

func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffortRoots []cid.Cid, output chan<- Result) (*cid.Set, error)

ColoredSet computes the set of nodes in the graph that are pinned by the pins in the given pinner.

func Descendants

func Descendants(ctx context.Context, getLinks dag.GetLinks, set *cid.Set, roots []cid.Cid) error

Descendants recursively finds all the descendants of the given roots and adds them to the given cid.Set, using the provided dag.GetLinks function to walk the tree.

func GC

func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn pin.Pinner, bestEffortRoots []cid.Cid) <-chan Result

GC performs a mark and sweep garbage collection of the blocks in the blockstore first, it creates a 'marked' set and adds to it the following: - all recursively pinned blocks, plus all of their descendants (recursively) - bestEffortRoots, plus all of its descendants (recursively) - all directly pinned blocks - all blocks utilized internally by the pinner

The routine then iterates over every block in the blockstore and deletes any block that is not found in the marked set.

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 Result

type Result struct {
	KeyRemoved cid.Cid
	Error      error
}

Result represents an incremental output from a garbage collection run. It contains either an error, or the cid of a removed object.

Jump to

Keyboard shortcuts

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