feat: implement StorageProtocol

This commit is contained in:
Derrick Hammer 2024-02-17 05:20:42 -05:00
parent 263473db41
commit ac9a1a0b92
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 13 additions and 0 deletions

View File

@ -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