refactor: switch to using structs.SetImpl

This commit is contained in:
Derrick Hammer 2024-03-14 06:53:31 -04:00
parent 804f124632
commit 6510beddf2
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 8 additions and 8 deletions

View File

@ -4,8 +4,8 @@ import (
"git.lumeweb.com/LumeWeb/libs5-go/encoding" "git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/net" "git.lumeweb.com/LumeWeb/libs5-go/net"
"git.lumeweb.com/LumeWeb/libs5-go/storage" "git.lumeweb.com/LumeWeb/libs5-go/storage"
"git.lumeweb.com/LumeWeb/libs5-go/structs"
"git.lumeweb.com/LumeWeb/libs5-go/types" "git.lumeweb.com/LumeWeb/libs5-go/types"
"github.com/emirpasic/gods/sets/hashset"
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
"go.uber.org/zap" "go.uber.org/zap"
"log" "log"
@ -146,7 +146,7 @@ func (h *HashQuery) HandleMessage(message IncomingMessageData) error {
} }
} }
var peers *hashset.Set var peers *structs.SetImpl
hashString, err := h.hash.ToString() hashString, err := h.hash.ToString()
logger.Debug("HashQuery", zap.Any("hashString", hashString)) logger.Debug("HashQuery", zap.Any("hashString", hashString))
if err != nil { if err != nil {
@ -154,7 +154,7 @@ func (h *HashQuery) HandleMessage(message IncomingMessageData) error {
} }
peersVal, ok := mediator.HashQueryRoutingTable().Get(hashString) peersVal, ok := mediator.HashQueryRoutingTable().Get(hashString)
if ok { if ok {
peers = peersVal.(*hashset.Set) peers = peersVal.(*structs.SetImpl)
if !peers.Contains(peer.Id()) { if !peers.Contains(peer.Id()) {
peers.Add(peer.Id()) peers.Add(peer.Id())
} }
@ -162,7 +162,7 @@ func (h *HashQuery) HandleMessage(message IncomingMessageData) error {
return nil return nil
} }
peerList := hashset.New() peerList := structs.NewSet()
peerList.Add(peer.Id()) peerList.Add(peer.Id())
mediator.HashQueryRoutingTable().Put(hashString, peerList) mediator.HashQueryRoutingTable().Put(hashString, peerList)

View File

@ -6,9 +6,9 @@ import (
"git.lumeweb.com/LumeWeb/libs5-go/encoding" "git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/net" "git.lumeweb.com/LumeWeb/libs5-go/net"
"git.lumeweb.com/LumeWeb/libs5-go/storage" "git.lumeweb.com/LumeWeb/libs5-go/storage"
"git.lumeweb.com/LumeWeb/libs5-go/structs"
"git.lumeweb.com/LumeWeb/libs5-go/types" "git.lumeweb.com/LumeWeb/libs5-go/types"
"git.lumeweb.com/LumeWeb/libs5-go/utils" "git.lumeweb.com/LumeWeb/libs5-go/utils"
"github.com/emirpasic/gods/sets/hashset"
"github.com/vmihailenco/msgpack/v5" "github.com/vmihailenco/msgpack/v5"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -89,12 +89,12 @@ func (s *StorageLocation) HandleMessage(message IncomingMessageData) error {
return err return err
} }
var list *hashset.Set var list *structs.SetImpl
listVal, ok := mediator.HashQueryRoutingTable().Get(hashStr) // Implement HashQueryRoutingTable method listVal, ok := mediator.HashQueryRoutingTable().Get(hashStr) // Implement HashQueryRoutingTable method
if !ok { if !ok {
list = hashset.New() list = structs.NewSet()
} else { } else {
list = listVal.(*hashset.Set) list = listVal.(*structs.SetImpl)
} }
for _, peerIdVal := range list.Values() { for _, peerIdVal := range list.Values() {