Pretty prints node output from kad lookup tool (#762)
* Pretty prints node output from kad lookup tool * Linter fix
This commit is contained in:
parent
c6d790d58e
commit
69281552b3
@ -205,7 +205,7 @@ func LookupNode(cmd *cobra.Command, args []string) (err error) {
|
||||
return ErrInspectorDial.Wrap(err)
|
||||
}
|
||||
|
||||
node, err := i.client.LookupNode(context.Background(), &pb.LookupNodeRequest{
|
||||
n, err := i.client.LookupNode(context.Background(), &pb.LookupNodeRequest{
|
||||
Id: args[0],
|
||||
})
|
||||
|
||||
@ -213,11 +213,20 @@ func LookupNode(cmd *cobra.Command, args []string) (err error) {
|
||||
return ErrRequest.Wrap(err)
|
||||
}
|
||||
|
||||
fmt.Printf("%+v\n", node)
|
||||
fmt.Println(prettyPrintNode(n))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prettyPrintNode(n *pb.LookupNodeResponse) string {
|
||||
m := jsonpb.Marshaler{Indent: " ", EmitDefaults: false}
|
||||
s, err := m.MarshalToString(n)
|
||||
if err != nil {
|
||||
zap.S().Error("error marshaling node: %s", n)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func prettyPrintBucket(b *pb.GetBucketResponse) string {
|
||||
m := jsonpb.Marshaler{Indent: " ", EmitDefaults: false}
|
||||
s, err := m.MarshalToString(b)
|
||||
|
@ -138,10 +138,7 @@ func (srv *Server) LookupNode(ctx context.Context, req *pb.LookupNodeRequest) (*
|
||||
}
|
||||
|
||||
return &pb.LookupNodeResponse{
|
||||
Node: &pb.Node{
|
||||
Id: node.Id,
|
||||
},
|
||||
Meta: nil,
|
||||
Node: &node,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user