Commit 84a9fb45 authored by Jeromy's avatar Jeromy

clean up some dead code in the dht

License: MIT
Signed-off-by: default avatarJeromy <why@ipfs.io>
parent 71a85193
...@@ -96,16 +96,6 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.Datastore) *IpfsDHT { ...@@ -96,16 +96,6 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.Datastore) *IpfsDHT {
return dht return dht
} }
// LocalPeer returns the peer.Peer of the dht.
func (dht *IpfsDHT) LocalPeer() peer.ID {
return dht.self
}
// log returns the dht's logger
func (dht *IpfsDHT) log() logging.EventLogger {
return log // TODO rm
}
// putValueToPeer stores the given key/value pair at the peer 'p' // putValueToPeer stores the given key/value pair at the peer 'p'
func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID, func (dht *IpfsDHT) putValueToPeer(ctx context.Context, p peer.ID,
key key.Key, rec *pb.Record) error { key key.Key, rec *pb.Record) error {
......
package dht
import (
"encoding/json"
"fmt"
"time"
)
type logDhtRPC struct {
Type string
Start time.Time
End time.Time
Duration time.Duration
RPCCount int
Success bool
}
func startNewRPC(name string) *logDhtRPC {
r := new(logDhtRPC)
r.Type = name
r.Start = time.Now()
return r
}
func (l *logDhtRPC) EndLog() {
l.End = time.Now()
l.Duration = l.End.Sub(l.Start)
}
func (l *logDhtRPC) Print() {
b, err := json.Marshal(l)
if err != nil {
log.Debugf("Error marshaling logDhtRPC object: %s", err)
} else {
log.Debug(string(b))
}
}
func (l *logDhtRPC) String() string {
return fmt.Sprintf("DHT RPC: %s took %s, success = %v", l.Type, l.Duration, l.Success)
}
func (l *logDhtRPC) EndAndPrint() {
l.EndLog()
l.Print()
}
package dht
import (
"encoding/json"
"time"
peer "gx/ipfs/QmQGwpJy9P4yXZySmqkZEXCmbBpJUb8xntCv8Ca4taZwDC/go-libp2p-peer"
)
type connDiagInfo struct {
Latency time.Duration
ID peer.ID
}
type diagInfo struct {
ID peer.ID
Connections []connDiagInfo
Keys []string
LifeSpan time.Duration
CodeVersion string
}
func (di *diagInfo) Marshal() []byte {
b, err := json.Marshal(di)
if err != nil {
panic(err)
}
//TODO: also consider compressing this. There will be a lot of these
return b
}
func (dht *IpfsDHT) getDiagInfo() *diagInfo {
di := new(diagInfo)
di.CodeVersion = "github.com/ipfs/go-ipfs"
di.ID = dht.self
di.LifeSpan = time.Since(dht.birth)
di.Keys = nil // Currently no way to query datastore
for _, p := range dht.routingTable.ListPeers() {
d := connDiagInfo{dht.peerstore.LatencyEWMA(p), p}
di.Connections = append(di.Connections, d)
}
return di
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment