File tree 2 files changed +11
-11
lines changed
2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,20 @@ import (
5
5
mhash "github.com/multiformats/go-multihash"
6
6
)
7
7
8
- // Inliner is a cid.Builder that will use the id multihash when the
8
+ // InlineBuilder is a cid.Builder that will use the id multihash when the
9
9
// size of the content is no more than limit
10
- type Inliner struct {
11
- cid.Builder
12
- Limit int
10
+ type InlineBuilder struct {
11
+ cid.Builder // Parent Builder
12
+ Limit int // Limit (inclusive)
13
13
}
14
14
15
15
// WithCodec implements the cid.Builder interface
16
- func (p Inliner ) WithCodec (c uint64 ) cid.Builder {
17
- return Inliner {p .Builder .WithCodec (c ), p .Limit }
16
+ func (p InlineBuilder ) WithCodec (c uint64 ) cid.Builder {
17
+ return InlineBuilder {p .Builder .WithCodec (c ), p .Limit }
18
18
}
19
19
20
20
// Sum implements the cid.Builder interface
21
- func (p Inliner ) Sum (data []byte ) (* cid.Cid , error ) {
21
+ func (p InlineBuilder ) Sum (data []byte ) (* cid.Cid , error ) {
22
22
if len (data ) > p .Limit {
23
23
return p .Builder .Sum (data )
24
24
}
Original file line number Diff line number Diff line change 8
8
mhash "github.com/multiformats/go-multihash"
9
9
)
10
10
11
- func TestInlinerSmallValue (t * testing.T ) {
12
- builder := Inliner {cid.V0Builder {}, 64 }
11
+ func TestInlineBuilderSmallValue (t * testing.T ) {
12
+ builder := InlineBuilder {cid.V0Builder {}, 64 }
13
13
c , err := builder .Sum ([]byte ("Hello World" ))
14
14
if err != nil {
15
15
t .Fatal (err )
@@ -19,8 +19,8 @@ func TestInlinerSmallValue(t *testing.T) {
19
19
}
20
20
}
21
21
22
- func TestInlinerLargeValue (t * testing.T ) {
23
- builder := Inliner {cid.V0Builder {}, 64 }
22
+ func TestInlinerBuilderLargeValue (t * testing.T ) {
23
+ builder := InlineBuilder {cid.V0Builder {}, 64 }
24
24
data := make ([]byte , 512 )
25
25
rand .Read (data )
26
26
c , err := builder .Sum (data )
You can’t perform that action at this time.
0 commit comments