fix: switch to using hash cid and fix handling of list

This commit is contained in:
Derrick Hammer 2024-01-08 12:40:40 -05:00
parent a593cac1ce
commit 350d9c8244
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 15 additions and 6 deletions

View File

@ -81,13 +81,18 @@ func (s *StorageLocation) HandleMessage(node interfaces.Node, peer net.Peer, ver
return fmt.Errorf("Failed to add storage location: %s", err)
}
var list *hashset.Set
listVal, ok := node.HashQueryRoutingTable().Get(hash.HashCode()) // Implement HashQueryRoutingTable method
if !ok {
list = hashset.New()
hashStr, err := hash.ToString()
if err != nil {
return err
}
list = listVal.(*hashset.Set)
var list *hashset.Set
listVal, ok := node.HashQueryRoutingTable().Get(hashStr) // Implement HashQueryRoutingTable method
if !ok {
list = hashset.New()
} else {
list = listVal.(*hashset.Set)
}
for _, peerIdVal := range list.Values() {
peerId := peerIdVal.(*encoding.NodeId)
@ -95,7 +100,11 @@ func (s *StorageLocation) HandleMessage(node interfaces.Node, peer net.Peer, ver
if peerId.Equals(nodeId) || peerId.Equals(peer) {
continue
}
if peerVal, ok := node.Services().P2P().Peers().Get(peerId.HashCode()); ok {
peerIdStr, err := peerId.ToString()
if err != nil {
return err
}
if peerVal, ok := node.Services().P2P().Peers().Get(peerIdStr); ok {
foundPeer := peerVal.(net.Peer)
err := foundPeer.SendMessage(s.raw)
if err != nil {