core/commands2: Fixed 'object get' dagnode output format
Matt Bell committed
Nov 9, 2014 at 00:50 UTC
f3733873de14682bb44186f9d2b4ddb2cd0befe1
1 file changed
+20
-2
core/commands2/object.go
+20
-2
@@ -17,6 +17,11 @@ var ErrObjectTooLarge = errors.New("input object was too large. limit is 512kbyt
17
18
const inputLimit = 512 * 1024
19
20
+type Node struct {
21
+ Links []Link
22
+ Data []byte
23
+}
24
+
25
var objectCmd = &cmds.Command{
26
Description: "Interact with ipfs objects",
27
Help: `'ipfs object' is a plumbing command used to manipulate DAG objects directly.`,
@@ -121,9 +126,22 @@ This command outputs data in the following encodings:
126
return
127
}
128
124
- res.SetOutput(object)
129
+ node := &Node{
130
+ Links: make([]Link, len(object.Links)),
131
+ Data: object.Data,
132
+ }
133
+
134
+ for i, link := range object.Links {
135
+ node.Links[i] = Link{
136
+ Hash: link.Hash.B58String(),
137
+ Name: link.Name,
138
+ Size: link.Size,
139
+ }
140
+ }
141
+
142
+ res.SetOutput(node)
143
},
126
- Type: &dag.Node{},
144
+ Type: &Node{},
145
Marshallers: map[cmds.EncodingType]cmds.Marshaller{
146
cmds.EncodingType("protobuf"): func(res cmds.Response) ([]byte, error) {
147
object := res.Output().(*dag.Node)