refactor: make encode fixed method to take a [32]byte, and change Encode to take a byte array that just copies and calls EncodeFixed
This commit is contained in:
parent
b21a425e24
commit
6ceefc11cf
|
@ -14,7 +14,14 @@ type CID struct {
|
|||
Size uint64
|
||||
}
|
||||
|
||||
func Encode(hash [32]byte, size uint64) (string, error) {
|
||||
func Encode(hash []byte, size uint64) (string, error) {
|
||||
var hashBytes [32]byte
|
||||
copy(hashBytes[:], hash)
|
||||
|
||||
return EncodeFixed(hashBytes, size)
|
||||
}
|
||||
|
||||
func EncodeFixed(hash [32]byte, size uint64) (string, error) {
|
||||
sizeBytes := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(sizeBytes, size)
|
||||
|
||||
|
|
Loading…
Reference in New Issue