mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 19:24:14 +08:00
Upgraded merkledag proto
This commit is contained in:

committed by
Juan Batiz-Benet

parent
c1ae1d2ad4
commit
9b4c0f258e
@ -3,3 +3,6 @@ all: node.pb.go
|
|||||||
|
|
||||||
node.pb.go: node.proto
|
node.pb.go: node.proto
|
||||||
protoc --gogo_out=. --proto_path=../../../../:/usr/local/opt/protobuf/include:. $<
|
protoc --gogo_out=. --proto_path=../../../../:/usr/local/opt/protobuf/include:. $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm node.pb.go
|
||||||
|
@ -2,6 +2,7 @@ package merkledag
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
blocks "github.com/jbenet/go-ipfs/blocks"
|
blocks "github.com/jbenet/go-ipfs/blocks"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
mh "github.com/jbenet/go-multihash"
|
mh "github.com/jbenet/go-multihash"
|
||||||
|
@ -15,31 +15,30 @@
|
|||||||
package merkledag
|
package merkledag
|
||||||
|
|
||||||
import proto "code.google.com/p/gogoprotobuf/proto"
|
import proto "code.google.com/p/gogoprotobuf/proto"
|
||||||
import json "encoding/json"
|
|
||||||
import math "math"
|
import math "math"
|
||||||
|
|
||||||
// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
|
// discarding unused import gogoproto "code.google.com/p/gogoprotobuf/gogoproto/gogo.pb"
|
||||||
|
|
||||||
import io "io"
|
import io "io"
|
||||||
|
import fmt "fmt"
|
||||||
import code_google_com_p_gogoprotobuf_proto "code.google.com/p/gogoprotobuf/proto"
|
import code_google_com_p_gogoprotobuf_proto "code.google.com/p/gogoprotobuf/proto"
|
||||||
|
|
||||||
import fmt "fmt"
|
import fmt1 "fmt"
|
||||||
import strings "strings"
|
import strings "strings"
|
||||||
import reflect "reflect"
|
import reflect "reflect"
|
||||||
|
|
||||||
import fmt1 "fmt"
|
import fmt2 "fmt"
|
||||||
import strings1 "strings"
|
import strings1 "strings"
|
||||||
import code_google_com_p_gogoprotobuf_proto1 "code.google.com/p/gogoprotobuf/proto"
|
import code_google_com_p_gogoprotobuf_proto1 "code.google.com/p/gogoprotobuf/proto"
|
||||||
import sort "sort"
|
import sort "sort"
|
||||||
import strconv "strconv"
|
import strconv "strconv"
|
||||||
import reflect1 "reflect"
|
import reflect1 "reflect"
|
||||||
|
|
||||||
import fmt2 "fmt"
|
import fmt3 "fmt"
|
||||||
import bytes "bytes"
|
import bytes "bytes"
|
||||||
|
|
||||||
// Reference proto, json, and math imports to suppress error if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ = proto.Marshal
|
var _ = proto.Marshal
|
||||||
var _ = &json.SyntaxError{}
|
|
||||||
var _ = math.Inf
|
var _ = math.Inf
|
||||||
|
|
||||||
// An IPFS MerkleDAG Link
|
// An IPFS MerkleDAG Link
|
||||||
@ -126,7 +125,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
|
|||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 1:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return code_google_com_p_gogoprotobuf_proto.ErrWrongType
|
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
|
||||||
}
|
}
|
||||||
var byteLen int
|
var byteLen int
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
@ -148,7 +147,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
|
|||||||
index = postIndex
|
index = postIndex
|
||||||
case 2:
|
case 2:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return code_google_com_p_gogoprotobuf_proto.ErrWrongType
|
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
|
||||||
}
|
}
|
||||||
var stringLen uint64
|
var stringLen uint64
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
@ -171,7 +170,7 @@ func (m *PBLink) Unmarshal(data []byte) error {
|
|||||||
index = postIndex
|
index = postIndex
|
||||||
case 3:
|
case 3:
|
||||||
if wireType != 0 {
|
if wireType != 0 {
|
||||||
return code_google_com_p_gogoprotobuf_proto.ErrWrongType
|
return fmt.Errorf("proto: wrong wireType = %d for field Tsize", wireType)
|
||||||
}
|
}
|
||||||
var v uint64
|
var v uint64
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
@ -230,7 +229,7 @@ func (m *PBNode) Unmarshal(data []byte) error {
|
|||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 2:
|
case 2:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return code_google_com_p_gogoprotobuf_proto.ErrWrongType
|
return fmt.Errorf("proto: wrong wireType = %d for field Links", wireType)
|
||||||
}
|
}
|
||||||
var msglen int
|
var msglen int
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
@ -253,7 +252,7 @@ func (m *PBNode) Unmarshal(data []byte) error {
|
|||||||
index = postIndex
|
index = postIndex
|
||||||
case 1:
|
case 1:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return code_google_com_p_gogoprotobuf_proto.ErrWrongType
|
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
|
||||||
}
|
}
|
||||||
var byteLen int
|
var byteLen int
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
@ -304,7 +303,7 @@ func (this *PBLink) String() string {
|
|||||||
`Hash:` + valueToStringNode(this.Hash) + `,`,
|
`Hash:` + valueToStringNode(this.Hash) + `,`,
|
||||||
`Name:` + valueToStringNode(this.Name) + `,`,
|
`Name:` + valueToStringNode(this.Name) + `,`,
|
||||||
`Tsize:` + valueToStringNode(this.Tsize) + `,`,
|
`Tsize:` + valueToStringNode(this.Tsize) + `,`,
|
||||||
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
|
`XXX_unrecognized:` + fmt1.Sprintf("%v", this.XXX_unrecognized) + `,`,
|
||||||
`}`,
|
`}`,
|
||||||
}, "")
|
}, "")
|
||||||
return s
|
return s
|
||||||
@ -314,9 +313,9 @@ func (this *PBNode) String() string {
|
|||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
s := strings.Join([]string{`&PBNode{`,
|
s := strings.Join([]string{`&PBNode{`,
|
||||||
`Links:` + strings.Replace(fmt.Sprintf("%v", this.Links), "PBLink", "PBLink", 1) + `,`,
|
`Links:` + strings.Replace(fmt1.Sprintf("%v", this.Links), "PBLink", "PBLink", 1) + `,`,
|
||||||
`Data:` + valueToStringNode(this.Data) + `,`,
|
`Data:` + valueToStringNode(this.Data) + `,`,
|
||||||
`XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`,
|
`XXX_unrecognized:` + fmt1.Sprintf("%v", this.XXX_unrecognized) + `,`,
|
||||||
`}`,
|
`}`,
|
||||||
}, "")
|
}, "")
|
||||||
return s
|
return s
|
||||||
@ -327,7 +326,7 @@ func valueToStringNode(v interface{}) string {
|
|||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
pv := reflect.Indirect(rv).Interface()
|
pv := reflect.Indirect(rv).Interface()
|
||||||
return fmt.Sprintf("*%v", pv)
|
return fmt1.Sprintf("*%v", pv)
|
||||||
}
|
}
|
||||||
func (m *PBLink) Size() (n int) {
|
func (m *PBLink) Size() (n int) {
|
||||||
var l int
|
var l int
|
||||||
@ -601,14 +600,14 @@ func (this *PBLink) GoString() string {
|
|||||||
if this == nil {
|
if this == nil {
|
||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
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) + `}`}, ", ")
|
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) + `}`}, ", ")
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
func (this *PBNode) GoString() string {
|
func (this *PBNode) GoString() string {
|
||||||
if this == nil {
|
if this == nil {
|
||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
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) + `}`}, ", ")
|
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) + `}`}, ", ")
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
func valueToGoStringNode(v interface{}, typ string) string {
|
func valueToGoStringNode(v interface{}, typ string) string {
|
||||||
@ -617,7 +616,7 @@ func valueToGoStringNode(v interface{}, typ string) string {
|
|||||||
return "nil"
|
return "nil"
|
||||||
}
|
}
|
||||||
pv := reflect1.Indirect(rv).Interface()
|
pv := reflect1.Indirect(rv).Interface()
|
||||||
return fmt1.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
|
return fmt2.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
|
||||||
}
|
}
|
||||||
func extensionToGoStringNode(e map[int32]code_google_com_p_gogoprotobuf_proto1.Extension) string {
|
func extensionToGoStringNode(e map[int32]code_google_com_p_gogoprotobuf_proto1.Extension) string {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
@ -641,44 +640,44 @@ func (this *PBLink) VerboseEqual(that interface{}) error {
|
|||||||
if this == nil {
|
if this == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt2.Errorf("that == nil && this != nil")
|
return fmt3.Errorf("that == nil && this != nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
that1, ok := that.(*PBLink)
|
that1, ok := that.(*PBLink)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt2.Errorf("that is not of type *PBLink")
|
return fmt3.Errorf("that is not of type *PBLink")
|
||||||
}
|
}
|
||||||
if that1 == nil {
|
if that1 == nil {
|
||||||
if this == nil {
|
if this == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt2.Errorf("that is type *PBLink but is nil && this != nil")
|
return fmt3.Errorf("that is type *PBLink but is nil && this != nil")
|
||||||
} else if this == nil {
|
} else if this == nil {
|
||||||
return fmt2.Errorf("that is type *PBLinkbut is not nil && this == nil")
|
return fmt3.Errorf("that is type *PBLinkbut is not nil && this == nil")
|
||||||
}
|
}
|
||||||
if !bytes.Equal(this.Hash, that1.Hash) {
|
if !bytes.Equal(this.Hash, that1.Hash) {
|
||||||
return fmt2.Errorf("Hash this(%v) Not Equal that(%v)", this.Hash, that1.Hash)
|
return fmt3.Errorf("Hash this(%v) Not Equal that(%v)", this.Hash, that1.Hash)
|
||||||
}
|
}
|
||||||
if this.Name != nil && that1.Name != nil {
|
if this.Name != nil && that1.Name != nil {
|
||||||
if *this.Name != *that1.Name {
|
if *this.Name != *that1.Name {
|
||||||
return fmt2.Errorf("Name this(%v) Not Equal that(%v)", *this.Name, *that1.Name)
|
return fmt3.Errorf("Name this(%v) Not Equal that(%v)", *this.Name, *that1.Name)
|
||||||
}
|
}
|
||||||
} else if this.Name != nil {
|
} else if this.Name != nil {
|
||||||
return fmt2.Errorf("this.Name == nil && that.Name != nil")
|
return fmt3.Errorf("this.Name == nil && that.Name != nil")
|
||||||
} else if that1.Name != nil {
|
} else if that1.Name != nil {
|
||||||
return fmt2.Errorf("Name this(%v) Not Equal that(%v)", this.Name, that1.Name)
|
return fmt3.Errorf("Name this(%v) Not Equal that(%v)", this.Name, that1.Name)
|
||||||
}
|
}
|
||||||
if this.Tsize != nil && that1.Tsize != nil {
|
if this.Tsize != nil && that1.Tsize != nil {
|
||||||
if *this.Tsize != *that1.Tsize {
|
if *this.Tsize != *that1.Tsize {
|
||||||
return fmt2.Errorf("Tsize this(%v) Not Equal that(%v)", *this.Tsize, *that1.Tsize)
|
return fmt3.Errorf("Tsize this(%v) Not Equal that(%v)", *this.Tsize, *that1.Tsize)
|
||||||
}
|
}
|
||||||
} else if this.Tsize != nil {
|
} else if this.Tsize != nil {
|
||||||
return fmt2.Errorf("this.Tsize == nil && that.Tsize != nil")
|
return fmt3.Errorf("this.Tsize == nil && that.Tsize != nil")
|
||||||
} else if that1.Tsize != nil {
|
} else if that1.Tsize != nil {
|
||||||
return fmt2.Errorf("Tsize this(%v) Not Equal that(%v)", this.Tsize, that1.Tsize)
|
return fmt3.Errorf("Tsize this(%v) Not Equal that(%v)", this.Tsize, that1.Tsize)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||||
return fmt2.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
|
return fmt3.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -733,34 +732,34 @@ func (this *PBNode) VerboseEqual(that interface{}) error {
|
|||||||
if this == nil {
|
if this == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt2.Errorf("that == nil && this != nil")
|
return fmt3.Errorf("that == nil && this != nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
that1, ok := that.(*PBNode)
|
that1, ok := that.(*PBNode)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt2.Errorf("that is not of type *PBNode")
|
return fmt3.Errorf("that is not of type *PBNode")
|
||||||
}
|
}
|
||||||
if that1 == nil {
|
if that1 == nil {
|
||||||
if this == nil {
|
if this == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt2.Errorf("that is type *PBNode but is nil && this != nil")
|
return fmt3.Errorf("that is type *PBNode but is nil && this != nil")
|
||||||
} else if this == nil {
|
} else if this == nil {
|
||||||
return fmt2.Errorf("that is type *PBNodebut is not nil && this == nil")
|
return fmt3.Errorf("that is type *PBNodebut is not nil && this == nil")
|
||||||
}
|
}
|
||||||
if len(this.Links) != len(that1.Links) {
|
if len(this.Links) != len(that1.Links) {
|
||||||
return fmt2.Errorf("Links this(%v) Not Equal that(%v)", len(this.Links), len(that1.Links))
|
return fmt3.Errorf("Links this(%v) Not Equal that(%v)", len(this.Links), len(that1.Links))
|
||||||
}
|
}
|
||||||
for i := range this.Links {
|
for i := range this.Links {
|
||||||
if !this.Links[i].Equal(that1.Links[i]) {
|
if !this.Links[i].Equal(that1.Links[i]) {
|
||||||
return fmt2.Errorf("Links this[%v](%v) Not Equal that[%v](%v)", i, this.Links[i], i, that1.Links[i])
|
return fmt3.Errorf("Links this[%v](%v) Not Equal that[%v](%v)", i, this.Links[i], i, that1.Links[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bytes.Equal(this.Data, that1.Data) {
|
if !bytes.Equal(this.Data, that1.Data) {
|
||||||
return fmt2.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data)
|
return fmt3.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
|
||||||
return fmt2.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
|
return fmt3.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user