blockstoreutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 6 Imported by: 0

Documentation

Overview

Package blockstoreutil provides utility functions for Blockstores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterPinned

func FilterPinned(ctx context.Context, pins pin.Pinner, out chan<- interface{}, cids []cid.Cid) []cid.Cid

FilterPinned takes a slice of Cids and returns it with the pinned Cids removed. If a Cid is pinned, it will place RemovedBlock objects in the given out channel, with an error which indicates that the Cid is pinned. This function is used in RmBlocks to filter out any blocks which are not to be removed (because they are pinned).

func ProcRmOutput

func ProcRmOutput(next func() (interface{}, error), sout io.Writer, serr io.Writer) error

ProcRmOutput takes a function which returns a result from RmBlocks or EOF if there is no input. It then writes to stdout/stderr according to the RemovedBlock object returned from the function.

func RmBlocks

func RmBlocks(ctx context.Context, blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error)

RmBlocks removes the blocks provided in the cids slice. It returns a channel where objects of type RemovedBlock are placed, when not using the Quiet option. Block removal is asynchronous and will skip any pinned blocks.

Types

type RemovedBlock

type RemovedBlock struct {
	Hash  string `json:",omitempty"`
	Error string `json:",omitempty"`
}

RemovedBlock is used to represent the result of removing a block. If a block was removed successfully than the Error string will be empty. If a block could not be removed than Error will contain the reason the block could not be removed. If the removal was aborted due to a fatal error Hash will be empty, Error will contain the reason, and no more results will be sent.

type RmBlocksOpts

type RmBlocksOpts struct {
	Prefix string
	Quiet  bool
	Force  bool
}

RmBlocksOpts is used to wrap options for RmBlocks().

Jump to

Keyboard shortcuts

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