improve deposit.GetCurrentConfirmation

This commit is contained in:
c9s 2024-11-15 12:15:44 +08:00
parent 0917b13b3f
commit 3eff1abba7
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 11 additions and 3 deletions

View File

@ -369,10 +369,15 @@ 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 {
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
}
succeededDeposits = append(succeededDeposits, deposit)
delete(s.watchingDeposits, deposit.TransactionID)

View File

@ -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
}