Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 62e26e4

Browse files
committedJun 26, 2015
comment GC algo
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent 42a73fe commit 62e26e4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎pin/gc/gc.go

+10
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ func (gcs *GCSet) AddDag(ds dag.DAGService, root key.Key) error {
5050
return nil
5151
}
5252

53+
// GC performs a mark and sweep garbage collection of the blocks in the blockstore
54+
// first, it creates a 'marked' set and adds to it the following:
55+
// - all recursively pinned blocks, plus all of their descendants (recursively)
56+
// - all directly pinned blocks
57+
// - all blocks utilized internally by the pinner
58+
//
59+
// The routine then iterates over every block in the blockstore and
60+
// deletes any block that is not found in the marked set.
5361
func GC(ctx context.Context, bs bstore.Blockstore, pn pin.Pinner) (<-chan key.Key, error) {
5462
bsrv, err := bserv.New(bs, offline.Exchange(bs))
5563
if err != nil {
5664
return nil, err
5765
}
5866
ds := dag.NewDAGService(bsrv)
5967

68+
// GCSet currently implemented in memory, in the future, may be bloom filter or
69+
// disk backed to conserve memory.
6070
gcs := NewGCSet()
6171
for _, k := range pn.RecursiveKeys() {
6272
err := gcs.AddDag(ds, k)

0 commit comments

Comments
 (0)
Please sign in to comment.