2020-07-24 13:54:03 +00:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
2024-10-21 07:22:54 +00:00
|
|
|
"context"
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2023-03-07 13:38:26 +00:00
|
|
|
frostfsContract "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/frostfs"
|
|
|
|
balanceEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/balance"
|
2020-07-24 13:54:03 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Process lock event by invoking Cheque method in main net to send assets
|
|
|
|
// back to the withdraw issuer.
|
2023-05-26 10:24:41 +00:00
|
|
|
func (bp *Processor) processLock(lock *balanceEvent.Lock) bool {
|
2021-03-23 15:20:44 +00:00
|
|
|
if !bp.alphabetState.IsAlphabet() {
|
2024-10-21 07:22:54 +00:00
|
|
|
bp.log.Info(context.Background(), logs.BalanceNonAlphabetModeIgnoreBalanceLock)
|
2023-05-26 10:24:41 +00:00
|
|
|
return true
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
|
|
|
|
2023-01-10 12:50:17 +00:00
|
|
|
prm := frostfsContract.ChequePrm{}
|
2021-11-10 11:05:51 +00:00
|
|
|
|
|
|
|
prm.SetID(lock.ID())
|
|
|
|
prm.SetUser(lock.User())
|
|
|
|
prm.SetAmount(bp.converter.ToFixed8(lock.Amount()))
|
|
|
|
prm.SetLock(lock.LockAccount())
|
|
|
|
prm.SetHash(lock.TxHash())
|
|
|
|
|
2023-01-10 13:07:47 +00:00
|
|
|
err := bp.frostfsClient.Cheque(prm)
|
2020-07-24 13:54:03 +00:00
|
|
|
if err != nil {
|
2024-10-21 07:22:54 +00:00
|
|
|
bp.log.Error(context.Background(), logs.BalanceCantSendLockAssetTx, zap.Error(err))
|
2023-05-26 10:24:41 +00:00
|
|
|
return false
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
2023-05-26 10:24:41 +00:00
|
|
|
|
|
|
|
return true
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|