a few more cleanup changes to handlers
Jeromy committed
Feb 13, 2015 at 08:29 UTC
066ebda6871fbd9a9dc5108ca789ce565e3aeb36
2 files changed
+6
-18
routing/dht/handlers.go
+1
-18
@@ -3,7 +3,6 @@ package dht
3
import (
4
"errors"
5
"fmt"
6
- "time"
6
7
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
8
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
@@ -63,9 +62,6 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
62
return nil, err
63
}
64
66
- // Note: changed the behavior here to return _as much_ info as possible
67
- // (potentially all of {value, closer peers, provider})
68
-
65
// if we have the value, send it back
66
if err == nil {
67
log.Debugf("%s handleGetValue success!", dht.self)
@@ -85,18 +81,10 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
81
resp.Record = rec
82
}
83
88
- // if we know any providers for the requested value, return those.
89
- provs := dht.providers.GetProviders(ctx, u.Key(pmes.GetKey()))
90
- provinfos := peer.PeerInfos(dht.peerstore, provs)
91
- if len(provs) > 0 {
92
- log.Debugf("handleGetValue returning %d provider[s]", len(provs))
93
- resp.ProviderPeers = pb.PeerInfosToPBPeers(dht.host.Network(), provinfos)
94
- }
95
-
84
// Find closest peer on given cluster to desired key and reply with that info
85
closer := dht.betterPeersToQuery(pmes, p, CloserPeerCount)
98
- closerinfos := peer.PeerInfos(dht.peerstore, closer)
86
if closer != nil {
87
+ closerinfos := peer.PeerInfos(dht.peerstore, closer)
88
for _, pi := range closerinfos {
89
log.Debugf("handleGetValue returning closer peer: '%s'", pi.ID)
90
if len(pi.Addrs) < 1 {
@@ -209,11 +197,6 @@ func (dht *IpfsDHT) handleGetProviders(ctx context.Context, p peer.ID, pmes *pb.
197
return resp, nil
198
}
199
212
-type providerInfo struct {
213
- Creation time.Time
214
- Value peer.ID
215
-}
216
-
200
func (dht *IpfsDHT) handleAddProvider(ctx context.Context, p peer.ID, pmes *pb.Message) (*pb.Message, error) {
201
defer log.EventBegin(ctx, "handleAddProvider", p).Done()
202
key := u.Key(pmes.GetKey())
routing/dht/providers.go
+5
@@ -10,6 +10,11 @@ import (
10
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
11
)
12
13
+type providerInfo struct {
14
+ Creation time.Time
15
+ Value peer.ID
16
+}
17
+
18
type ProviderManager struct {
19
providers map[u.Key][]*providerInfo
20
local map[u.Key]struct{}