diff --git a/pkg/pubsub/node_data.go b/pkg/pubsub/node_data.go index 45722477..dfcd6dc7 100644 --- a/pkg/pubsub/node_data.go +++ b/pkg/pubsub/node_data.go @@ -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 diff --git a/pkg/workers/workers.go b/pkg/workers/workers.go index 57d96cf9..6a2e793f 100644 --- a/pkg/workers/workers.go +++ b/pkg/workers/workers.go @@ -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) {