forked from TrueCloudLab/frostfs-node
35 lines
968 B
Go
35 lines
968 B
Go
package balance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
frostfsContract "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/frostfs"
|
|
balanceEvent "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/balance"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// Process lock event by invoking Cheque method in main net to send assets
|
|
// back to the withdraw issuer.
|
|
func (bp *Processor) processLock(ctx context.Context, lock *balanceEvent.Lock) bool {
|
|
if !bp.alphabetState.IsAlphabet(ctx) {
|
|
bp.log.Info(ctx, logs.BalanceNonAlphabetModeIgnoreBalanceLock)
|
|
return true
|
|
}
|
|
|
|
prm := frostfsContract.ChequePrm{}
|
|
|
|
prm.SetID(lock.ID())
|
|
prm.SetUser(lock.User())
|
|
prm.SetAmount(bp.converter.ToFixed8(lock.Amount()))
|
|
prm.SetLock(lock.LockAccount())
|
|
prm.SetHash(lock.TxHash())
|
|
|
|
err := bp.frostfsClient.Cheque(ctx, prm)
|
|
if err != nil {
|
|
bp.log.Error(ctx, logs.BalanceCantSendLockAssetTx, zap.Error(err))
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|