only construct bitswap event loggable if necessary
Base58 encoding cids/peerIDs isn't exactly fast. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Dec 29, 2017 at 13:00 UTC
914e653828b47c963cc15d3263f0f739380694a0
1 file changed
+7
-5
exchange/bitswap/workers.go
+7
-5
@@ -59,11 +59,13 @@ func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
59
if !ok {
60
continue
61
}
62
- log.Event(ctx, "Bitswap.TaskWorker.Work", logging.LoggableMap{
63
- "ID": id,
64
- "Target": envelope.Peer.Pretty(),
65
- "Block": envelope.Block.Cid().String(),
66
- })
62
+ log.Event(ctx, "Bitswap.TaskWorker.Work", logging.LoggableF(func() map[string]interface{} {
63
+ return logging.LoggableMap{
64
+ "ID": id,
65
+ "Target": envelope.Peer.Pretty(),
66
+ "Block": envelope.Block.Cid().String(),
67
+ }
68
+ }))
69
70
// update the BS ledger to reflect sent message
71
// TODO: Should only track *useful* messages in ledger