Commit 4709f60d authored by Kevin Atkinson's avatar Kevin Atkinson

Rename Inliner to InlineBuilder.

parent c614d37c
...@@ -5,20 +5,20 @@ import ( ...@@ -5,20 +5,20 @@ import (
mhash "github.com/multiformats/go-multihash" mhash "github.com/multiformats/go-multihash"
) )
// Inliner is a cid.Builder that will use the id multihash when the // InlineBuilder is a cid.Builder that will use the id multihash when the
// size of the content is no more than limit // size of the content is no more than limit
type Inliner struct { type InlineBuilder struct {
cid.Builder cid.Builder // Parent Builder
Limit int Limit int // Limit (inclusive)
} }
// WithCodec implements the cid.Builder interface // WithCodec implements the cid.Builder interface
func (p Inliner) WithCodec(c uint64) cid.Builder { func (p InlineBuilder) WithCodec(c uint64) cid.Builder {
return Inliner{p.Builder.WithCodec(c), p.Limit} return InlineBuilder{p.Builder.WithCodec(c), p.Limit}
} }
// Sum implements the cid.Builder interface // Sum implements the cid.Builder interface
func (p Inliner) 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)
} }
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
mhash "github.com/multiformats/go-multihash" mhash "github.com/multiformats/go-multihash"
) )
func TestInlinerSmallValue(t *testing.T) { func TestInlineBuilderSmallValue(t *testing.T) {
builder := Inliner{cid.V0Builder{}, 64} builder := InlineBuilder{cid.V0Builder{}, 64}
c, err := builder.Sum([]byte("Hello World")) c, err := builder.Sum([]byte("Hello World"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
...@@ -19,8 +19,8 @@ func TestInlinerSmallValue(t *testing.T) { ...@@ -19,8 +19,8 @@ func TestInlinerSmallValue(t *testing.T) {
} }
} }
func TestInlinerLargeValue(t *testing.T) { func TestInlinerBuilderLargeValue(t *testing.T) {
builder := Inliner{cid.V0Builder{}, 64} builder := InlineBuilder{cid.V0Builder{}, 64}
data := make([]byte, 512) data := make([]byte, 512)
rand.Read(data) rand.Read(data)
c, err := builder.Sum(data) c, err := builder.Sum(data)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment