Skip to content

Commit

Permalink
chore: cleanup, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Cihelka committed Oct 10, 2023
1 parent 0aee0d1 commit 662ca60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pkg/net/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (c BitswapClient) Retrieve(

// Starts with the root CID, then fetches a random CID from the children and grandchildren nodes, until it reaches `traverseDepth`
// Note: the root CID is considered depth `0`, so passing `traverseDepth=0` will only fetch the root CID
// Returns true if all retrievals were successful, false if any failed
func (c BitswapClient) SpadeTraversal(parent context.Context, startingCid cid.Cid, target peer.AddrInfo, traverseDepth uint) (*task.RetrievalResult, error) {
// Returns a `SuccessfulRetrievalResult` if *all* retrievals were successful, `ErrorRetrievalResult` if any failed
func (c BitswapClient) SpadeTraversal(parent context.Context, target peer.AddrInfo, startingCid cid.Cid, traverseDepth uint) (*task.RetrievalResult, error) {
logger := logging.Logger("bitswap_client_spade").With("cid", startingCid).With("target", target)
cidToRetrieve := startingCid

Expand All @@ -186,7 +186,7 @@ func (c BitswapClient) SpadeTraversal(parent context.Context, startingCid cid.Ci
client := NewBitswapClient(host, time.Second*1)

// Retrieval
logger.Debugf("retrieving %s\n", cidToRetrieve.String())
logger.Infof("retrieving %s\n", cidToRetrieve.String())
blk, err := client.RetrieveBlock(parent, target, cidToRetrieve)
if err != nil {
return task.NewErrorRetrievalResultWithErrorResolution(task.RetrievalFailure, err), nil
Expand Down Expand Up @@ -220,7 +220,7 @@ func (c BitswapClient) SpadeTraversal(parent context.Context, startingCid cid.Ci
if len(links) == 1 {
// Generally this should not happen as the root node should contain at least one AggregateManifest and other links
// however, there may be a different construction in the future where this is still valid, so we will attempt to retrieve
logger.Debugf("starting node contains only 1 link - will still attempt retrieval test")
logger.Info("starting node contains only 1 link - will still attempt retrieval test")
nextIndex = 0
} else {
// To be safe, never grab the first link off the root as it may refer to the AggregateManifest
Expand All @@ -240,7 +240,7 @@ func (c BitswapClient) SpadeTraversal(parent context.Context, startingCid cid.Ci
return task.NewErrorRetrievalResultWithErrorResolution(task.CIDCodecNotSupported, err), nil
}

i++
i++ // To the next layer of the tree
}
}

Expand Down
4 changes: 2 additions & 2 deletions worker/bitswap/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ func (e Worker) DoWork(tsk task.Task) (*task.RetrievalResult, error) {
return nil, errors.Wrap(err, "failed to parse traverse depth")
}

return client.SpadeTraversal(ctx, contentCID, peer.AddrInfo{
return client.SpadeTraversal(ctx, peer.AddrInfo{
ID: peerID,
Addrs: addrs,
}, uint(depth),
}, contentCID, uint(depth),
)
}

Expand Down

0 comments on commit 662ca60

Please sign in to comment.