From 0ecbee354611beb149952d3b568590d7c0c6ebd4 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Wed, 17 Feb 2021 11:36:15 -0800 Subject: [PATCH] feat(utils): add prefetch to IPFS --- testbed/testbed/utils/ipfs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testbed/testbed/utils/ipfs.go b/testbed/testbed/utils/ipfs.go index d82c320..70cc427 100644 --- a/testbed/testbed/utils/ipfs.go +++ b/testbed/testbed/utils/ipfs.go @@ -16,6 +16,7 @@ import ( "github.com/ipfs/go-datastore" files "github.com/ipfs/go-ipfs-files" ipld "github.com/ipfs/go-ipld-format" + "github.com/ipfs/go-merkledag" "github.com/ipfs/interface-go-ipfs-core/path" blockstore "github.com/ipfs/go-ipfs-blockstore" @@ -338,7 +339,7 @@ func (n *IPFSNode) ClearDatastore(ctx context.Context) error { //} //for _, r := range entries { // ds.Delete(datastore.NewKey(r.Key)) - //ds.Sync(datastore.NewKey(r.Key)) + //ds.Sync(datastore.NewKey(r.Key)) //} return nil } @@ -396,6 +397,10 @@ func (n *IPFSNode) Add(ctx context.Context, tmpFile files.Node) (cid.Cid, error) } func (n *IPFSNode) Fetch(ctx context.Context, c cid.Cid, _ []PeerInfo) (files.Node, error) { + err := merkledag.FetchGraph(ctx, c, n.API.DAG()) + if err != nil { + return nil, err + } fPath := path.IpfsPath(c) return n.API.Unixfs().Get(ctx, fPath) }