@cryptotaxi247 / kubo / commits / 9b4c0f258

Upgraded merkledag proto

Chas Leichner committed Aug 16, 2014 at 17:23 UTC 9b4c0f258e87a54c765ff059d8f327678e0b5ed7
3 files changed +41 -38
merkledag/Makefile
+3
@@ -3,3 +3,6 @@ all: node.pb.go
3
4 node.pb.go: node.proto
5 protoc --gogo_out=. --proto_path=../../../../:/usr/local/opt/protobuf/include:. $<
6 +
7 +clean:
8 + rm node.pb.go
merkledag/merkledag.go
+1
@@ -2,6 +2,7 @@ package merkledag
2
3 import (
4 "fmt"
5 +
6 blocks "github.com/jbenet/go-ipfs/blocks"
7 u "github.com/jbenet/go-ipfs/util"
8 mh "github.com/jbenet/go-multihash"
merkledag/node.pb.go
+37 -38
@@ -15,31 +15,30 @@
15 package merkledag
16
17 import proto "code.google.com/p/gogoprotobuf/proto"
18 -import json "encoding/json"
18 import math "math"
19
20 // discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
21
22 import io "io"
23 +import fmt "fmt"
24 import code_google_com_p_gogoprotobuf_proto "code.google.com/p/gogoprotobuf/proto"
25
26 -import fmt "fmt"
26 +import fmt1 "fmt"
27 import strings "strings"
28 import reflect "reflect"
29
30 -import fmt1 "fmt"
30 +import fmt2 "fmt"
31 import strings1 "strings"
32 import code_google_com_p_gogoprotobuf_proto1 "code.google.com/p/gogoprotobuf/proto"
33 import sort "sort"
34 import strconv "strconv"
35 import reflect1 "reflect"
36
37 -import fmt2 "fmt"
37 +import fmt3 "fmt"
38 import bytes "bytes"
39
40 -// Reference proto, json, and math imports to suppress error if they are not otherwise used.
40 +// Reference imports to suppress errors if they are not otherwise used.
41 var _ = proto.Marshal
42 -var _ = &json.SyntaxError{}
42 var _ = math.Inf
43
44 // An IPFS MerkleDAG Link
@@ -126,7 +125,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
125 switch fieldNum {
126 case 1:
127 if wireType != 2 {
129 - return code_google_com_p_gogoprotobuf_proto.ErrWrongType
128 + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
129 }
130 var byteLen int
131 for shift := uint(0); ; shift += 7 {
@@ -148,7 +147,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
147 index = postIndex
148 case 2:
149 if wireType != 2 {
151 - return code_google_com_p_gogoprotobuf_proto.ErrWrongType
150 + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
151 }
152 var stringLen uint64
153 for shift := uint(0); ; shift += 7 {
@@ -171,7 +170,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
170 index = postIndex
171 case 3:
172 if wireType != 0 {
174 - return code_google_com_p_gogoprotobuf_proto.ErrWrongType
173 + return fmt.Errorf("proto: wrong wireType = %d for field Tsize", wireType)
174 }
175 var v uint64
176 for shift := uint(0); ; shift += 7 {
@@ -230,7 +229,7 @@ func (m *PBNode) Unmarshal(data []byte) error {
229 switch fieldNum {
230 case 2:
231 if wireType != 2 {
233 - return code_google_com_p_gogoprotobuf_proto.ErrWrongType
232 + return fmt.Errorf("proto: wrong wireType = %d for field Links", wireType)
233 }
234 var msglen int
235 for shift := uint(0); ; shift += 7 {
@@ -253,7 +252,7 @@ func (m *PBNode) Unmarshal(data []byte) error {
252 index = postIndex
253 case 1:
254 if wireType != 2 {
256 - return code_google_com_p_gogoprotobuf_proto.ErrWrongType
255 + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
256 }
257 var byteLen int
258 for shift := uint(0); ; shift += 7 {
@@ -304,7 +303,7 @@ func (this *PBLink) String() string {
303 `Hash:` + valueToStringNode(this.Hash) + `,`,
304 `Name:` + valueToStringNode(this.Name) + `,`,
305 `Tsize:` + valueToStringNode(this.Tsize) + `,`,
307 - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
306 + `XXX_unrecognized:` + fmt1.Sprintf("%v", this.XXX_unrecognized) + `,`,
307 `}`,
308 }, "")
309 return s
@@ -314,9 +313,9 @@ func (this *PBNode) String() string {
313 return "nil"
314 }
315 s := strings.Join([]string{`&PBNode{`,
317 - `Links:` + strings.Replace(fmt.Sprintf("%v", this.Links), "PBLink", "PBLink", 1) + `,`,
316 + `Links:` + strings.Replace(fmt1.Sprintf("%v", this.Links), "PBLink", "PBLink", 1) + `,`,
317 `Data:` + valueToStringNode(this.Data) + `,`,
319 - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
318 + `XXX_unrecognized:` + fmt1.Sprintf("%v", this.XXX_unrecognized) + `,`,
319 `}`,
320 }, "")
321 return s
@@ -327,7 +326,7 @@ func valueToStringNode(v interface{}) string {
326 return "nil"
327 }
328 pv := reflect.Indirect(rv).Interface()
330 - return fmt.Sprintf("*%v", pv)
329 + return fmt1.Sprintf("*%v", pv)
330 }
331 func (m *PBLink) Size() (n int) {
332 var l int
@@ -601,14 +600,14 @@ func (this *PBLink) GoString() string {
600 if this == nil {
601 return "nil"
602 }
604 - s := strings1.Join([]string{`&merkledag.PBLink{` + `Hash:` + valueToGoStringNode(this.Hash, "byte"), `Name:` + valueToGoStringNode(this.Name, "string"), `Tsize:` + valueToGoStringNode(this.Tsize, "uint64"), `XXX_unrecognized:` + fmt1.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
603 + s := strings1.Join([]string{`&merkledag.PBLink{` + `Hash:` + valueToGoStringNode(this.Hash, "byte"), `Name:` + valueToGoStringNode(this.Name, "string"), `Tsize:` + valueToGoStringNode(this.Tsize, "uint64"), `XXX_unrecognized:` + fmt2.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
604 return s
605 }
606 func (this *PBNode) GoString() string {
607 if this == nil {
608 return "nil"
609 }
611 - s := strings1.Join([]string{`&merkledag.PBNode{` + `Links:` + fmt1.Sprintf("%#v", this.Links), `Data:` + valueToGoStringNode(this.Data, "byte"), `XXX_unrecognized:` + fmt1.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
610 + s := strings1.Join([]string{`&merkledag.PBNode{` + `Links:` + fmt2.Sprintf("%#v", this.Links), `Data:` + valueToGoStringNode(this.Data, "byte"), `XXX_unrecognized:` + fmt2.Sprintf("%#v", this.XXX_unrecognized) + `}`}, ", ")
611 return s
612 }
613 func valueToGoStringNode(v interface{}, typ string) string {
@@ -617,7 +616,7 @@ func valueToGoStringNode(v interface{}, typ string) string {
616 return "nil"
617 }
618 pv := reflect1.Indirect(rv).Interface()
620 - return fmt1.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
619 + return fmt2.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
620 }
621 func extensionToGoStringNode(e map[int32]code_google_com_p_gogoprotobuf_proto1.Extension) string {
622 if e == nil {
@@ -641,44 +640,44 @@ func (this *PBLink) VerboseEqual(that interface{}) error {
640 if this == nil {
641 return nil
642 }
644 - return fmt2.Errorf("that == nil && this != nil")
643 + return fmt3.Errorf("that == nil && this != nil")
644 }
645
646 that1, ok := that.(*PBLink)
647 if !ok {
649 - return fmt2.Errorf("that is not of type *PBLink")
648 + return fmt3.Errorf("that is not of type *PBLink")
649 }
650 if that1 == nil {
651 if this == nil {
652 return nil
653 }
655 - return fmt2.Errorf("that is type *PBLink but is nil && this != nil")
654 + return fmt3.Errorf("that is type *PBLink but is nil && this != nil")
655 } else if this == nil {
657 - return fmt2.Errorf("that is type *PBLinkbut is not nil && this == nil")
656 + return fmt3.Errorf("that is type *PBLinkbut is not nil && this == nil")
657 }
658 if !bytes.Equal(this.Hash, that1.Hash) {
660 - return fmt2.Errorf("Hash this(%v) Not Equal that(%v)", this.Hash, that1.Hash)
659 + return fmt3.Errorf("Hash this(%v) Not Equal that(%v)", this.Hash, that1.Hash)
660 }
661 if this.Name != nil && that1.Name != nil {
662 if *this.Name != *that1.Name {
664 - return fmt2.Errorf("Name this(%v) Not Equal that(%v)", *this.Name, *that1.Name)
663 + return fmt3.Errorf("Name this(%v) Not Equal that(%v)", *this.Name, *that1.Name)
664 }
665 } else if this.Name != nil {
667 - return fmt2.Errorf("this.Name == nil && that.Name != nil")
666 + return fmt3.Errorf("this.Name == nil && that.Name != nil")
667 } else if that1.Name != nil {
669 - return fmt2.Errorf("Name this(%v) Not Equal that(%v)", this.Name, that1.Name)
668 + return fmt3.Errorf("Name this(%v) Not Equal that(%v)", this.Name, that1.Name)
669 }
670 if this.Tsize != nil && that1.Tsize != nil {
671 if *this.Tsize != *that1.Tsize {
673 - return fmt2.Errorf("Tsize this(%v) Not Equal that(%v)", *this.Tsize, *that1.Tsize)
672 + return fmt3.Errorf("Tsize this(%v) Not Equal that(%v)", *this.Tsize, *that1.Tsize)
673 }
674 } else if this.Tsize != nil {
676 - return fmt2.Errorf("this.Tsize == nil && that.Tsize != nil")
675 + return fmt3.Errorf("this.Tsize == nil && that.Tsize != nil")
676 } else if that1.Tsize != nil {
678 - return fmt2.Errorf("Tsize this(%v) Not Equal that(%v)", this.Tsize, that1.Tsize)
677 + return fmt3.Errorf("Tsize this(%v) Not Equal that(%v)", this.Tsize, that1.Tsize)
678 }
679 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
681 - return fmt2.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
680 + return fmt3.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
681 }
682 return nil
683 }
@@ -733,34 +732,34 @@ func (this *PBNode) VerboseEqual(that interface{}) error {
732 if this == nil {
733 return nil
734 }
736 - return fmt2.Errorf("that == nil && this != nil")
735 + return fmt3.Errorf("that == nil && this != nil")
736 }
737
738 that1, ok := that.(*PBNode)
739 if !ok {
741 - return fmt2.Errorf("that is not of type *PBNode")
740 + return fmt3.Errorf("that is not of type *PBNode")
741 }
742 if that1 == nil {
743 if this == nil {
744 return nil
745 }
747 - return fmt2.Errorf("that is type *PBNode but is nil && this != nil")
746 + return fmt3.Errorf("that is type *PBNode but is nil && this != nil")
747 } else if this == nil {
749 - return fmt2.Errorf("that is type *PBNodebut is not nil && this == nil")
748 + return fmt3.Errorf("that is type *PBNodebut is not nil && this == nil")
749 }
750 if len(this.Links) != len(that1.Links) {
752 - return fmt2.Errorf("Links this(%v) Not Equal that(%v)", len(this.Links), len(that1.Links))
751 + return fmt3.Errorf("Links this(%v) Not Equal that(%v)", len(this.Links), len(that1.Links))
752 }
753 for i := range this.Links {
754 if !this.Links[i].Equal(that1.Links[i]) {
756 - return fmt2.Errorf("Links this[%v](%v) Not Equal that[%v](%v)", i, this.Links[i], i, that1.Links[i])
755 + return fmt3.Errorf("Links this[%v](%v) Not Equal that[%v](%v)", i, this.Links[i], i, that1.Links[i])
756 }
757 }
758 if !bytes.Equal(this.Data, that1.Data) {
760 - return fmt2.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data)
759 + return fmt3.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data)
760 }
761 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
763 - return fmt2.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
762 + return fmt3.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
763 }
764 return nil
765 }