Skip to content

Commit

Permalink
logging + tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Oct 13, 2014
1 parent 3e56f26 commit c4659b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions exchange/bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion routing/dht/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
12 changes: 9 additions & 3 deletions routing/dht/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down

0 comments on commit c4659b2

Please sign in to comment.