@cryptotaxi247 / kubo / commits / 58ea97013

pin cmd: better struct naming

Michael Muré committed Jul 11, 2019 at 13:59 UTC 58ea970135284a4ba3f64c1bf868f2f1dffe488b
1 file changed +15 -15
core/commands/pin.go
+15 -15
@@ -339,11 +339,11 @@ Example:
339
340 // For backward compatibility, we accumulate the pins in the same output type as before.
341 emit := res.Emit
342 - lgcList := map[string]RefObject{}
342 + lgcList := map[string]PinLsType{}
343 if !stream {
344 emit = func(v interface{}) error {
345 obj := v.(*PinLsOutputWrapper)
346 - lgcList[obj.RefKeyObject.Cid] = RefObject{Type: obj.RefKeyObject.Type}
346 + lgcList[obj.PinLsObject.Cid] = PinLsType{Type: obj.PinLsObject.Type}
347 return nil
348 }
349 }
@@ -359,7 +359,7 @@ Example:
359
360 if !stream {
361 return cmds.EmitOnce(res, &PinLsOutputWrapper{
362 - RefKeyList: RefKeyList{Keys: lgcList},
362 + PinLsList: PinLsList{Keys: lgcList},
363 })
364 }
365
@@ -373,14 +373,14 @@ Example:
373
374 if stream {
375 if quiet {
376 - fmt.Fprintf(w, "%s\n", out.RefKeyObject.Cid)
376 + fmt.Fprintf(w, "%s\n", out.PinLsObject.Cid)
377 } else {
378 - fmt.Fprintf(w, "%s %s\n", out.RefKeyObject.Cid, out.RefKeyObject.Type)
378 + fmt.Fprintf(w, "%s %s\n", out.PinLsObject.Cid, out.PinLsObject.Type)
379 }
380 return nil
381 }
382
383 - for k, v := range out.RefKeyList.Keys {
383 + for k, v := range out.PinLsList.Keys {
384 if quiet {
385 fmt.Fprintf(w, "%s\n", k)
386 } else {
@@ -393,24 +393,24 @@ Example:
393 },
394 }
395
396 -type RefKeyObject struct {
396 +type PinLsObject struct {
397 Cid string `json:",omitempty"`
398 Type string `json:",omitempty"`
399 }
400
401 -type RefObject struct {
401 +type PinLsType struct {
402 Type string
403 }
404
405 -type RefKeyList struct {
406 - Keys map[string]RefObject `json:",omitempty"`
405 +type PinLsList struct {
406 + Keys map[string]PinLsType `json:",omitempty"`
407 }
408
409 // Pin ls needs to output two different type depending on if it's streamed or not.
410 // We use this to bypass the cmds lib refusing to have interface{}
411 type PinLsOutputWrapper struct {
412 - RefKeyList
413 - RefKeyObject
412 + PinLsList
413 + PinLsObject
414 }
415
416 func pinLsKeys(req *cmds.Request, typeStr string, n *core.IpfsNode, api coreiface.CoreAPI, emit func(value interface{}) error) error {
@@ -446,7 +446,7 @@ func pinLsKeys(req *cmds.Request, typeStr string, n *core.IpfsNode, api coreifac
446 }
447
448 err = emit(&PinLsOutputWrapper{
449 - RefKeyObject: RefKeyObject{
449 + PinLsObject: PinLsObject{
450 Type: pinType,
451 Cid: enc.Encode(c.Cid()),
452 },
@@ -471,7 +471,7 @@ func pinLsAll(req *cmds.Request, typeStr string, n *core.IpfsNode, emit func(val
471 for _, c := range keyList {
472 if keys.Visit(c) {
473 err := emit(&PinLsOutputWrapper{
474 - RefKeyObject: RefKeyObject{
474 + PinLsObject: PinLsObject{
475 Type: typeStr,
476 Cid: enc.Encode(c),
477 },
@@ -497,7 +497,7 @@ func pinLsAll(req *cmds.Request, typeStr string, n *core.IpfsNode, emit func(val
497 r := keys.Visit(c)
498 if r {
499 err := emit(&PinLsOutputWrapper{
500 - RefKeyObject: RefKeyObject{
500 + PinLsObject: PinLsObject{
501 Type: typeStr,
502 Cid: enc.Encode(c),
503 },