Documentation ¶
Overview ¶
Package blockstoreutil provides utility functions for Blockstores.
Index ¶
- func FilterPinned(ctx context.Context, pins pin.Pinner, out chan<- interface{}, cids []cid.Cid) []cid.Cid
- func ProcRmOutput(next func() (interface{}, error), sout io.Writer, serr io.Writer) error
- func RmBlocks(ctx context.Context, blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, ...) (<-chan interface{}, error)
- type RemovedBlock
- type RmBlocksOpts
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 ¶
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 ¶
RemovedBlock is used to represent the result of removing a block. If a block was removed successfully, then the Error string will be empty. If a block could not be removed, then 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 ¶
RmBlocksOpts is used to wrap options for RmBlocks().