From 62867f26a9bc269b86e42e716175e462d0f14bc0 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 21 Mar 2024 15:57:05 -0400 Subject: [PATCH] refactor: use CIDFromHash and extract the hash --- api/s5/s5.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/s5/s5.go b/api/s5/s5.go index 755150f..e27bebd 100644 --- a/api/s5/s5.go +++ b/api/s5/s5.go @@ -859,7 +859,12 @@ func (s *S5API) accountPins(jc jape.Context) { pins := make([]AccountPin, len(pinsRet)) for i, pin := range pinsRet { - base64Url, err := encoding.NewMultihash(append([]byte{byte(types.HashTypeBlake3)}, pin.Upload.Hash...)).ToBase64Url() + cid, err := encoding.CIDFromHash(pin.Upload.Hash, pin.Upload.Size, types.CIDTypeRaw, types.HashTypeBlake3) + if err != nil { + s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err)) + return + } + base64Url, err := cid.Hash.ToBase64Url() if err != nil { s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err)) return