Skip to content

Commit

Permalink
fix: Request batch now creates batches for every token (#46)
Browse files Browse the repository at this point in the history
* print error instead of returning

* fix scopelint

* fix super-linter version
  • Loading branch information
facundomedica authored Nov 15, 2021
1 parent 0018e16 commit badb131
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# within `super-linter`.
fetch-depth: 0
- name: Run super-linter
uses: github/super-linter@v4
uses: github/super-linter@v4.8.1
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: true
Expand Down
13 changes: 10 additions & 3 deletions orchestrator/main_loops.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ func (p *peggyOrchestrator) BatchRequesterLoop(ctx context.Context) (err error)
if len(unbatchedTokensWithFees) > 0 {
logger.Debug().Msg("checking if token fees meets set threshold amount and send batch request")
for _, unbatchedToken := range unbatchedTokensWithFees {
return retry.Do(func() (err error) {
batchFees := unbatchedToken // use this because of scopelint
err := retry.Do(func() (err error) {
// Check if the token is present in cosmos denom. If so, send batch
// request with cosmosDenom.
tokenAddr := common.HexToAddress(unbatchedToken.Token)
tokenAddr := common.HexToAddress(batchFees.Token)

var denom string
resp, err := p.cosmosQueryClient.ERC20ToDenom(ctx, tokenAddr)
Expand All @@ -248,7 +249,7 @@ func (p *peggyOrchestrator) BatchRequesterLoop(ctx context.Context) (err error)
denom = resp.GetDenom()

// send batch request only if fee threshold is met
if p.CheckFeeThreshold(ctx, tokenAddr, unbatchedToken.TotalFees, p.minBatchFeeUSD) {
if p.CheckFeeThreshold(ctx, tokenAddr, batchFees.TotalFees, p.minBatchFeeUSD) {
logger.Info().Str("token_contract", tokenAddr.String()).Str("denom", denom).Msg("sending batch request")
_ = p.peggyBroadcastClient.SendRequestBatch(ctx, denom)
}
Expand All @@ -257,6 +258,12 @@ func (p *peggyOrchestrator) BatchRequesterLoop(ctx context.Context) (err error)
}, retry.Context(ctx), retry.OnRetry(func(n uint, err error) {
logger.Err(err).Uint("retry", n).Msg("failed to get LatestUnbatchOutgoingTx; retrying...")
}))

if err != nil {
logger.Err(err).
Str("token_address", unbatchedToken.Token).
Msg("exhausted attempts to get LatestUnbatchOutgoingTx")
}
}
} else {
logger.Debug().Msg("no outgoing withdraw tx or unbatched token fee less than threshold")
Expand Down

0 comments on commit badb131

Please sign in to comment.