File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,16 @@ package pkg
33import (
44 "context"
55 "encoding/hex"
6- "fmt"
76 "net/http"
87 "net/rpc"
98 "time"
109
1110 "github.com/yetanotherco/aligned_layer/core/types"
1211)
1312
13+ const waitForEventRetries = 50
14+ const waitForEventSleepSeconds = 4 * time .Second
15+
1416func (agg * Aggregator ) ServeOperators () error {
1517 // Registers a new RPC server
1618 err := rpc .Register (agg )
@@ -49,13 +51,18 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponse(signedTaskResponse *typ
4951 "merkleRoot" , hex .EncodeToString (signedTaskResponse .BatchMerkleRoot [:]),
5052 "operatorId" , hex .EncodeToString (signedTaskResponse .OperatorId [:]))
5153
52- agg .taskMutex .Lock ()
53- agg .AggregatorConfig .BaseConfig .Logger .Info ("- Locked Resources: Starting processing of Response" )
54- taskIndex , ok := agg .batchesIdxByRoot [signedTaskResponse .BatchMerkleRoot ]
55- if ! ok {
56- agg .AggregatorConfig .BaseConfig .Logger .Info ("- Unlocked Resources" )
57- agg .taskMutex .Unlock ()
58- return fmt .Errorf ("task with batch merkle root %d does not exist" , signedTaskResponse .BatchMerkleRoot )
54+ taskIndex := uint32 (0 )
55+ for i := 0 ; i < waitForEventRetries ; i ++ {
56+ agg .taskMutex .Lock ()
57+ agg .AggregatorConfig .BaseConfig .Logger .Info ("- Locked Resources: Starting processing of Response" )
58+ ok := false
59+ taskIndex , ok = agg .batchesIdxByRoot [signedTaskResponse .BatchMerkleRoot ]
60+ if ! ok {
61+ agg .taskMutex .Unlock ()
62+ time .Sleep (waitForEventSleepSeconds )
63+ } else {
64+ break
65+ }
5966 }
6067
6168 // Don't wait infinitely if it can't answer
You can’t perform that action at this time.
0 commit comments