refactor: use CIDFromHash and extract the hash
This commit is contained in:
parent
a48b10e50c
commit
62867f26a9
|
@ -859,7 +859,12 @@ func (s *S5API) accountPins(jc jape.Context) {
|
||||||
pins := make([]AccountPin, len(pinsRet))
|
pins := make([]AccountPin, len(pinsRet))
|
||||||
|
|
||||||
for i, pin := range 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 {
|
if err != nil {
|
||||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
|
s.sendErrorResponse(jc, NewS5Error(ErrKeyInternalError, err))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue