forked from TrueCloudLab/frostfs-node
[#128] IR: Do not try to emit GAS to nobody
Fix sending GAS to an empty extra wallets receivers list. Also, send GAS to extra wallets even if netmap is empty. Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
7a31988a36
commit
9a4f40626c
1 changed files with 19 additions and 14 deletions
|
@ -50,15 +50,18 @@ func (ap *Processor) processEmit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nmNodes := networkMap.Nodes()
|
nmNodes := networkMap.Nodes()
|
||||||
|
nmLen := len(nmNodes)
|
||||||
|
extraLen := len(ap.parsedWallets)
|
||||||
|
|
||||||
ln := len(nmNodes)
|
ap.log.Debug("gas emission",
|
||||||
if ln == 0 {
|
zap.Int("network_map", nmLen),
|
||||||
ap.log.Debug("empty network map, do not emit gas")
|
zap.Int("extra_wallets", extraLen))
|
||||||
|
|
||||||
|
if nmLen+extraLen == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
gasPerNode := fixedn.Fixed8(ap.storageEmission / uint64(ln+len(ap.parsedWallets)))
|
gasPerNode := fixedn.Fixed8(ap.storageEmission / uint64(nmLen+extraLen))
|
||||||
|
|
||||||
for i := range nmNodes {
|
for i := range nmNodes {
|
||||||
keyBytes := nmNodes[i].PublicKey()
|
keyBytes := nmNodes[i].PublicKey()
|
||||||
|
@ -81,9 +84,10 @@ func (ap *Processor) processEmit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if extraLen != 0 {
|
||||||
err = ap.morphClient.BatchTransferGas(ap.parsedWallets, gasPerNode)
|
err = ap.morphClient.BatchTransferGas(ap.parsedWallets, gasPerNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
receiversLog := make([]string, len(ap.parsedWallets))
|
receiversLog := make([]string, extraLen)
|
||||||
for i, addr := range ap.parsedWallets {
|
for i, addr := range ap.parsedWallets {
|
||||||
receiversLog[i] = addr.StringLE()
|
receiversLog[i] = addr.StringLE()
|
||||||
}
|
}
|
||||||
|
@ -93,4 +97,5 @@ func (ap *Processor) processEmit() {
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue