go-ipfs: github.com/ipfs/go-ipfs/pin/gc Index | Files

package gc

import "github.com/ipfs/go-ipfs/pin/gc"

Package gc provides garbage collection for go-ipfs.

Index

Package Files

gc.go

Variables

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.

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.

func ColoredSet Uses

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 Uses

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 Uses

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.

type CannotDeleteBlockError Uses

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 Uses

func (e *CannotDeleteBlockError) Error() string

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

type CannotFetchLinksError Uses

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 Uses

func (e *CannotFetchLinksError) Error() string

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

type Result Uses

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.

Package gc imports 14 packages (graph) and is imported by 31 packages. Updated 2019-08-19. Refresh now. Tools for package owners.