fix: switch to using hash cid and fix handling of list
This commit is contained in:
parent
a593cac1ce
commit
350d9c8244
|
@ -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)
|
return fmt.Errorf("Failed to add storage location: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var list *hashset.Set
|
hashStr, err := hash.ToString()
|
||||||
listVal, ok := node.HashQueryRoutingTable().Get(hash.HashCode()) // Implement HashQueryRoutingTable method
|
if err != nil {
|
||||||
if !ok {
|
return err
|
||||||
list = hashset.New()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
for _, peerIdVal := range list.Values() {
|
||||||
peerId := peerIdVal.(*encoding.NodeId)
|
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) {
|
if peerId.Equals(nodeId) || peerId.Equals(peer) {
|
||||||
continue
|
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)
|
foundPeer := peerVal.(net.Peer)
|
||||||
err := foundPeer.SendMessage(s.raw)
|
err := foundPeer.SendMessage(s.raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue