[#128] IR: Do not try to emit GAS to nobody #151

Merged
fyrchik merged 1 commit from carpawell/frostfs-node:fix/not-send-gas-to-nobody into master 2023-03-21 08:59:47 +00:00

View file

@ -49,15 +49,18 @@ func (ap *Processor) processEmit() {
}
nmNodes := networkMap.Nodes()
nmLen := len(nmNodes)
extraLen := len(ap.parsedWallets)
ln := len(nmNodes)
if ln == 0 {
ap.log.Debug("empty network map, do not emit gas")
ap.log.Debug("gas emission",
zap.Int("network_map", nmLen),
zap.Int("extra_wallets", extraLen))
if nmLen+extraLen == 0 {
return
}
gasPerNode := fixedn.Fixed8(ap.storageEmission / uint64(ln+len(ap.parsedWallets)))
gasPerNode := fixedn.Fixed8(ap.storageEmission / uint64(nmLen+extraLen))
for i := range nmNodes {
keyBytes := nmNodes[i].PublicKey()
@ -80,16 +83,18 @@ func (ap *Processor) processEmit() {
}
}
err = ap.morphClient.BatchTransferGas(ap.parsedWallets, gasPerNode)
if err != nil {
receiversLog := make([]string, len(ap.parsedWallets))
for i, addr := range ap.parsedWallets {
receiversLog[i] = addr.StringLE()
if extraLen != 0 {

Can we use 1 log message like Debug("gas emission", zap.Int("network_map", nmLen), zap.Int("extra", extraLen)) instead on 3 (2 in else and 1 if both are 0).

Can we use 1 log message like `Debug("gas emission", zap.Int("network_map", nmLen), zap.Int("extra", extraLen))` instead on 3 (2 in `else` and 1 if both are 0).

fixed

fixed

fixed

fixed
err = ap.morphClient.BatchTransferGas(ap.parsedWallets, gasPerNode)
if err != nil {
receiversLog := make([]string, extraLen)

I had this condition initially but lost it in transition to batch processing. 👽

I had this condition initially but lost it in transition to batch processing. 👽
for i, addr := range ap.parsedWallets {
receiversLog[i] = addr.StringLE()
}
ap.log.Warn("can't transfer gas to wallet",
zap.Strings("receivers", receiversLog),
zap.Int64("amount", int64(gasPerNode)),
zap.String("error", err.Error()),
)
}
ap.log.Warn("can't transfer gas to wallet",
zap.Strings("receivers", receiversLog),
zap.Int64("amount", int64(gasPerNode)),
zap.String("error", err.Error()),
)
}
}