Skip to content

Commit

Permalink
Fix/tip listener (#428) (#430)
Browse files Browse the repository at this point in the history
* fixed a bug in the tip listener and made some small timing changes

* made a couple more small changes

* moved the wait to outside of the inner for loop

(cherry picked from commit 3b9e5d6)

Co-authored-by: CJPotter10 <[email protected]>
  • Loading branch information
github-actions[bot] and CJPotter10 authored Nov 5, 2024
1 parent 662358c commit 26d38d3
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions daemons/reporter/client/reporter_monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ func (c *Client) MonitorCyclelistQuery(ctx context.Context, wg *sync.WaitGroup)
if err != nil {
// log error
c.logger.Error("getting current query", "error", err)
time.Sleep(150 * time.Millisecond)
}
if bytes.Equal(querydata, prevQueryData) || commitedIds[querymeta.Id] {
time.Sleep(100 * time.Millisecond)
time.Sleep(150 * time.Millisecond)
continue
}

Expand All @@ -33,11 +34,7 @@ func (c *Client) MonitorCyclelistQuery(ctx context.Context, wg *sync.WaitGroup)
c.logger.Error("Generating CycleList message", "error", err)
}
}(ctx, querydata, querymeta)

err = c.WaitForBlockHeight(ctx, int64(querymeta.Expiration))
if err != nil {
c.logger.Error("Error waiting for block height", "error", err)
}
time.Sleep(250 * time.Millisecond)
}
}

Expand Down Expand Up @@ -83,22 +80,30 @@ func (c *Client) MonitorForTippedQueries(ctx context.Context, wg *sync.WaitGroup
}
height := uint64(status.SyncInfo.LatestBlockHeight)
for i := 0; i < len(res.Queries); i++ {
if height > res.Queries[i].Expiration || commitedIds[res.Queries[i].Id] || strings.EqualFold(res.Queries[i].QueryType, "SpotPrice") {
if height > res.Queries[i].Expiration || strings.EqualFold(res.Queries[i].QueryType, "SpotPrice") {
if len(res.Queries) == 1 || i == (len(res.Queries)-1) {
time.Sleep(200 * time.Millisecond)
}
continue
}
if commitedIds[res.Queries[i].Id] {
if len(res.Queries) == 1 || i == (len(res.Queries)-1) {
time.Sleep(200 * time.Millisecond)
}
continue
}

localWG.Add(1)
go func(query *oracletypes.QueryMeta) {
defer localWG.Done()
err := c.GenerateAndBroadcastSpotPriceReport(ctx, query.GetQueryData(), query)
err := c.GenerateAndBroadcastSpotPriceReport(ctx, query.QueryData, query)
if err != nil {
c.logger.Error("Error generating report for tipped query: ", err)
} else {
c.logger.Info("Broadcasted report for tipped query")
}
c.logger.Info("Broadcasted report for tipped query")
}(res.Queries[i])
}

wg.Wait()

localWG.Wait()
}
}

0 comments on commit 26d38d3

Please sign in to comment.