@cryptotaxi247 / kubo / commits / b8c96b250

log(dht) add eventlog.Update event

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Nov 22, 2014 at 20:02 UTC b8c96b25057f08909508efb2191f61d5ce865a0b
2 files changed +7 -7
routing/dht/dht.go
+4 -4
@@ -121,7 +121,7 @@ func (dht *IpfsDHT) Connect(ctx context.Context, npeer peer.Peer) (peer.Peer, er
121 return nil, fmt.Errorf("failed to ping newly connected peer: %s\n", err)
122 }
123
124 - dht.Update(npeer)
124 + dht.Update(ctx, npeer)
125
126 return npeer, nil
127 }
@@ -150,7 +150,7 @@ func (dht *IpfsDHT) HandleMessage(ctx context.Context, mes msg.NetMessage) msg.N
150 }
151
152 // update the peer (on valid msgs only)
153 - dht.Update(mPeer)
153 + dht.Update(ctx, mPeer)
154
155 log.Event(ctx, "foo", dht.self, mPeer, pmes)
156
@@ -397,8 +397,8 @@ func (dht *IpfsDHT) putLocal(key u.Key, value []byte) error {
397
398 // Update signals to all routingTables to Update their last-seen status
399 // on the given peer.
400 -func (dht *IpfsDHT) Update(p peer.Peer) {
401 - log.Debugf("updating peer: %s latency = %f\n", p, p.GetLatency().Seconds())
400 +func (dht *IpfsDHT) Update(ctx context.Context, p peer.Peer) {
401 + log.Event(ctx, "updatePeer", p)
402 removedCount := 0
403 for _, route := range dht.routingTables {
404 removed := route.Update(p)
routing/dht/ext_test.go
+3 -3
@@ -129,7 +129,7 @@ func TestGetFailures(t *testing.T) {
129
130 d := NewDHT(ctx, local, peerstore, fn, fs, ds.NewMapDatastore())
131 other := makePeer(nil)
132 - d.Update(other)
132 + d.Update(ctx, other)
133
134 // This one should time out
135 // u.POut("Timout Test\n")
@@ -232,7 +232,7 @@ func TestNotFound(t *testing.T) {
232 var ps []peer.Peer
233 for i := 0; i < 5; i++ {
234 ps = append(ps, _randPeer())
235 - d.Update(ps[i])
235 + d.Update(ctx, ps[i])
236 }
237
238 // Reply with random peers to every message
@@ -298,7 +298,7 @@ func TestLessThanKResponses(t *testing.T) {
298 var ps []peer.Peer
299 for i := 0; i < 5; i++ {
300 ps = append(ps, _randPeer())
301 - d.Update(ps[i])
301 + d.Update(ctx, ps[i])
302 }
303 other := _randPeer()
304