mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
Tally Handler Fixes (#1342)
* reassign after addition since values are not modified in place * fix incorrect logic; add bkava when there is no error
This commit is contained in:
parent
e6fc0135aa
commit
7847f3ee7b
@ -193,13 +193,13 @@ func (bkavaMap bkavaByDenom) add(coin sdk.Coin) {
|
|||||||
if !found {
|
if !found {
|
||||||
bkavaMap[coin.Denom] = sdk.ZeroInt()
|
bkavaMap[coin.Denom] = sdk.ZeroInt()
|
||||||
}
|
}
|
||||||
bkavaMap[coin.Denom].Add(coin.Amount)
|
bkavaMap[coin.Denom] = bkavaMap[coin.Denom].Add(coin.Amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bkavaMap bkavaByDenom) toCoins() sdk.Coins {
|
func (bkavaMap bkavaByDenom) toCoins() sdk.Coins {
|
||||||
coins := sdk.Coins{}
|
coins := sdk.Coins{}
|
||||||
for denom, amt := range bkavaMap {
|
for denom, amt := range bkavaMap {
|
||||||
coins.Add(sdk.NewCoin(denom, amt))
|
coins = coins.Add(sdk.NewCoin(denom, amt))
|
||||||
}
|
}
|
||||||
return coins.Sort()
|
return coins.Sort()
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ func (th TallyHandler) addBkavaFromEarn(ctx sdk.Context, addr sdk.AccAddress, bk
|
|||||||
}
|
}
|
||||||
for _, share := range shares {
|
for _, share := range shares {
|
||||||
if th.lk.IsDerivativeDenom(ctx, share.Denom) {
|
if th.lk.IsDerivativeDenom(ctx, share.Denom) {
|
||||||
if coin, err := th.ek.ConvertToAssets(ctx, share); err != nil {
|
if coin, err := th.ek.ConvertToAssets(ctx, share); err == nil {
|
||||||
bkava.add(coin)
|
bkava.add(coin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user