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
4709f60d
Commit
4709f60d
authored
Aug 21, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Inliner to InlineBuilder.
parent
c614d37c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
inline.go
inline.go
+7
-7
inline_test.go
inline_test.go
+4
-4
No files found.
inline
r
.go
→
inline.go
View file @
4709f60d
...
...
@@ -5,20 +5,20 @@ import (
mhash
"github.com/multiformats/go-multihash"
)
// Inliner is a cid.Builder that will use the id multihash when the
// Inline
Builde
r is a cid.Builder that will use the id multihash when the
// size of the content is no more than limit
type
Inliner
struct
{
cid
.
Builder
Limit
int
type
Inline
Builde
r
struct
{
cid
.
Builder
// Parent Builder
Limit
int
// Limit (inclusive)
}
// WithCodec implements the cid.Builder interface
func
(
p
Inliner
)
WithCodec
(
c
uint64
)
cid
.
Builder
{
return
Inliner
{
p
.
Builder
.
WithCodec
(
c
),
p
.
Limit
}
func
(
p
Inline
Builde
r
)
WithCodec
(
c
uint64
)
cid
.
Builder
{
return
Inline
Builde
r
{
p
.
Builder
.
WithCodec
(
c
),
p
.
Limit
}
}
// Sum implements the cid.Builder interface
func
(
p
Inliner
)
Sum
(
data
[]
byte
)
(
*
cid
.
Cid
,
error
)
{
func
(
p
Inline
Builde
r
)
Sum
(
data
[]
byte
)
(
*
cid
.
Cid
,
error
)
{
if
len
(
data
)
>
p
.
Limit
{
return
p
.
Builder
.
Sum
(
data
)
}
...
...
inline
r
_test.go
→
inline_test.go
View file @
4709f60d
...
...
@@ -8,8 +8,8 @@ import (
mhash
"github.com/multiformats/go-multihash"
)
func
TestInlinerSmallValue
(
t
*
testing
.
T
)
{
builder
:=
Inliner
{
cid
.
V0Builder
{},
64
}
func
TestInline
Builde
rSmallValue
(
t
*
testing
.
T
)
{
builder
:=
Inline
Builde
r
{
cid
.
V0Builder
{},
64
}
c
,
err
:=
builder
.
Sum
([]
byte
(
"Hello World"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -19,8 +19,8 @@ func TestInlinerSmallValue(t *testing.T) {
}
}
func
TestInlinerLargeValue
(
t
*
testing
.
T
)
{
builder
:=
Inliner
{
cid
.
V0Builder
{},
64
}
func
TestInliner
Builder
LargeValue
(
t
*
testing
.
T
)
{
builder
:=
Inline
Builde
r
{
cid
.
V0Builder
{},
64
}
data
:=
make
([]
byte
,
512
)
rand
.
Read
(
data
)
c
,
err
:=
builder
.
Sum
(
data
)
...
...
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