1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-20 00:18:12 +08:00

clean deprecated Key.Pretty()

License: MIT
Signed-off-by: Michael Muré <batolettre@gmail.com>
This commit is contained in:
Michael Muré
2016-03-20 17:07:25 +01:00
parent 2b6da0c024
commit c88e46cb52
12 changed files with 17 additions and 23 deletions

View File

@ -82,7 +82,7 @@ func TestAllKeysSimple(t *testing.T) {
keys2 := collect(ch)
// for _, k2 := range keys2 {
// t.Log("found ", k2.Pretty())
// t.Log("found ", k2.B58String())
// }
expectMatches(t, keys, keys2)

View File

@ -14,12 +14,6 @@ type Key string
// String is utililty function for printing out keys as strings (Pretty).
func (k Key) String() string {
return k.Pretty()
}
// Pretty returns Key in a b58 encoded string
// TODO: deprecate Pretty. bad name.
func (k Key) Pretty() string {
return k.B58String()
}

View File

@ -65,7 +65,7 @@ on raw ipfs blocks. It outputs the following to stdout:
}
res.SetOutput(&BlockStat{
Key: b.Key().Pretty(),
Key: b.Key().B58String(),
Size: len(b.Data),
})
},

View File

@ -550,7 +550,7 @@ func getOutput(dagnode *dag.Node) (*Object, error) {
}
output := &Object{
Hash: key.Pretty(),
Hash: key.B58String(),
Links: make([]Link, len(dagnode.Links)),
}

View File

@ -176,7 +176,7 @@ Displays the hashes of all local objects.
defer pipew.Close()
for k := range allKeys {
s := k.Pretty() + "\n"
s := k.B58String() + "\n"
if _, err := pipew.Write([]byte(s)); err != nil {
log.Error("pipe write error: ", err)
return
@ -314,13 +314,13 @@ func (rw *RefWriter) WriteEdge(from, to key.Key, linkname string) error {
switch {
case rw.PrintFmt != "":
s = rw.PrintFmt
s = strings.Replace(s, "<src>", from.Pretty(), -1)
s = strings.Replace(s, "<dst>", to.Pretty(), -1)
s = strings.Replace(s, "<src>", from.B58String(), -1)
s = strings.Replace(s, "<dst>", to.B58String(), -1)
s = strings.Replace(s, "<linkname>", linkname, -1)
case rw.PrintEdge:
s = from.Pretty() + " -> " + to.Pretty()
s = from.B58String() + " -> " + to.B58String()
default:
s += to.Pretty()
s += to.B58String()
}
rw.out <- &RefWrapper{Ref: s}

View File

@ -323,7 +323,7 @@ func (adder *Adder) addNode(node *dag.Node, path string) error {
return err
}
path = key.Pretty()
path = key.B58String()
}
dir := gopath.Dir(path)
@ -479,7 +479,7 @@ func getOutput(dagnode *dag.Node) (*Object, error) {
}
output := &Object{
Hash: key.Pretty(),
Hash: key.B58String(),
Links: make([]Link, len(dagnode.Links)),
}

View File

@ -173,7 +173,7 @@ func (m *impl) ToNet(w io.Writer) error {
func (m *impl) Loggable() map[string]interface{} {
var blocks []string
for _, v := range m.blocks {
blocks = append(blocks, v.Key().Pretty())
blocks = append(blocks, v.Key().B58String())
}
return map[string]interface{}{
"blocks": blocks,

View File

@ -241,7 +241,7 @@ func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
continue
}
ent := fuse.Dirent{
Name: key.Key(hash).Pretty(),
Name: key.Key(hash).B58String(),
Type: fuse.DT_Dir,
}
link := fuse.Dirent{

View File

@ -171,7 +171,7 @@ func (s *Node) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadR
// setup our logging event
lm := make(lgbl.DeferredMap)
lm["fs"] = "ipfs"
lm["key"] = func() interface{} { return k.Pretty() }
lm["key"] = func() interface{} { return k.B58String() }
lm["req_offset"] = req.Offset
lm["req_size"] = req.Size
defer log.EventBegin(ctx, "fuseRead", lm).Done()

View File

@ -42,7 +42,7 @@ func TestRoutingResolve(t *testing.T) {
}
pkhash := u.Hash(pubkb)
res, err := resolver.Resolve(context.Background(), key.Key(pkhash).Pretty())
res, err := resolver.Resolve(context.Background(), key.Key(pkhash).B58String())
if err != nil {
t.Fatal(err)
}

View File

@ -210,7 +210,7 @@ func (dht *IpfsDHT) handleGetProviders(ctx context.Context, p peer.ID, pmes *pb.
resp := pb.NewMessage(pmes.GetType(), pmes.GetKey(), pmes.GetClusterLevel())
key := key.Key(pmes.GetKey())
lm["key"] = func() interface{} { return key.Pretty() }
lm["key"] = func() interface{} { return key.B58String() }
// debug logging niceness.
reqDesc := fmt.Sprintf("%s handleGetProviders(%s, %s): ", dht.self, p, key)
@ -254,7 +254,7 @@ func (dht *IpfsDHT) handleAddProvider(ctx context.Context, p peer.ID, pmes *pb.M
defer log.EventBegin(ctx, "handleAddProvider", lm).Done()
key := key.Key(pmes.GetKey())
lm["key"] = func() interface{} { return key.Pretty() }
lm["key"] = func() interface{} { return key.B58String() }
log.Debugf("%s adding %s as a provider for '%s'\n", dht.self, p, key)

View File

@ -143,7 +143,7 @@ func (m *Message) Loggable() map[string]interface{} {
return map[string]interface{}{
"message": map[string]string{
"type": m.Type.String(),
"key": key.Key(m.GetKey()).Pretty(),
"key": key.Key(m.GetKey()).B58String(),
},
}
}