Skip to content

Commit

Permalink
coin distribution: fix infinity loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-dionysos committed Dec 28, 2023
1 parent 12278af commit 5b8aef0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions coin-distribution/coin_distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/ice-blockchain/wintr/log"
)

func (d *databaseConfig) MustDisable(ctx context.Context, reason string) {
for err := d.Disable(ctx); err != nil; err = d.Disable(ctx) {
func (d *databaseConfig) MustDisable(reason string) {
for err := d.Disable(context.Background()); err != nil; err = d.Disable(context.Background()) {
log.Error(errors.Wrap(err, "failed to disable coinDistributer"))
stdlibtime.Sleep(stdlibtime.Millisecond)
}

log.Error(sendCoinDistributionsProcessingStoppedDueToUnrecoverableFailureSlackMessage(ctx, reason),
log.Error(sendCoinDistributionsProcessingStoppedDueToUnrecoverableFailureSlackMessage(context.Background(), reason),
"failed to sendCoinDistributionsProcessingStoppedDueToUnrecoverableFailureSlackMessage")
}

Expand Down
4 changes: 2 additions & 2 deletions coin-distribution/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (proc *coinProcessor) Do(ctx context.Context, num int64) (*batch, error) {
if err2 := proc.BatchMarkRejected(ctx, num, data); err2 != nil {
log.Error(errors.Wrapf(err2, "worker [%v]: failed to mark batch %v as rejected", num, data.ID))
}
proc.MustDisable(ctx, err.Error())
proc.MustDisable(err.Error())

return data, err
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func (proc *coinProcessor) Controller(ctx context.Context) {
err := proc.RunWorkers(ctx)
if err != nil {
log.Error(errors.Wrapf(err, "controller: worker(s) failed"))
proc.MustDisable(ctx, err.Error())
proc.MustDisable(err.Error())
} else if !proc.HasPendingTransactions(ctx, ethApiStatusNew) {
log.Error(errors.Wrapf(sendCurrentCoinDistributionsFinishedBeingSentToEthereumSlackMessage(ctx),
"failed to sendCurrentCoinDistributionsFinishedBeingSentToEthereumSlackMessage"))
Expand Down
2 changes: 1 addition & 1 deletion coin-distribution/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (ct *coinTracker) ProcessTransactionsHashes(ctx context.Context, hashes []*
if err != nil {
msg = err.Error()
}
ct.MustDisable(ctx, fmt.Sprintf("some transactions failed: %v", msg))
ct.MustDisable(fmt.Sprintf("some transactions failed: %v", msg))
delete(statuses, ethTxStatusFailed)
}

Expand Down

0 comments on commit 5b8aef0

Please sign in to comment.