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-cidutil
Commits
a0ab751a
Commit
a0ab751a
authored
Sep 06, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gx update and fix code to use new Cid type
parent
0e1a8db3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
14 deletions
+14
-14
cid-fmt/main.go
cid-fmt/main.go
+4
-4
format.go
format.go
+1
-1
inline.go
inline.go
+1
-1
package.json
package.json
+4
-4
set.go
set.go
+4
-4
No files found.
cid-fmt/main.go
View file @
a0ab751a
...
@@ -22,7 +22,7 @@ func main() {
...
@@ -22,7 +22,7 @@ func main() {
usage
()
usage
()
}
}
newBase
:=
mb
.
Encoding
(
-
1
)
newBase
:=
mb
.
Encoding
(
-
1
)
var
verConv
func
(
cid
*
c
.
Cid
)
(
*
c
.
Cid
,
error
)
var
verConv
func
(
cid
c
.
Cid
)
(
c
.
Cid
,
error
)
args
:=
os
.
Args
[
1
:
]
args
:=
os
.
Args
[
1
:
]
outer
:
outer
:
for
{
for
{
...
@@ -117,13 +117,13 @@ func errorMsg(fmtStr string, a ...interface{}) {
...
@@ -117,13 +117,13 @@ func errorMsg(fmtStr string, a ...interface{}) {
exitCode
=
1
exitCode
=
1
}
}
func
toCidV0
(
cid
*
c
.
Cid
)
(
*
c
.
Cid
,
error
)
{
func
toCidV0
(
cid
c
.
Cid
)
(
c
.
Cid
,
error
)
{
if
cid
.
Type
()
!=
c
.
DagProtobuf
{
if
cid
.
Type
()
!=
c
.
DagProtobuf
{
return
nil
,
fmt
.
Errorf
(
"can't convert non-protobuf nodes to cidv0"
)
return
c
.
Cid
{}
,
fmt
.
Errorf
(
"can't convert non-protobuf nodes to cidv0"
)
}
}
return
c
.
NewCidV0
(
cid
.
Hash
()),
nil
return
c
.
NewCidV0
(
cid
.
Hash
()),
nil
}
}
func
toCidV1
(
cid
*
c
.
Cid
)
(
*
c
.
Cid
,
error
)
{
func
toCidV1
(
cid
c
.
Cid
)
(
c
.
Cid
,
error
)
{
return
c
.
NewCidV1
(
cid
.
Type
(),
cid
.
Hash
()),
nil
return
c
.
NewCidV1
(
cid
.
Type
(),
cid
.
Hash
()),
nil
}
}
format.go
View file @
a0ab751a
...
@@ -35,7 +35,7 @@ used. For Cid version 1 the multibase prefix is included.
...
@@ -35,7 +35,7 @@ used. For Cid version 1 the multibase prefix is included.
// Format formats a cid according to the format specificer as
// Format formats a cid according to the format specificer as
// documented in the FormatRef constant
// documented in the FormatRef constant
func
Format
(
fmtStr
string
,
base
mb
.
Encoding
,
cid
*
c
.
Cid
)
(
string
,
error
)
{
func
Format
(
fmtStr
string
,
base
mb
.
Encoding
,
cid
c
.
Cid
)
(
string
,
error
)
{
p
:=
cid
.
Prefix
()
p
:=
cid
.
Prefix
()
var
out
bytes
.
Buffer
var
out
bytes
.
Buffer
var
err
error
var
err
error
...
...
inline.go
View file @
a0ab751a
...
@@ -18,7 +18,7 @@ func (p InlineBuilder) WithCodec(c uint64) cid.Builder {
...
@@ -18,7 +18,7 @@ func (p InlineBuilder) WithCodec(c uint64) cid.Builder {
}
}
// Sum implements the cid.Builder interface
// Sum implements the cid.Builder interface
func
(
p
InlineBuilder
)
Sum
(
data
[]
byte
)
(
*
cid
.
Cid
,
error
)
{
func
(
p
InlineBuilder
)
Sum
(
data
[]
byte
)
(
cid
.
Cid
,
error
)
{
if
len
(
data
)
>
p
.
Limit
{
if
len
(
data
)
>
p
.
Limit
{
return
p
.
Builder
.
Sum
(
data
)
return
p
.
Builder
.
Sum
(
data
)
}
}
...
...
package.json
View file @
a0ab751a
...
@@ -13,15 +13,15 @@
...
@@ -13,15 +13,15 @@
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
Sbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR
"
,
"hash"
:
"Qm
ekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd
"
,
"name"
:
"go-multibase"
,
"name"
:
"go-multibase"
,
"version"
:
"0.
2.7
"
"version"
:
"0.
3.0
"
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
ZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb
"
,
"hash"
:
"Qm
PSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7
"
,
"name"
:
"go-cid"
,
"name"
:
"go-cid"
,
"version"
:
"0.
8
.0"
"version"
:
"0.
9
.0"
}
}
],
],
"gxVersion"
:
"0.12.1"
,
"gxVersion"
:
"0.12.1"
,
...
...
set.go
View file @
a0ab751a
...
@@ -14,21 +14,21 @@ func NewSet() *Set { return c.NewSet() }
...
@@ -14,21 +14,21 @@ func NewSet() *Set { return c.NewSet() }
// for the Visit function
// for the Visit function
type
StreamingSet
struct
{
type
StreamingSet
struct
{
Set
*
Set
Set
*
Set
New
chan
*
c
.
Cid
New
chan
c
.
Cid
}
}
// NewStreamingSet initializes and returns new Set.
// NewStreamingSet initializes and returns new Set.
func
NewStreamingSet
()
*
StreamingSet
{
func
NewStreamingSet
()
*
StreamingSet
{
return
&
StreamingSet
{
return
&
StreamingSet
{
Set
:
c
.
NewSet
(),
Set
:
c
.
NewSet
(),
New
:
make
(
chan
*
c
.
Cid
),
New
:
make
(
chan
c
.
Cid
),
}
}
}
}
// Visitor creates new visitor which adds a Cids to the set and emits them to
// Visitor creates new visitor which adds a Cids to the set and emits them to
// the set.New channel
// the set.New channel
func
(
s
*
StreamingSet
)
Visitor
(
ctx
context
.
Context
)
func
(
c
*
c
.
Cid
)
bool
{
func
(
s
*
StreamingSet
)
Visitor
(
ctx
context
.
Context
)
func
(
c
c
.
Cid
)
bool
{
return
func
(
c
*
c
.
Cid
)
bool
{
return
func
(
c
c
.
Cid
)
bool
{
if
s
.
Set
.
Visit
(
c
)
{
if
s
.
Set
.
Visit
(
c
)
{
select
{
select
{
case
s
.
New
<-
c
:
case
s
.
New
<-
c
:
...
...
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