Skip to content

Commit

Permalink
moved workertimeoutcheck to candowork
Browse files Browse the repository at this point in the history
  • Loading branch information
jdutchak committed Aug 1, 2024
1 parent a9ed152 commit 75f446c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pkg/pubsub/node_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ func (wc WorkerCategory) String() string {
// CanDoWork checks if the node can perform work of the specified WorkerType.
// It returns true if the node is configured for the given worker type, false otherwise.
func (n *NodeData) CanDoWork(workerType WorkerCategory) bool {

if !n.WorkerTimeout.IsZero() && time.Since(n.WorkerTimeout) < 16*time.Minute {
logrus.Infof("[+] Skipping worker %s due to timeout", n.PeerId)
return false
}

switch workerType {
case CategoryTwitter:
return n.IsActive && n.IsTwitterScraper
Expand Down
8 changes: 0 additions & 8 deletions pkg/workers/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,6 @@ func SendWork(node *masa.OracleNode, m *pubsub2.Message) {
if (p.PeerId.String() != node.Host.ID().String()) &&
p.IsStaked &&
node.NodeTracker.GetNodeData(p.PeerId.String()).CanDoWork(pubsub.WorkerCategory(message.Type)) {

// Check WorkerTimeout
nodeData := node.NodeTracker.GetNodeData(p.PeerId.String())
if !nodeData.WorkerTimeout.IsZero() && time.Since(nodeData.WorkerTimeout) < 16*time.Minute {
logrus.Infof("[+] Skipping worker %s due to timeout", p.PeerId)
continue
}

logrus.Infof("[+] Worker Address: %s", ipAddr)
wg.Add(1)
go func(p pubsub.NodeData) {
Expand Down

0 comments on commit 75f446c

Please sign in to comment.