fix: need to manually process address slice

This commit is contained in:
Derrick Hammer 2024-01-09 16:13:53 -05:00
parent 1e94f378f3
commit 5ed286a639
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 2 deletions

View File

@ -121,7 +121,6 @@ func (n *NodeImpl) GetCachedStorageLocations(hash *encoding.Multihash, kinds []t
ts := time.Now().Unix() ts := time.Now().Unix()
for _, t := range kinds { for _, t := range kinds {
nodeMap, ok := (locationMap)[int(t)] nodeMap, ok := (locationMap)[int(t)]
if !ok { if !ok {
continue continue
@ -137,11 +136,24 @@ func (n *NodeImpl) GetCachedStorageLocations(hash *encoding.Multihash, kinds []t
continue continue
} }
addresses, ok := value[1].([]string) addressesInterface, ok := value[1].([]interface{})
if !ok { if !ok {
continue continue
} }
// Create a slice to hold the strings
addresses := make([]string, len(addressesInterface))
// Convert each element to string
for i, v := range addressesInterface {
str, ok := v.(string)
if !ok {
// Handle the error, maybe skip this element or set a default value
continue
}
addresses[i] = str
}
storageLocation := storage.NewStorageLocation(int(t), addresses, expiry) storageLocation := storage.NewStorageLocation(int(t), addresses, expiry)
if len(value) > 4 { if len(value) > 4 {
if providerMessage, ok := value[4].([]byte); ok { if providerMessage, ok := value[4].([]byte); ok {