Skip to content

Commit

Permalink
handle no last finalized height scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 committed Jan 1, 2025
1 parent 4db01c4 commit f71ce62
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions eibc/order_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,16 @@ func (p *orderPoller) getDemandOrdersFromIndexer(ctx context.Context) ([]Order,
}

func (p *orderPoller) getRollappDemandOrdersFromIndexer(ctx context.Context, rollappId string) ([]Order, error) {
lastFinalizedHeight, err := p.rollappClient.LatestHeight(ctx, &types.QueryGetLatestHeightRequest{
var lastFinalizedHeight string
lastHeightResp, err := p.rollappClient.LatestHeight(ctx, &types.QueryGetLatestHeightRequest{
RollappId: rollappId,
Finalized: true,
})
if err != nil {
return nil, fmt.Errorf("failed to get latest finalized height for rollapp '%s': %w", rollappId, err)
if err == nil {
lastFinalizedHeight = fmt.Sprint(lastHeightResp.Height)
}

queryStr := fmt.Sprintf(rollappOrdersQuery, p.chainID, fmt.Sprint(p.lastBlockHeight.Load()), rollappId, fmt.Sprint(lastFinalizedHeight.Height))
queryStr := fmt.Sprintf(rollappOrdersQuery, p.chainID, fmt.Sprint(p.lastBlockHeight.Load()), rollappId, lastFinalizedHeight)
body := strings.NewReader(queryStr)

resp, err := p.indexerClient.Post(p.indexerURL, "application/json", body)
Expand All @@ -259,4 +260,7 @@ func (p *orderPoller) getRollappDemandOrdersFromIndexer(ctx context.Context, rol

func (p *orderPoller) resetOrderPolling() {
p.lastBlockHeight.Store(0)
if err := p.pollPendingDemandOrders(context.Background()); err != nil {
p.logger.Error("failed to refresh demand orders", zap.Error(err))
}
}

0 comments on commit f71ce62

Please sign in to comment.