From 86805e711c0b28208aeb4ba3e8599ef7967a53c6 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Fri, 10 Aug 2018 00:13:49 -0400 Subject: [PATCH] Change field names in V1Builder to match Prefix. --- builder.go | 12 ++++++------ builder_test.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builder.go b/builder.go index fec6590..af33aac 100644 --- a/builder.go +++ b/builder.go @@ -13,9 +13,9 @@ type Builder interface { type V0Builder struct{} type V1Builder struct { - Codec uint64 - HashFun uint64 - HashLen int // HashLen <= 0 means the default length + Codec uint64 + MhType uint64 + MhLength int // MhLength <= 0 means the default length } func (p Prefix) GetCodec() uint64 { @@ -49,15 +49,15 @@ func (p V0Builder) WithCodec(c uint64) Builder { if c == DagProtobuf { return p } - return V1Builder{Codec: c, HashFun: mh.SHA2_256} + return V1Builder{Codec: c, MhType: mh.SHA2_256} } func (p V1Builder) Sum(data []byte) (*Cid, error) { - mhLen := p.HashLen + mhLen := p.MhLength if mhLen <= 0 { mhLen = -1 } - hash, err := mh.Sum(data, p.HashFun, mhLen) + hash, err := mh.Sum(data, p.MhType, mhLen) if err != nil { return nil, err } diff --git a/builder_test.go b/builder_test.go index 82c3b1c..dc6f35c 100644 --- a/builder_test.go +++ b/builder_test.go @@ -35,7 +35,7 @@ func TestV1Builder(t *testing.T) { data := []byte("this is some test content") // Construct c1 - format := V1Builder{Codec: DagCBOR, HashFun: mh.SHA2_256} + format := V1Builder{Codec: DagCBOR, MhType: mh.SHA2_256} c1, err := format.Sum(data) if err != nil { t.Fatal(err) @@ -69,7 +69,7 @@ func TestCodecChange(t *testing.T) { testCodecChange(t, V0Builder{}) }) t.Run("V1Builder", func(t *testing.T) { - testCodecChange(t, V1Builder{Codec: DagProtobuf, HashFun: mh.SHA2_256}) + testCodecChange(t, V1Builder{Codec: DagProtobuf, MhType: mh.SHA2_256}) }) }