From c4659b2d1302fbc681af70703450f43266223910 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 13 Oct 2014 01:31:51 -0700 Subject: [PATCH] logging + tweaks --- exchange/bitswap/bitswap.go | 1 + routing/dht/dht.go | 3 ++- routing/dht/handlers.go | 12 +++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/exchange/bitswap/bitswap.go b/exchange/bitswap/bitswap.go index 2cfff3919626..af513c1de3ad 100644 --- a/exchange/bitswap/bitswap.go +++ b/exchange/bitswap/bitswap.go @@ -85,6 +85,7 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error) log.Debug("bitswap got peersToQuery: %s", iiiii) go func(p *peer.Peer) { + log.Debug("bitswap dialing peer: %s", p) err := bs.sender.DialPeer(p) if err != nil { log.Error("Error sender.DialPeer(%s)", p) diff --git a/routing/dht/dht.go b/routing/dht/dht.go index 1c5beedac12f..6486ce40d3e4 100644 --- a/routing/dht/dht.go +++ b/routing/dht/dht.go @@ -472,7 +472,7 @@ func (dht *IpfsDHT) peerFromInfo(pbp *Message_Peer) (*peer.Peer, error) { } if p == nil { - maddr, err := ma.NewMultiaddr(pbp.GetAddr()) + maddr, err := pbp.Address() if err != nil { return nil, err } @@ -481,6 +481,7 @@ func (dht *IpfsDHT) peerFromInfo(pbp *Message_Peer) (*peer.Peer, error) { p = &peer.Peer{ID: id} p.AddAddress(maddr) dht.peerstore.Put(p) + log.Info("dht found new peer: %s %s", p, maddr) } return p, nil } diff --git a/routing/dht/handlers.go b/routing/dht/handlers.go index 0c739ab17495..0fcbb2be6501 100644 --- a/routing/dht/handlers.go +++ b/routing/dht/handlers.go @@ -176,19 +176,25 @@ func (dht *IpfsDHT) handleAddProvider(p *peer.Peer, pmes *Message) (*Message, er log.Debug("%s adding %s as a provider for '%s'\n", dht.self, p, peer.ID(key)) // add provider should use the address given in the message - for _, pb := range pmes.GetCloserPeers() { - if peer.ID(pb.GetId()).Equal(p.ID) { + for _, pb := range pmes.GetProviderPeers() { + pid := peer.ID(pb.GetId()) + if pid.Equal(p.ID) { addr, err := pb.Address() if err != nil { log.Error("provider %s error with address %s", p, *pb.Addr) continue } + + log.Info("received provider %s %s for %s", p, addr, key) p.AddAddress(addr) + dht.providers.AddProvider(key, p) + + } else { + log.Error("handleAddProvider received provider %s from %s", pid, p) } } - dht.providers.AddProvider(key, p) return pmes, nil // send back same msg as confirmation. }