From 6f22cffb6bada5024a1a7591800a1284ceec7247 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 30 Jul 2021 09:38:09 +0300 Subject: [PATCH] object visitor interface --- blockstore/splitstore/visitor.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 blockstore/splitstore/visitor.go diff --git a/blockstore/splitstore/visitor.go b/blockstore/splitstore/visitor.go new file mode 100644 index 000000000..4c9f1d49f --- /dev/null +++ b/blockstore/splitstore/visitor.go @@ -0,0 +1,28 @@ +package splitstore + +import ( + cid "github.com/ipfs/go-cid" +) + +// ObjectVisitor is an interface for deduplicating objects during walks +type ObjectVisitor interface { + Visit(cid.Cid) (bool, error) +} + +type noopVisitor struct{} + +var _ ObjectVisitor = (*noopVisitor)(nil) + +func (v *noopVisitor) Visit(_ cid.Cid) (bool, error) { + return true, nil +} + +type cidSetVisitor struct { + set *cid.Set +} + +var _ ObjectVisitor = (*cidSetVisitor)(nil) + +func (v *cidSetVisitor) Visit(c cid.Cid) (bool, error) { + return v.set.Visit(c), nil +}