Skip to content

Commit

Permalink
Remove redundant data retrieval from linksystem (#117)
Browse files Browse the repository at this point in the history
The was a redundant check to see if data is already present in the linksystem storage. This PR removes it.
  • Loading branch information
gammazero authored Sep 15, 2023
1 parent 757d854 commit d276ae0
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions dagsync/ipnisync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d276ae0

Please sign in to comment.