mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 23:42:20 +08:00
log(dht) add eventlog.Update event
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
@ -121,7 +121,7 @@ func (dht *IpfsDHT) Connect(ctx context.Context, npeer peer.Peer) (peer.Peer, er
|
||||
return nil, fmt.Errorf("failed to ping newly connected peer: %s\n", err)
|
||||
}
|
||||
|
||||
dht.Update(npeer)
|
||||
dht.Update(ctx, npeer)
|
||||
|
||||
return npeer, nil
|
||||
}
|
||||
@ -150,7 +150,7 @@ func (dht *IpfsDHT) HandleMessage(ctx context.Context, mes msg.NetMessage) msg.N
|
||||
}
|
||||
|
||||
// update the peer (on valid msgs only)
|
||||
dht.Update(mPeer)
|
||||
dht.Update(ctx, mPeer)
|
||||
|
||||
log.Event(ctx, "foo", dht.self, mPeer, pmes)
|
||||
|
||||
@ -397,8 +397,8 @@ func (dht *IpfsDHT) putLocal(key u.Key, value []byte) error {
|
||||
|
||||
// Update signals to all routingTables to Update their last-seen status
|
||||
// on the given peer.
|
||||
func (dht *IpfsDHT) Update(p peer.Peer) {
|
||||
log.Debugf("updating peer: %s latency = %f\n", p, p.GetLatency().Seconds())
|
||||
func (dht *IpfsDHT) Update(ctx context.Context, p peer.Peer) {
|
||||
log.Event(ctx, "updatePeer", p)
|
||||
removedCount := 0
|
||||
for _, route := range dht.routingTables {
|
||||
removed := route.Update(p)
|
||||
|
@ -129,7 +129,7 @@ func TestGetFailures(t *testing.T) {
|
||||
|
||||
d := NewDHT(ctx, local, peerstore, fn, fs, ds.NewMapDatastore())
|
||||
other := makePeer(nil)
|
||||
d.Update(other)
|
||||
d.Update(ctx, other)
|
||||
|
||||
// This one should time out
|
||||
// u.POut("Timout Test\n")
|
||||
@ -232,7 +232,7 @@ func TestNotFound(t *testing.T) {
|
||||
var ps []peer.Peer
|
||||
for i := 0; i < 5; i++ {
|
||||
ps = append(ps, _randPeer())
|
||||
d.Update(ps[i])
|
||||
d.Update(ctx, ps[i])
|
||||
}
|
||||
|
||||
// Reply with random peers to every message
|
||||
@ -298,7 +298,7 @@ func TestLessThanKResponses(t *testing.T) {
|
||||
var ps []peer.Peer
|
||||
for i := 0; i < 5; i++ {
|
||||
ps = append(ps, _randPeer())
|
||||
d.Update(ps[i])
|
||||
d.Update(ctx, ps[i])
|
||||
}
|
||||
other := _randPeer()
|
||||
|
||||
|
Reference in New Issue
Block a user