Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #137 from ipfs/fire/logging
Browse files Browse the repository at this point in the history
Enchanced logging for bitswap
  • Loading branch information
Kubuxu committed Jun 14, 2019
2 parents 536feb6 + 4c5fb60 commit 008c693
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,11 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg

bs.updateReceiveCounters(b)
bs.sm.UpdateReceiveCounters(b)
log.Debugf("got block %s from %s", b, p)
log.Debugf("[recv] block; cid=%s, peer=%s", b.Cid(), p)

// skip received blocks that are not in the wantlist
if !bs.wm.IsWanted(b.Cid()) {
log.Debugf("[recv] block not in wantlist; cid=%s, peer=%s", b.Cid(), p)
return
}

Expand Down
3 changes: 2 additions & 1 deletion wantmanager/wantmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ func New(ctx context.Context, peerHandler PeerHandler) *WantManager {

// WantBlocks adds the given cids to the wantlist, tracked by the given session.
func (wm *WantManager) WantBlocks(ctx context.Context, ks []cid.Cid, peers []peer.ID, ses uint64) {
log.Infof("want blocks: %s", ks)
log.Debugf("[wantlist] want blocks; cids=%s, peers=%s, ses=%d", ks, peers, ses)
wm.addEntries(ctx, ks, peers, false, ses)
}

// CancelWants removes the given cids from the wantlist, tracked by the given session.
func (wm *WantManager) CancelWants(ctx context.Context, ks []cid.Cid, peers []peer.ID, ses uint64) {
log.Debugf("[wantlist] unwant blocks; cids=%s, peers=%s, ses=%d", ks, peers, ses)
wm.addEntries(context.Background(), ks, peers, true, ses)
}

Expand Down

0 comments on commit 008c693

Please sign in to comment.