Skip to content

Commit 7d9cbcc

Browse files
authored
Merge pull request ipfs/go-bitswap#243 from ipfs/feat/update-deps
chore(dep): update This commit was moved from ipfs/go-bitswap@07ac318
2 parents bf9c0e6 + d9567a3 commit 7d9cbcc

File tree

10 files changed

+28
-33
lines changed

10 files changed

+28
-33
lines changed

bitswap/bitswap.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ func (bs *Bitswap) receiveBlocksFrom(ctx context.Context, from peer.ID, blks []b
382382

383383
if from != "" {
384384
for _, b := range wanted {
385-
log.Event(ctx, "Bitswap.GetBlockRequest.End", b.Cid())
385+
log.Debugw("Bitswap.GetBlockRequest.End", "cid", b.Cid())
386386
}
387387
}
388388

@@ -417,7 +417,7 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
417417
// Process blocks
418418
err := bs.receiveBlocksFrom(ctx, p, iblocks, haves, dontHaves)
419419
if err != nil {
420-
log.Warningf("ReceiveMessage recvBlockFrom error: %s", err)
420+
log.Warnf("ReceiveMessage recvBlockFrom error: %s", err)
421421
return
422422
}
423423
}

bitswap/internal/decision/engine_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"time"
1212

1313
lu "github.com/ipfs/go-bitswap/internal/logutil"
14+
"github.com/ipfs/go-bitswap/internal/testutil"
1415
message "github.com/ipfs/go-bitswap/message"
1516
pb "github.com/ipfs/go-bitswap/message/pb"
16-
"github.com/ipfs/go-bitswap/internal/testutil"
1717

1818
blocks "github.com/ipfs/go-block-format"
1919
cid "github.com/ipfs/go-cid"
@@ -1092,12 +1092,12 @@ func getNextEnvelope(e *Engine, next envChan, t time.Duration) (envChan, *Envelo
10921092
select {
10931093
case env, ok := <-next: // blocks till next envelope ready
10941094
if !ok {
1095-
log.Warningf("got closed channel")
1095+
log.Warnf("got closed channel")
10961096
return nil, nil
10971097
}
10981098
return nil, env
10991099
case <-ctx.Done():
1100-
// log.Warningf("got timeout")
1100+
// log.Warnf("got timeout")
11011101
}
11021102
return next, nil
11031103
}

