Commit 62a938ca authored by Jeromy's avatar Jeromy

use no padding encoding

License: MIT
Signed-off-by: default avatarJeromy <why@ipfs.io>
parent 326973f4
package providers package providers
import ( import (
"encoding/base32"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"strings" "strings"
...@@ -14,6 +13,7 @@ import ( ...@@ -14,6 +13,7 @@ import (
lru "gx/ipfs/QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy/golang-lru" lru "gx/ipfs/QmVYxfoJQiZijTgPNHCHgHELvQpbsJNTg6Crmc3dQkj3yy/golang-lru"
ds "gx/ipfs/QmZ6A6P6AMo8SR3jXAwzTuSU6B9R2Y4eqW2yW9VvfUayDN/go-datastore" ds "gx/ipfs/QmZ6A6P6AMo8SR3jXAwzTuSU6B9R2Y4eqW2yW9VvfUayDN/go-datastore"
dsq "gx/ipfs/QmZ6A6P6AMo8SR3jXAwzTuSU6B9R2Y4eqW2yW9VvfUayDN/go-datastore/query" dsq "gx/ipfs/QmZ6A6P6AMo8SR3jXAwzTuSU6B9R2Y4eqW2yW9VvfUayDN/go-datastore/query"
base32 "gx/ipfs/Qmb1DA2A9LS2wR4FFweB4uEDomFsdmnw1VLawLE1yQzudj/base32"
key "github.com/ipfs/go-ipfs/blocks/key" key "github.com/ipfs/go-ipfs/blocks/key"
...@@ -81,7 +81,7 @@ func NewProviderManager(ctx context.Context, local peer.ID, dstore ds.Datastore) ...@@ -81,7 +81,7 @@ func NewProviderManager(ctx context.Context, local peer.ID, dstore ds.Datastore)
const providersKeyPrefix = "/providers/" const providersKeyPrefix = "/providers/"
func mkProvKey(k key.Key) ds.Key { func mkProvKey(k key.Key) ds.Key {
return ds.NewKey(providersKeyPrefix + base32.StdEncoding.EncodeToString([]byte(k))) return ds.NewKey(providersKeyPrefix + base32.RawStdEncoding.EncodeToString([]byte(k)))
} }
func (pm *ProviderManager) Process() goprocess.Process { func (pm *ProviderManager) Process() goprocess.Process {
...@@ -132,7 +132,7 @@ func loadProvSet(dstore ds.Datastore, k key.Key) (*providerSet, error) { ...@@ -132,7 +132,7 @@ func loadProvSet(dstore ds.Datastore, k key.Key) (*providerSet, error) {
continue continue
} }
decstr, err := base32.StdEncoding.DecodeString(parts[len(parts)-1]) decstr, err := base32.RawStdEncoding.DecodeString(parts[len(parts)-1])
if err != nil { if err != nil {
log.Error("base32 decoding error: ", err) log.Error("base32 decoding error: ", err)
continue continue
...@@ -177,7 +177,7 @@ func (pm *ProviderManager) addProv(k key.Key, p peer.ID) error { ...@@ -177,7 +177,7 @@ func (pm *ProviderManager) addProv(k key.Key, p peer.ID) error {
} }
func writeProviderEntry(dstore ds.Datastore, k key.Key, p peer.ID, t time.Time) error { func writeProviderEntry(dstore ds.Datastore, k key.Key, p peer.ID, t time.Time) error {
dsk := mkProvKey(k).ChildString(base32.StdEncoding.EncodeToString([]byte(p))) dsk := mkProvKey(k).ChildString(base32.RawStdEncoding.EncodeToString([]byte(p)))
buf := make([]byte, 16) buf := make([]byte, 16)
n := binary.PutVarint(buf, t.UnixNano()) n := binary.PutVarint(buf, t.UnixNano())
...@@ -230,7 +230,7 @@ func (pm *ProviderManager) getAllProvKeys() ([]key.Key, error) { ...@@ -230,7 +230,7 @@ func (pm *ProviderManager) getAllProvKeys() ([]key.Key, error) {
log.Warning("incorrectly formatted provider entry in datastore") log.Warning("incorrectly formatted provider entry in datastore")
continue continue
} }
decoded, err := base32.StdEncoding.DecodeString(parts[2]) decoded, err := base32.RawStdEncoding.DecodeString(parts[2])
if err != nil { if err != nil {
log.Warning("error decoding base32 provider key") log.Warning("error decoding base32 provider key")
continue continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment