Example #1
0
func PinIndirectCB(p pin.ManualPinner) h.NodeCB {
	return func(n *dag.Node, last bool) error {
		k, err := n.Key()
		if err != nil {
			return err
		}

		p.PinWithMode(k, pin.Indirect)
		return nil
	}
}
Example #2
0
func basicGC(t *testing.T, bs blockstore.Blockstore, pins pin.ManualPinner) {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel() // in case error occurs during operation
	keychan, err := bs.AllKeysChan(ctx)
	if err != nil {
		t.Fatal(err)
	}
	for k := range keychan { // rely on AllKeysChan to close chan
		if !pins.IsPinned(k) {
			err := bs.DeleteBlock(k)
			if err != nil {
				t.Fatal(err)
			}
		}
	}
}
Example #3
0
func BasicPinnerCB(p pin.ManualPinner) h.NodeCB {
	return func(n *dag.Node, last bool) error {
		k, err := n.Key()
		if err != nil {
			return err
		}

		if last {
			p.PinWithMode(k, pin.Recursive)
			return p.Flush()
		} else {
			p.PinWithMode(k, pin.Indirect)
			return nil
		}
	}
}