-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathsubscriber.go
More file actions
34 lines (28 loc) · 983 Bytes
/
subscriber.go
File metadata and controls
34 lines (28 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package pkg
import "github.com/yetanotherco/aligned_layer/core/chainio"
func (agg *Aggregator) SubscribeToNewTasks() *chainio.ErrorPair {
errorPair := agg.subscribeToNewTasks()
if errorPair != nil {
return errorPair
}
for {
select {
case err := <-agg.taskSubscriber:
agg.AggregatorConfig.BaseConfig.Logger.Info("Failed to subscribe to new tasks", "err", err)
errorPair = agg.subscribeToNewTasks()
if errorPair != nil {
return errorPair
}
case newBatch := <-agg.NewBatchChan:
agg.AggregatorConfig.BaseConfig.Logger.Info("Adding new task")
agg.AddNewTask(newBatch.BatchMerkleRoot, newBatch.SenderAddress, newBatch.TaskCreatedBlock)
}
}
}
func (agg *Aggregator) subscribeToNewTasks() *chainio.ErrorPair {
errorPair := agg.avsSubscriber.SubscribeToNewTasksV3(agg.NewBatchChan, agg.taskSubscriber)
if errorPair != nil {
agg.AggregatorConfig.BaseConfig.Logger.Info("Failed to create task subscriber", "err", errorPair)
}
return errorPair
}