clean up some dead code in the dht
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Jun 7, 2016 at 01:50 UTC
3d38faef92fcfd7ae8c5b60d1a33ce7d52755d7f
3 files changed
-100
routing/dht/dht.go
-10
@@ -96,16 +96,6 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.Datastore) *IpfsDHT {
96
return dht
97
}
98
99
-// LocalPeer returns the peer.Peer of the dht.
100
-func (dht *IpfsDHT) LocalPeer() peer.ID {
101
- return dht.self
102
-}
103
-
104
-// log returns the dht's logger
105
-func (dht *IpfsDHT) log() logging.EventLogger {
106
- return log // TODO rm
107
-}
108
-
99
// putValueToPeer stores the given key/value pair at the peer 'p'
100
func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID,
101
key key.Key, rec *pb.Record) error {
routing/dht/dht_logger.go
deleted
-46
@@ -1,46 +0,0 @@
1
-package dht
2
-
3
-import (
4
- "encoding/json"
5
- "fmt"
6
- "time"
7
-)
8
-
9
-type logDhtRPC struct {
10
- Type string
11
- Start time.Time
12
- End time.Time
13
- Duration time.Duration
14
- RPCCount int
15
- Success bool
16
-}
17
-
18
-func startNewRPC(name string) *logDhtRPC {
19
- r := new(logDhtRPC)
20
- r.Type = name
21
- r.Start = time.Now()
22
- return r
23
-}
24
-
25
-func (l *logDhtRPC) EndLog() {
26
- l.End = time.Now()
27
- l.Duration = l.End.Sub(l.Start)
28
-}
29
-
30
-func (l *logDhtRPC) Print() {
31
- b, err := json.Marshal(l)
32
- if err != nil {
33
- log.Debugf("Error marshaling logDhtRPC object: %s", err)
34
- } else {
35
- log.Debug(string(b))
36
- }
37
-}
38
-
39
-func (l *logDhtRPC) String() string {
40
- return fmt.Sprintf("DHT RPC: %s took %s, success = %v", l.Type, l.Duration, l.Success)
41
-}
42
-
43
-func (l *logDhtRPC) EndAndPrint() {
44
- l.EndLog()
45
- l.Print()
46
-}
routing/dht/diag.go
deleted
-44
@@ -1,44 +0,0 @@
1
-package dht
2
-
3
-import (
4
- "encoding/json"
5
- "time"
6
-
7
- peer "gx/ipfs/QmQGwpJy9P4yXZySmqkZEXCmbBpJUb8xntCv8Ca4taZwDC/go-libp2p-peer"
8
-)
9
-
10
-type connDiagInfo struct {
11
- Latency time.Duration
12
- ID peer.ID
13
-}
14
-
15
-type diagInfo struct {
16
- ID peer.ID
17
- Connections []connDiagInfo
18
- Keys []string
19
- LifeSpan time.Duration
20
- CodeVersion string
21
-}
22
-
23
-func (di *diagInfo) Marshal() []byte {
24
- b, err := json.Marshal(di)
25
- if err != nil {
26
- panic(err)
27
- }
28
- //TODO: also consider compressing this. There will be a lot of these
29
- return b
30
-}
31
-
32
-func (dht *IpfsDHT) getDiagInfo() *diagInfo {
33
- di := new(diagInfo)
34
- di.CodeVersion = "github.com/ipfs/go-ipfs"
35
- di.ID = dht.self
36
- di.LifeSpan = time.Since(dht.birth)
37
- di.Keys = nil // Currently no way to query datastore
38
-
39
- for _, p := range dht.routingTable.ListPeers() {
40
- d := connDiagInfo{dht.peerstore.LatencyEWMA(p), p}
41
- di.Connections = append(di.Connections, d)
42
- }
43
- return di
44
-}