Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
d45513e0
Commit
d45513e0
authored
Oct 22, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(merkledag/pb) rename proto package -> merkledag_pb
parent
05e10f8e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
57 deletions
+60
-57
internal/pb/Makefile
internal/pb/Makefile
+7
-4
internal/pb/merkledag.pb.go
internal/pb/merkledag.pb.go
+48
-48
internal/pb/merkledag.proto
internal/pb/merkledag.proto
+1
-1
internal/pb/merkledagpb_test.go
internal/pb/merkledagpb_test.go
+4
-4
No files found.
internal/pb/Makefile
View file @
d45513e0
PB
=
$(
wildcard
*
.proto
)
GO
=
$(PB:.proto=.pb.go)
all
:
node.pb.go
all
:
$(GO)
node
.pb.go
:
node
.proto
protoc
--gogo_out
=
.
--proto_path
=
../../../../:/usr/local/opt/protobuf/include:.
$<
%
.pb.go
:
%
.proto
protoc
--gogo_out
=
.
--proto_path
=
../../../../
../../
:/usr/local/opt/protobuf/include:.
$<
clean
:
rm
node.pb.go
rm
-f
*
.pb.go
rm
-f
*
.go
internal/pb/
node
.pb.go
→
internal/pb/
merkledag
.pb.go
View file @
d45513e0
// Code generated by protoc-gen-gogo.
// source:
node
.proto
// source:
merkledag
.proto
// DO NOT EDIT!
/*
Package merkledag is a generated protocol buffer package.
Package merkledag
_pb
is a generated protocol buffer package.
It is generated from these files:
node
.proto
merkledag
.proto
It has these top-level messages:
PBLink
PBNode
*/
package
merkledag
package
merkledag
_pb
import
proto
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/proto"
import
math
"math"
...
...
@@ -300,9 +300,9 @@ func (this *PBLink) String() string {
return
"nil"
}
s
:=
strings
.
Join
([]
string
{
`&PBLink{`
,
`Hash:`
+
valueToString
Node
(
this
.
Hash
)
+
`,`
,
`Name:`
+
valueToString
Node
(
this
.
Name
)
+
`,`
,
`Tsize:`
+
valueToString
Node
(
this
.
Tsize
)
+
`,`
,
`Hash:`
+
valueToString
Merkledag
(
this
.
Hash
)
+
`,`
,
`Name:`
+
valueToString
Merkledag
(
this
.
Name
)
+
`,`
,
`Tsize:`
+
valueToString
Merkledag
(
this
.
Tsize
)
+
`,`
,
`XXX_unrecognized:`
+
fmt1
.
Sprintf
(
"%v"
,
this
.
XXX_unrecognized
)
+
`,`
,
`}`
,
},
""
)
...
...
@@ -314,13 +314,13 @@ func (this *PBNode) String() string {
}
s
:=
strings
.
Join
([]
string
{
`&PBNode{`
,
`Links:`
+
strings
.
Replace
(
fmt1
.
Sprintf
(
"%v"
,
this
.
Links
),
"PBLink"
,
"PBLink"
,
1
)
+
`,`
,
`Data:`
+
valueToString
Node
(
this
.
Data
)
+
`,`
,
`Data:`
+
valueToString
Merkledag
(
this
.
Data
)
+
`,`
,
`XXX_unrecognized:`
+
fmt1
.
Sprintf
(
"%v"
,
this
.
XXX_unrecognized
)
+
`,`
,
`}`
,
},
""
)
return
s
}
func
valueToString
Node
(
v
interface
{})
string
{
func
valueToString
Merkledag
(
v
interface
{})
string
{
rv
:=
reflect
.
ValueOf
(
v
)
if
rv
.
IsNil
()
{
return
"nil"
...
...
@@ -333,14 +333,14 @@ func (m *PBLink) Size() (n int) {
_
=
l
if
m
.
Hash
!=
nil
{
l
=
len
(
m
.
Hash
)
n
+=
1
+
l
+
sov
Node
(
uint64
(
l
))
n
+=
1
+
l
+
sov
Merkledag
(
uint64
(
l
))
}
if
m
.
Name
!=
nil
{
l
=
len
(
*
m
.
Name
)
n
+=
1
+
l
+
sov
Node
(
uint64
(
l
))
n
+=
1
+
l
+
sov
Merkledag
(
uint64
(
l
))
}
if
m
.
Tsize
!=
nil
{
n
+=
1
+
sov
Node
(
uint64
(
*
m
.
Tsize
))
n
+=
1
+
sov
Merkledag
(
uint64
(
*
m
.
Tsize
))
}
if
m
.
XXX_unrecognized
!=
nil
{
n
+=
len
(
m
.
XXX_unrecognized
)
...
...
@@ -353,12 +353,12 @@ func (m *PBNode) Size() (n int) {
if
len
(
m
.
Links
)
>
0
{
for
_
,
e
:=
range
m
.
Links
{
l
=
e
.
Size
()
n
+=
1
+
l
+
sov
Node
(
uint64
(
l
))
n
+=
1
+
l
+
sov
Merkledag
(
uint64
(
l
))
}
}
if
m
.
Data
!=
nil
{
l
=
len
(
m
.
Data
)
n
+=
1
+
l
+
sov
Node
(
uint64
(
l
))
n
+=
1
+
l
+
sov
Merkledag
(
uint64
(
l
))
}
if
m
.
XXX_unrecognized
!=
nil
{
n
+=
len
(
m
.
XXX_unrecognized
)
...
...
@@ -366,7 +366,7 @@ func (m *PBNode) Size() (n int) {
return
n
}
func
sov
Node
(
x
uint64
)
(
n
int
)
{
func
sov
Merkledag
(
x
uint64
)
(
n
int
)
{
for
{
n
++
x
>>=
7
...
...
@@ -376,10 +376,10 @@ func sovNode(x uint64) (n int) {
}
return
n
}
func
soz
Node
(
x
uint64
)
(
n
int
)
{
return
sov
Node
(
uint64
((
x
<<
1
)
^
uint64
((
int64
(
x
)
>>
63
))))
func
soz
Merkledag
(
x
uint64
)
(
n
int
)
{
return
sov
Merkledag
(
uint64
((
x
<<
1
)
^
uint64
((
int64
(
x
)
>>
63
))))
}
func
NewPopulatedPBLink
(
r
randy
Node
,
easy
bool
)
*
PBLink
{
func
NewPopulatedPBLink
(
r
randy
Merkledag
,
easy
bool
)
*
PBLink
{
this
:=
&
PBLink
{}
if
r
.
Intn
(
10
)
!=
0
{
v1
:=
r
.
Intn
(
100
)
...
...
@@ -389,7 +389,7 @@ func NewPopulatedPBLink(r randyNode, easy bool) *PBLink {
}
}
if
r
.
Intn
(
10
)
!=
0
{
v2
:=
randString
Node
(
r
)
v2
:=
randString
Merkledag
(
r
)
this
.
Name
=
&
v2
}
if
r
.
Intn
(
10
)
!=
0
{
...
...
@@ -397,12 +397,12 @@ func NewPopulatedPBLink(r randyNode, easy bool) *PBLink {
this
.
Tsize
=
&
v3
}
if
!
easy
&&
r
.
Intn
(
10
)
!=
0
{
this
.
XXX_unrecognized
=
randUnrecognized
Node
(
r
,
4
)
this
.
XXX_unrecognized
=
randUnrecognized
Merkledag
(
r
,
4
)
}
return
this
}
func
NewPopulatedPBNode
(
r
randy
Node
,
easy
bool
)
*
PBNode
{
func
NewPopulatedPBNode
(
r
randy
Merkledag
,
easy
bool
)
*
PBNode
{
this
:=
&
PBNode
{}
if
r
.
Intn
(
10
)
!=
0
{
v4
:=
r
.
Intn
(
10
)
...
...
@@ -419,12 +419,12 @@ func NewPopulatedPBNode(r randyNode, easy bool) *PBNode {
}
}
if
!
easy
&&
r
.
Intn
(
10
)
!=
0
{
this
.
XXX_unrecognized
=
randUnrecognized
Node
(
r
,
3
)
this
.
XXX_unrecognized
=
randUnrecognized
Merkledag
(
r
,
3
)
}
return
this
}
type
randy
Node
interface
{
type
randy
Merkledag
interface
{
Float32
()
float32
Float64
()
float64
Int63
()
int64
...
...
@@ -433,22 +433,22 @@ type randyNode interface {
Intn
(
n
int
)
int
}
func
randUTF8Rune
Node
(
r
randyNode
)
rune
{
func
randUTF8Rune
Merkledag
(
r
randyMerkledag
)
rune
{
res
:=
rune
(
r
.
Uint32
()
%
1112064
)
if
55296
<=
res
{
res
+=
2047
}
return
res
}
func
randString
Node
(
r
randyNode
)
string
{
func
randString
Merkledag
(
r
randyMerkledag
)
string
{
v6
:=
r
.
Intn
(
100
)
tmps
:=
make
([]
rune
,
v6
)
for
i
:=
0
;
i
<
v6
;
i
++
{
tmps
[
i
]
=
randUTF8Rune
Node
(
r
)
tmps
[
i
]
=
randUTF8Rune
Merkledag
(
r
)
}
return
string
(
tmps
)
}
func
randUnrecognized
Node
(
r
randyNode
,
maxFieldNumber
int
)
(
data
[]
byte
)
{
func
randUnrecognized
Merkledag
(
r
randyMerkledag
,
maxFieldNumber
int
)
(
data
[]
byte
)
{
l
:=
r
.
Intn
(
5
)
for
i
:=
0
;
i
<
l
;
i
++
{
wire
:=
r
.
Intn
(
4
)
...
...
@@ -456,37 +456,37 @@ func randUnrecognizedNode(r randyNode, maxFieldNumber int) (data []byte) {
wire
=
5
}
fieldNumber
:=
maxFieldNumber
+
r
.
Intn
(
100
)
data
=
randField
Node
(
data
,
r
,
fieldNumber
,
wire
)
data
=
randField
Merkledag
(
data
,
r
,
fieldNumber
,
wire
)
}
return
data
}
func
randField
Node
(
data
[]
byte
,
r
randy
Node
,
fieldNumber
int
,
wire
int
)
[]
byte
{
func
randField
Merkledag
(
data
[]
byte
,
r
randy
Merkledag
,
fieldNumber
int
,
wire
int
)
[]
byte
{
key
:=
uint32
(
fieldNumber
)
<<
3
|
uint32
(
wire
)
switch
wire
{
case
0
:
data
=
encodeVarintPopulate
Node
(
data
,
uint64
(
key
))
data
=
encodeVarintPopulate
Merkledag
(
data
,
uint64
(
key
))
v7
:=
r
.
Int63
()
if
r
.
Intn
(
2
)
==
0
{
v7
*=
-
1
}
data
=
encodeVarintPopulate
Node
(
data
,
uint64
(
v7
))
data
=
encodeVarintPopulate
Merkledag
(
data
,
uint64
(
v7
))
case
1
:
data
=
encodeVarintPopulate
Node
(
data
,
uint64
(
key
))
data
=
encodeVarintPopulate
Merkledag
(
data
,
uint64
(
key
))
data
=
append
(
data
,
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)))
case
2
:
data
=
encodeVarintPopulate
Node
(
data
,
uint64
(
key
))
data
=
encodeVarintPopulate
Merkledag
(
data
,
uint64
(
key
))
ll
:=
r
.
Intn
(
100
)
data
=
encodeVarintPopulate
Node
(
data
,
uint64
(
ll
))
data
=
encodeVarintPopulate
Merkledag
(
data
,
uint64
(
ll
))
for
j
:=
0
;
j
<
ll
;
j
++
{
data
=
append
(
data
,
byte
(
r
.
Intn
(
256
)))
}
default
:
data
=
encodeVarintPopulate
Node
(
data
,
uint64
(
key
))
data
=
encodeVarintPopulate
Merkledag
(
data
,
uint64
(
key
))
data
=
append
(
data
,
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)),
byte
(
r
.
Intn
(
256
)))
}
return
data
}
func
encodeVarintPopulate
Node
(
data
[]
byte
,
v
uint64
)
[]
byte
{
func
encodeVarintPopulate
Merkledag
(
data
[]
byte
,
v
uint64
)
[]
byte
{
for
v
>=
1
<<
7
{
data
=
append
(
data
,
uint8
(
uint64
(
v
)
&
0x7f
|
0x80
))
v
>>=
7
...
...
@@ -512,19 +512,19 @@ func (m *PBLink) MarshalTo(data []byte) (n int, err error) {
if
m
.
Hash
!=
nil
{
data
[
i
]
=
0xa
i
++
i
=
encodeVarint
Node
(
data
,
i
,
uint64
(
len
(
m
.
Hash
)))
i
=
encodeVarint
Merkledag
(
data
,
i
,
uint64
(
len
(
m
.
Hash
)))
i
+=
copy
(
data
[
i
:
],
m
.
Hash
)
}
if
m
.
Name
!=
nil
{
data
[
i
]
=
0x12
i
++
i
=
encodeVarint
Node
(
data
,
i
,
uint64
(
len
(
*
m
.
Name
)))
i
=
encodeVarint
Merkledag
(
data
,
i
,
uint64
(
len
(
*
m
.
Name
)))
i
+=
copy
(
data
[
i
:
],
*
m
.
Name
)
}
if
m
.
Tsize
!=
nil
{
data
[
i
]
=
0x18
i
++
i
=
encodeVarint
Node
(
data
,
i
,
uint64
(
*
m
.
Tsize
))
i
=
encodeVarint
Merkledag
(
data
,
i
,
uint64
(
*
m
.
Tsize
))
}
if
m
.
XXX_unrecognized
!=
nil
{
i
+=
copy
(
data
[
i
:
],
m
.
XXX_unrecognized
)
...
...
@@ -550,7 +550,7 @@ func (m *PBNode) MarshalTo(data []byte) (n int, err error) {
for
_
,
msg
:=
range
m
.
Links
{
data
[
i
]
=
0x12
i
++
i
=
encodeVarint
Node
(
data
,
i
,
uint64
(
msg
.
Size
()))
i
=
encodeVarint
Merkledag
(
data
,
i
,
uint64
(
msg
.
Size
()))
n
,
err
:=
msg
.
MarshalTo
(
data
[
i
:
])
if
err
!=
nil
{
return
0
,
err
...
...
@@ -561,7 +561,7 @@ func (m *PBNode) MarshalTo(data []byte) (n int, err error) {
if
m
.
Data
!=
nil
{
data
[
i
]
=
0xa
i
++
i
=
encodeVarint
Node
(
data
,
i
,
uint64
(
len
(
m
.
Data
)))
i
=
encodeVarint
Merkledag
(
data
,
i
,
uint64
(
len
(
m
.
Data
)))
i
+=
copy
(
data
[
i
:
],
m
.
Data
)
}
if
m
.
XXX_unrecognized
!=
nil
{
...
...
@@ -569,7 +569,7 @@ func (m *PBNode) MarshalTo(data []byte) (n int, err error) {
}
return
i
,
nil
}
func
encodeFixed64
Node
(
data
[]
byte
,
offset
int
,
v
uint64
)
int
{
func
encodeFixed64
Merkledag
(
data
[]
byte
,
offset
int
,
v
uint64
)
int
{
data
[
offset
]
=
uint8
(
v
)
data
[
offset
+
1
]
=
uint8
(
v
>>
8
)
data
[
offset
+
2
]
=
uint8
(
v
>>
16
)
...
...
@@ -580,14 +580,14 @@ func encodeFixed64Node(data []byte, offset int, v uint64) int {
data
[
offset
+
7
]
=
uint8
(
v
>>
56
)
return
offset
+
8
}
func
encodeFixed32
Node
(
data
[]
byte
,
offset
int
,
v
uint32
)
int
{
func
encodeFixed32
Merkledag
(
data
[]
byte
,
offset
int
,
v
uint32
)
int
{
data
[
offset
]
=
uint8
(
v
)
data
[
offset
+
1
]
=
uint8
(
v
>>
8
)
data
[
offset
+
2
]
=
uint8
(
v
>>
16
)
data
[
offset
+
3
]
=
uint8
(
v
>>
24
)
return
offset
+
4
}
func
encodeVarint
Node
(
data
[]
byte
,
offset
int
,
v
uint64
)
int
{
func
encodeVarint
Merkledag
(
data
[]
byte
,
offset
int
,
v
uint64
)
int
{
for
v
>=
1
<<
7
{
data
[
offset
]
=
uint8
(
v
&
0x7f
|
0x80
)
v
>>=
7
...
...
@@ -600,17 +600,17 @@ func (this *PBLink) GoString() string {
if
this
==
nil
{
return
"nil"
}
s
:=
strings1
.
Join
([]
string
{
`&merkledag.PBLink{`
+
`Hash:`
+
valueToGoString
Node
(
this
.
Hash
,
"byte"
),
`Name:`
+
valueToGoString
Node
(
this
.
Name
,
"string"
),
`Tsize:`
+
valueToGoString
Node
(
this
.
Tsize
,
"uint64"
),
`XXX_unrecognized:`
+
fmt2
.
Sprintf
(
"%#v"
,
this
.
XXX_unrecognized
)
+
`}`
},
", "
)
s
:=
strings1
.
Join
([]
string
{
`&merkledag
_pb
.PBLink{`
+
`Hash:`
+
valueToGoString
Merkledag
(
this
.
Hash
,
"byte"
),
`Name:`
+
valueToGoString
Merkledag
(
this
.
Name
,
"string"
),
`Tsize:`
+
valueToGoString
Merkledag
(
this
.
Tsize
,
"uint64"
),
`XXX_unrecognized:`
+
fmt2
.
Sprintf
(
"%#v"
,
this
.
XXX_unrecognized
)
+
`}`
},
", "
)
return
s
}
func
(
this
*
PBNode
)
GoString
()
string
{
if
this
==
nil
{
return
"nil"
}
s
:=
strings1
.
Join
([]
string
{
`&merkledag.PBNode{`
+
`Links:`
+
fmt2
.
Sprintf
(
"%#v"
,
this
.
Links
),
`Data:`
+
valueToGoString
Node
(
this
.
Data
,
"byte"
),
`XXX_unrecognized:`
+
fmt2
.
Sprintf
(
"%#v"
,
this
.
XXX_unrecognized
)
+
`}`
},
", "
)
s
:=
strings1
.
Join
([]
string
{
`&merkledag
_pb
.PBNode{`
+
`Links:`
+
fmt2
.
Sprintf
(
"%#v"
,
this
.
Links
),
`Data:`
+
valueToGoString
Merkledag
(
this
.
Data
,
"byte"
),
`XXX_unrecognized:`
+
fmt2
.
Sprintf
(
"%#v"
,
this
.
XXX_unrecognized
)
+
`}`
},
", "
)
return
s
}
func
valueToGoString
Node
(
v
interface
{},
typ
string
)
string
{
func
valueToGoString
Merkledag
(
v
interface
{},
typ
string
)
string
{
rv
:=
reflect1
.
ValueOf
(
v
)
if
rv
.
IsNil
()
{
return
"nil"
...
...
@@ -618,7 +618,7 @@ func valueToGoStringNode(v interface{}, typ string) string {
pv
:=
reflect1
.
Indirect
(
rv
)
.
Interface
()
return
fmt2
.
Sprintf
(
"func(v %v) *%v { return &v } ( %#v )"
,
typ
,
typ
,
pv
)
}
func
extensionToGoString
Node
(
e
map
[
int32
]
code_google_com_p_gogoprotobuf_proto1
.
Extension
)
string
{
func
extensionToGoString
Merkledag
(
e
map
[
int32
]
code_google_com_p_gogoprotobuf_proto1
.
Extension
)
string
{
if
e
==
nil
{
return
"nil"
}
...
...
internal/pb/
node
.proto
→
internal/pb/
merkledag
.proto
View file @
d45513e0
package
merkledag
;
package
merkledag
.
pb
;
import
"code.google.com/p/gogoprotobuf/gogoproto/gogo.proto"
;
...
...
internal/pb/
node
pb_test.go
→
internal/pb/
merkledag
pb_test.go
View file @
d45513e0
// Code generated by protoc-gen-gogo.
// source:
node
.proto
// source:
merkledag
.proto
// DO NOT EDIT!
/*
Package merkledag is a generated protocol buffer package.
Package merkledag
_pb
is a generated protocol buffer package.
It is generated from these files:
node
.proto
merkledag
.proto
It has these top-level messages:
PBLink
PBNode
*/
package
merkledag
package
merkledag
_pb
import
testing
"testing"
import
math_rand
"math/rand"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment