go-ipfs: github.com/ipfs/go-ipfs/blocks/blockstoreutil Index | Files

package blockstoreutil

import "github.com/ipfs/go-ipfs/blocks/blockstoreutil"

Package blockstoreutil provides utility functions for Blockstores.


Package Files


func FilterPinned Uses

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 Uses

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 Uses

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.

type RemovedBlock Uses

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 Uses

type RmBlocksOpts struct {
    Prefix string
    Quiet  bool
    Force  bool

RmBlocksOpts is used to wrap options for RmBlocks().

Package blockstoreutil imports 6 packages (graph) and is imported by 28 packages. Updated 2020-05-23. Refresh now. Tools for package owners.