From 271e3555a4d2b42c45d6f5c1aa42d0c67cfd5dc7 Mon Sep 17 00:00:00 2001 From: gammazero Date: Fri, 15 Sep 2023 01:51:35 -0700 Subject: [PATCH] Remove redundant data retrieval from linksystem The was a redundant check to see if data is already present in the linksystem storage. This PR removes it. --- dagsync/ipnisync/sync.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/dagsync/ipnisync/sync.go b/dagsync/ipnisync/sync.go index b400944..89a3def 100644 --- a/dagsync/ipnisync/sync.go +++ b/dagsync/ipnisync/sync.go @@ -246,18 +246,13 @@ func (s *Syncer) walkFetch(ctx context.Context, rootCid cid.Cid, sel selector.Se getMissingLs.TrustedStorage = true getMissingLs.StorageReadOpener = func(lc ipld.LinkContext, l ipld.Link) (io.Reader, error) { c := l.(cidlink.Link).Cid - r, err := s.sync.lsys.StorageReadOpener(lc, l) - if err == nil { - // Found block read opener, so return it. - traversalOrder = append(traversalOrder, c) - return r, nil - } - - if err = s.fetchBlock(ctx, c); err != nil { + // fetchBlock checks if the node is already present in storage. + err := s.fetchBlock(ctx, c) + if err != nil { return nil, fmt.Errorf("failed to fetch block for cid %s: %w", c, err) } - r, err = s.sync.lsys.StorageReadOpener(lc, l) + r, err := s.sync.lsys.StorageReadOpener(lc, l) if err == nil { traversalOrder = append(traversalOrder, c) }