feat: implement StorageProtocol
This commit is contained in:
parent
263473db41
commit
ac9a1a0b92
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue