feat: use CIDs as their byte representation instead of a struct
This commit is contained in:
committed by
Kevin Atkinson
parent
6ddb575a8d
commit
e153340e5a
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
type Builder interface {
|
||||
Sum(data []byte) (*Cid, error)
|
||||
Sum(data []byte) (Cid, error)
|
||||
GetCodec() uint64
|
||||
WithCodec(uint64) Builder
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func (p Prefix) WithCodec(c uint64) Builder {
|
||||
return p
|
||||
}
|
||||
|
||||
func (p V0Builder) Sum(data []byte) (*Cid, error) {
|
||||
func (p V0Builder) Sum(data []byte) (Cid, error) {
|
||||
hash, err := mh.Sum(data, mh.SHA2_256, -1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -52,7 +52,7 @@ func (p V0Builder) WithCodec(c uint64) Builder {
|
||||
return V1Builder{Codec: c, MhType: mh.SHA2_256}
|
||||
}
|
||||
|
||||
func (p V1Builder) Sum(data []byte) (*Cid, error) {
|
||||
func (p V1Builder) Sum(data []byte) (Cid, error) {
|
||||
mhLen := p.MhLength
|
||||
if mhLen <= 0 {
|
||||
mhLen = -1
|
||||
|
||||
Reference in New Issue
Block a user