Skip to content

Commit

Permalink
fix(core): Fix GetKeys method on basic storage implementation
Browse files Browse the repository at this point in the history
rolysr committed Jun 10, 2023
1 parent 847ca70 commit 0c6ff53
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/fullNode.go
Original file line number Diff line number Diff line change
@@ -651,9 +651,10 @@ func (fn *FullNode) Republish() {
break
}
for _, key := range keys {
data := fn.dht.Storage.Read(key, 0, 0)
data, _ := fn.dht.Storage.Read(key, 0, 0)
keyStr := base58.Encode(key)
go func() {
fn.StoreValue(key, data)
fn.StoreValue(keyStr, data)
}()
}
}
11 changes: 11 additions & 0 deletions structs/storage.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ package structs
import (
"errors"
"fmt"

"github.com/jbenet/go-base58"
)

type Storage struct {
@@ -53,3 +55,12 @@ func (s *Storage) Delete(key []byte) error {
delete(s.KV, id)
return nil
}

func (s *Storage) GetKeys() [][]byte {
keys := [][]byte{}
for k := range s.KV {
keyStr := base58.Decode(k)
keys = append(keys, keyStr)
}
return keys
}

0 comments on commit 0c6ff53

Please sign in to comment.