bitswap/internal/getter/getter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func AsyncGetBlocks(ctx context.Context, sessctx context.Context, keys []cid.Cid
7777
remaining := cid.NewSet()
7878
promise := notif.Subscribe(ctx, keys...)
7979
for _, k := range keys {
80-
log.Event(ctx, "Bitswap.GetBlockRequest.Start", k)
80+
log.Debugw("Bitswap.GetBlockRequest.Start", "cid", k)
8181
remaining.Add(k)
8282
}
8383

bitswap/internal/session/peerresponsetracker.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (prt *peerResponseTracker) choose(peers []peer.ID) peer.ID {
4141
for _, p := range peers {
4242
counted += float64(prt.getPeerCount(p)) / float64(total)
4343
if counted > rnd {
44-
// log.Warningf(" chose %s from %s (%d) / %s (%d) with pivot %.2f",
44+
// log.Warnf(" chose %s from %s (%d) / %s (%d) with pivot %.2f",
4545
// lu.P(p), lu.P(peers[0]), prt.firstResponder[peers[0]], lu.P(peers[1]), prt.firstResponder[peers[1]], rnd)
4646
return p
4747
}
@@ -51,7 +51,7 @@ func (prt *peerResponseTracker) choose(peers []peer.ID) peer.ID {
5151
// math that doesn't quite cover the whole range of peers in the for loop
5252
// so just choose the last peer.
5353
index := len(peers) - 1
54-
// log.Warningf(" chose last (indx %d) %s from %s (%d) / %s (%d) with pivot %.2f",
54+
// log.Warnf(" chose last (indx %d) %s from %s (%d) / %s (%d) with pivot %.2f",
5555
// index, lu.P(peers[index]), lu.P(peers[0]), prt.firstResponder[peers[0]], lu.P(peers[1]), prt.firstResponder[peers[1]], rnd)
5656
return peers[index]
5757
}

bitswap/internal/session/session.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ func (s *Session) ReceiveFrom(from peer.ID, ks []cid.Cid, haves []cid.Cid, dontH
210210
// // log.Infof("Ses%d<-%s: %d blocks, %d haves, %d dont haves\n",
211211
// // s.id, from, len(interestedKs), len(wantedHaves), len(wantedDontHaves))
212212
// for _, c := range interestedKs {
213-
// log.Warningf("Ses%d %s<-%s: block %s\n", s.id, lu.P(s.self), lu.P(from), lu.C(c))
213+
// log.Warnf("Ses%d %s<-%s: block %s\n", s.id, lu.P(s.self), lu.P(from), lu.C(c))
214214
// }
215215
// for _, c := range haves {
216-
// log.Warningf("Ses%d %s<-%s: HAVE %s\n", s.id, lu.P(s.self), lu.P(from), lu.C(c))
216+
// log.Warnf("Ses%d %s<-%s: HAVE %s\n", s.id, lu.P(s.self), lu.P(from), lu.C(c))
217217
// }
218218
// for _, c := range dontHaves {
219-
// log.Warningf("Ses%d %s<-%s: DONT_HAVE %s\n", s.id, lu.P(s.self), lu.P(from), lu.C(c))
219+
// log.Warnf("Ses%d %s<-%s: DONT_HAVE %s\n", s.id, lu.P(s.self), lu.P(from), lu.C(c))
220220
// }
221221
// }
222222

@@ -306,9 +306,9 @@ func (s *Session) run(ctx context.Context) {
306306

307307
func (s *Session) handleIdleTick(ctx context.Context) {
308308
live := s.sw.PrepareBroadcast()
309-
// log.Warningf("\n\n\n\n\nSes%d: broadcast %d keys\n\n\n\n\n", s.id, len(live))
309+
// log.Warnf("\n\n\n\n\nSes%d: broadcast %d keys\n\n\n\n\n", s.id, len(live))
310310
// log.Infof("Ses%d: broadcast %d keys\n", s.id, len(live))
311-
log.Warningf("Ses%d: broadcast %d keys", s.id, len(live))
311+
log.Warnf("Ses%d: broadcast %d keys", s.id, len(live))
312312

313313
// Broadcast a want-have for the live wants to everyone we're connected to
314314
s.sprm.RecordPeerRequests(nil, live)
@@ -387,7 +387,7 @@ func (s *Session) resetIdleTick() {
387387
tickDelay = s.initialSearchDelay
388388
} else {
389389
avLat := s.latencyTrkr.averageLatency()
390-
// log.Warningf("averageLatency %s", avLat)
390+
// log.Warnf("averageLatency %s", avLat)
391391
tickDelay = s.baseTickDelay + (3 * avLat)
392392
}
393393
tickDelay = tickDelay * time.Duration(1+s.consecutiveTicks)

bitswap/internal/testutil/testutil.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package testutil
33
import (
44
"math/rand"
55

6-
bsmsg "github.com/ipfs/go-bitswap/message"
76
bssd "github.com/ipfs/go-bitswap/internal/sessiondata"
7+
bsmsg "github.com/ipfs/go-bitswap/message"
88
"github.com/ipfs/go-bitswap/wantlist"
99
blocks "github.com/ipfs/go-block-format"
1010
cid "github.com/ipfs/go-cid"

bitswap/internal/wantmanager/wantmanager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (wm *WantManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid.Ci
7575
// BroadcastWantHaves is called when want-haves should be broadcast to all
7676
// connected peers (as part of session discovery)
7777
func (wm *WantManager) BroadcastWantHaves(ctx context.Context, ses uint64, wantHaves []cid.Cid) {
78-
// log.Warningf("BroadcastWantHaves session%d: %s", ses, wantHaves)
78+
// log.Warnf("BroadcastWantHaves session%d: %s", ses, wantHaves)
7979

8080
// Record broadcast wants
8181
wm.bcwl.Add(wantHaves, ses)

bitswap/network/ipfs_impl.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (bsnet *impl) msgToStream(ctx context.Context, s network.Stream, msg bsmsg.
135135
}
136136

137137
if err := s.SetWriteDeadline(deadline); err != nil {
138-
log.Warningf("error setting deadline: %s", err)
138+
log.Warnf("error setting deadline: %s", err)
139139
}
140140

141141
// Older Bitswap versions use a slightly different wire format so we need
@@ -157,7 +157,7 @@ func (bsnet *impl) msgToStream(ctx context.Context, s network.Stream, msg bsmsg.
157157
}
158158

159159
if err := s.SetWriteDeadline(time.Time{}); err != nil {
160-
log.Warningf("error resetting deadline: %s", err)
160+
log.Warnf("error resetting deadline: %s", err)
161161
}
162162
return nil
163163
}

bitswap/network/ipfs_impl_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
"testing"
66
"time"
77

8+
tn "github.com/ipfs/go-bitswap/internal/testnet"
89
bsmsg "github.com/ipfs/go-bitswap/message"
910
pb "github.com/ipfs/go-bitswap/message/pb"
1011
bsnet "github.com/ipfs/go-bitswap/network"
11-
tn "github.com/ipfs/go-bitswap/internal/testnet"
1212
blocksutil "github.com/ipfs/go-ipfs-blocksutil"
1313
mockrouting "github.com/ipfs/go-ipfs-routing/mock"
1414

bitswap/workers.go

+9-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
bsmsg "github.com/ipfs/go-bitswap/message"
99
pb "github.com/ipfs/go-bitswap/message/pb"
1010
cid "github.com/ipfs/go-cid"
11-
logging "github.com/ipfs/go-log"
1211
process "github.com/jbenet/goprocess"
1312
procctx "github.com/jbenet/goprocess/context"
1413
)
@@ -41,10 +40,10 @@ func (bs *Bitswap) startWorkers(ctx context.Context, px process.Process) {
4140
}
4241

4342
func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
44-
idmap := logging.LoggableMap{"ID": id}
4543
defer log.Debug("bitswap task worker shutting down...")
44+
log := log.With("ID", id)
4645
for {
47-
log.Event(ctx, "Bitswap.TaskWorker.Loop", idmap)
46+
log.Debug("Bitswap.TaskWorker.Loop")
4847
select {
4948
case nextEnvelope := <-bs.engine.Outbox():
5049
select {
@@ -57,13 +56,10 @@ func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
5756
// TODO: Should only track *useful* messages in ledger
5857
outgoing := bsmsg.New(false)
5958
for _, block := range envelope.Message.Blocks() {
60-
log.Event(ctx, "Bitswap.TaskWorker.Work", logging.LoggableF(func() map[string]interface{} {
61-
return logging.LoggableMap{
62-
"ID": id,
63-
"Target": envelope.Peer.Pretty(),
64-
"Block": block.Cid().String(),
65-
}
66-
}))
59+
log.Debugw("Bitswap.TaskWorker.Work",
60+
"Target", envelope.Peer,
61+
"Block", block.Cid(),
62+
)
6763
outgoing.AddBlock(block)
6864
}
6965
for _, blockPresence := range envelope.Message.BlockPresences() {
@@ -143,9 +139,9 @@ func (bs *Bitswap) provideWorker(px process.Process) {
143139
// replace token when done
144140
<-limit
145141
}()
146-
ev := logging.LoggableMap{"ID": wid}
147142

148-
defer log.EventBegin(ctx, "Bitswap.ProvideWorker.Work", ev, k).Done()
143+
log.Debugw("Bitswap.ProvideWorker.Start", "ID", wid, "cid", k)
144+
defer log.Debugw("Bitswap.ProvideWorker.End", "ID", wid, "cid", k)
149145

150146
ctx, cancel := context.WithTimeout(ctx, provideTimeout) // timeout ctx
151147
defer cancel()
@@ -158,8 +154,7 @@ func (bs *Bitswap) provideWorker(px process.Process) {
158154
// worker spawner, reads from bs.provideKeys until it closes, spawning a
159155
// _ratelimited_ number of workers to handle each key.
160156
for wid := 2; ; wid++ {
161-
ev := logging.LoggableMap{"ID": 1}
162-
log.Event(ctx, "Bitswap.ProvideWorker.Loop", ev)
157+
log.Debug("Bitswap.ProvideWorker.Loop")
163158

164159
select {
165160
case <-px.Closing():

0 commit comments

Comments
 (0)