From ac9a1a0b92f8bf250a000b83a724b80285793dab Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 17 Feb 2024 05:20:42 -0500 Subject: [PATCH] feat: implement StorageProtocol --- protocols/s5/s5.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/protocols/s5/s5.go b/protocols/s5/s5.go index fd73706..123919a 100644 --- a/protocols/s5/s5.go +++ b/protocols/s5/s5.go @@ -28,6 +28,7 @@ import ( var ( _ s5storage.ProviderStore = (*S5ProviderStore)(nil) _ registry.Protocol = (*S5Protocol)(nil) + _ storage.StorageProtocol = (*S5Protocol)(nil) ) type S5Protocol struct { @@ -218,6 +219,18 @@ func (s *S5Protocol) SetNode(node *s5node.Node) { s.node = node } +func (s *S5Protocol) EncodeFileName(bytes []byte) string { + bytes = append([]byte{byte(types.HashTypeBlake3)}, bytes...) + + hash, err := encoding.NewMultihash(bytes).ToBase64Url() + if err != nil { + s.logger.Error("error encoding hash", zap.Error(err)) + panic(err) + } + + return hash +} + type S5ProviderStore struct { config *viper.Viper logger *zap.Logger