Documentation ¶
Overview ¶
Package gc provides garbage collection for go-ipfs.
Index ¶
- Variables
- func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, ...) (*cid.Set, error)
- func Descendants(ctx context.Context, getLinks dag.GetLinks, set *cid.Set, roots []cid.Cid) error
- func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, ...) <-chan Result
- type CannotDeleteBlockError
- type CannotFetchLinksError
- type Result
Constants ¶
This section is empty.
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.
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 ¶
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 ¶
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 ¶
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.