Commit 4c5fb600 authored by Jakub Sztandera's avatar Jakub Sztandera

Enchanced logging for bitswap

License: MIT
Signed-off-by: default avatarJakub Sztandera <kubuxu@protonmail.ch>
parent 86089ee1
...@@ -334,10 +334,11 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg ...@@ -334,10 +334,11 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
bs.updateReceiveCounters(b) bs.updateReceiveCounters(b)
bs.sm.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 // skip received blocks that are not in the wantlist
if !bs.wm.IsWanted(b.Cid()) { if !bs.wm.IsWanted(b.Cid()) {
log.Debugf("[recv] block not in wantlist; cid=%s, peer=%s", b.Cid(), p)
return return
} }
......
...@@ -70,12 +70,13 @@ func New(ctx context.Context, peerHandler PeerHandler) *WantManager { ...@@ -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. // 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) { 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) wm.addEntries(ctx, ks, peers, false, ses)
} }
// CancelWants removes the given cids from the wantlist, tracked by the given session. // 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) { 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) wm.addEntries(context.Background(), ks, peers, true, ses)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment