[#374] Add inner-ring event metrics
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
8dcd06c587
commit
ebcc8afbee
27 changed files with 287 additions and 113 deletions
|
@ -15,10 +15,10 @@ const (
|
|||
|
||||
// Process deposit event by invoking a balance contract and sending native
|
||||
// gas in the sidechain.
|
||||
func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) {
|
||||
func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) bool {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info(logs.FrostFSNonAlphabetModeIgnoreDeposit)
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
prm := balance.MintPrm{}
|
||||
|
@ -49,7 +49,7 @@ func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) {
|
|||
zap.Uint64("last_emission", val),
|
||||
zap.Uint64("current_epoch", curEpoch))
|
||||
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
// get gas balance of the node
|
||||
|
@ -57,7 +57,7 @@ func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) {
|
|||
balance, err := np.morphClient.GasBalance()
|
||||
if err != nil {
|
||||
np.log.Error(logs.FrostFSCantGetGasBalanceOfTheNode, zap.Error(err))
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
if balance < np.gasBalanceThreshold {
|
||||
|
@ -65,7 +65,7 @@ func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) {
|
|||
zap.Int64("balance", balance),
|
||||
zap.Int64("threshold", np.gasBalanceThreshold))
|
||||
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
err = np.morphClient.TransferGas(receiver, np.mintEmitValue)
|
||||
|
@ -73,24 +73,26 @@ func (np *Processor) processDeposit(deposit frostfsEvent.Deposit) {
|
|||
np.log.Error(logs.FrostFSCantTransferNativeGasToReceiver,
|
||||
zap.String("error", err.Error()))
|
||||
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
np.mintEmitCache.Add(receiver.String(), curEpoch)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Process withdraw event by locking assets in the balance account.
|
||||
func (np *Processor) processWithdraw(withdraw frostfsEvent.Withdraw) {
|
||||
func (np *Processor) processWithdraw(withdraw frostfsEvent.Withdraw) bool {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info(logs.FrostFSNonAlphabetModeIgnoreWithdraw)
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
// create lock account
|
||||
lock, err := util.Uint160DecodeBytesBE(withdraw.ID()[:util.Uint160Size])
|
||||
if err != nil {
|
||||
np.log.Error(logs.FrostFSCantCreateLockAccount, zap.Error(err))
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
curEpoch := np.epochState.EpochCounter()
|
||||
|
@ -106,15 +108,18 @@ func (np *Processor) processWithdraw(withdraw frostfsEvent.Withdraw) {
|
|||
err = np.balanceClient.Lock(prm)
|
||||
if err != nil {
|
||||
np.log.Error(logs.FrostFSCantLockAssetsForWithdraw, zap.Error(err))
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Process cheque event by transferring assets from the lock account back to
|
||||
// the reserve account.
|
||||
func (np *Processor) processCheque(cheque frostfsEvent.Cheque) {
|
||||
func (np *Processor) processCheque(cheque frostfsEvent.Cheque) bool {
|
||||
if !np.alphabetState.IsAlphabet() {
|
||||
np.log.Info(logs.FrostFSNonAlphabetModeIgnoreCheque)
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
prm := balance.BurnPrm{}
|
||||
|
@ -126,5 +131,8 @@ func (np *Processor) processCheque(cheque frostfsEvent.Cheque) {
|
|||
err := np.balanceClient.Burn(prm)
|
||||
if err != nil {
|
||||
np.log.Error(logs.FrostFSCantTransferAssetsToFedContract, zap.Error(err))
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue