Skip to content

Commit

Permalink
Add AddrInfo to localWorker in worker_selection.go
Browse files Browse the repository at this point in the history
This commit adds the AddrInfo struct to the localWorker object in worker_selection.go. This change ensures that localWorker now contains information about its ID and addresses, which may be necessary for future network operations or worker identification.
  • Loading branch information
restevens402 committed Aug 23, 2024
1 parent 5b794e7 commit 15e3e5f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/workers/worker_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func GetEligibleWorkers(node *masa.OracleNode, category pubsub.WorkerCategory, c
start := time.Now()
for _, eligible := range nodes {
if eligible.PeerId.String() == node.Host.ID().String() {
localWorker = &data_types.Worker{IsLocal: true, NodeData: eligible}
localAddrInfo := peer.AddrInfo{
ID: node.Host.ID(),
Addrs: node.Host.Addrs(),
}
localWorker = &data_types.Worker{IsLocal: true, NodeData: eligible, AddrInfo: &localAddrInfo}
continue
}
addr, err := multiaddr.NewMultiaddr(eligible.MultiaddrsString)
Expand Down Expand Up @@ -60,7 +64,11 @@ func GetEligibleWorkers(node *masa.OracleNode, category pubsub.WorkerCategory, c
if localWorker == nil {
nd := node.NodeTracker.GetNodeData(node.Host.ID().String())
if nd.CanDoWork(category) {
localWorker = &data_types.Worker{IsLocal: true, NodeData: *nd}
localAddrInfo := peer.AddrInfo{
ID: node.Host.ID(),
Addrs: node.Host.Addrs(),
}
localWorker = &data_types.Worker{IsLocal: true, NodeData: *nd, AddrInfo: &localAddrInfo}
}
}
return workers, localWorker
Expand Down

0 comments on commit 15e3e5f

Please sign in to comment.