From 3eff1abba7e675c846e084ac447e0001e936ce60 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 15 Nov 2024 12:15:44 +0800 Subject: [PATCH] improve deposit.GetCurrentConfirmation --- pkg/strategy/deposit2transfer/strategy.go | 9 +++++++-- pkg/types/deposit.go | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/strategy/deposit2transfer/strategy.go b/pkg/strategy/deposit2transfer/strategy.go index 59c305d0a..c4ce5e610 100644 --- a/pkg/strategy/deposit2transfer/strategy.go +++ b/pkg/strategy/deposit2transfer/strategy.go @@ -369,8 +369,13 @@ func (s *Strategy) scanDepositHistory(ctx context.Context, asset string, duratio case types.DepositSuccess: logger.Infof("found pending -> success deposit: %+v", deposit) current, required := deposit.GetCurrentConfirmation() - if required > 0 && deposit.UnlockConfirm > 0 && current < deposit.UnlockConfirm { - logger.Infof("deposit %s unlock confirm %d is not reached, current: %d, required: %d, skip this round", deposit.TransactionID, deposit.UnlockConfirm, current, required) + if deposit.UnlockConfirm > 0 { + if current < deposit.UnlockConfirm { + logger.Infof("deposit %s unlock confirm %d is not reached, current: %d, required: %d, skip this round", deposit.TransactionID, deposit.UnlockConfirm, current, required) + continue + } + } else if required > 0 && current < required { + logger.Infof("deposit %s confirm %d/%d is not reached", deposit.TransactionID, current, required) continue } diff --git a/pkg/types/deposit.go b/pkg/types/deposit.go index eb78440aa..4f01d5efd 100644 --- a/pkg/types/deposit.go +++ b/pkg/types/deposit.go @@ -71,7 +71,10 @@ func (d Deposit) GetCurrentConfirmation() (current int, required int) { } strs := strings.Split(d.Confirmation, "/") - if len(strs) < 2 { + if len(strs) == 1 { + current, _ = strconv.Atoi(strs[0]) + return current, 0 + } else if len(strs) < 2 { return 0, 0 }