Skip to content

Commit

Permalink
mv conditional to top
Browse files Browse the repository at this point in the history
  • Loading branch information
akremstudy committed Dec 18, 2024
1 parent 5486f5a commit f1b9c1d
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,26 +1008,27 @@ func (app *App) preBlocker(ph *ProposalHandler) func(ctx sdk.Context, _ *abci.Re
if err != nil {
return nil, err
}
bondedPoolBal := app.BankKeeper.GetBalance(ctx, authtypes.NewModuleAddress(stakingtypes.BondedPoolName), "loya")
vals, err := app.StakingKeeper.GetValidators(ctx, 7) // only 6 validators exist
if err != nil {
return nil, err
}
bondedtotal := math.ZeroInt()
notbondedtotal := math.ZeroInt()
for _, v := range vals {
if v.IsBonded() {
bondedtotal = bondedtotal.Add(v.Tokens)
} else {
notbondedtotal = notbondedtotal.Add(v.Tokens)
if ctx.BlockHeight() == 1062219+1 { // todo: figure out height
bondedPoolBal := app.BankKeeper.GetBalance(ctx, authtypes.NewModuleAddress(stakingtypes.BondedPoolName), "loya")
vals, err := app.StakingKeeper.GetValidators(ctx, 7) // only 6 validators exist
if err != nil {
return nil, err
}
}
// transfer amount should be 1950000000
// "spendable balance 97171770000loya is smaller than 99121770000loya
transferAmt := bondedPoolBal.Amount.Sub(bondedtotal)
if transferAmt.Equal(math.NewInt(1950000000)) { // manually checked amount
// last_block_height":"1062219"
if ctx.BlockHeight() == 1062219+1 { // todo: figure out height
bondedtotal := math.ZeroInt()
notbondedtotal := math.ZeroInt()
for _, v := range vals {
if v.IsBonded() {
bondedtotal = bondedtotal.Add(v.Tokens)
} else {
notbondedtotal = notbondedtotal.Add(v.Tokens)
}
}
// transfer amount should be 1950000000
// "spendable balance 97171770000loya is smaller than 99121770000loya
transferAmt := bondedPoolBal.Amount.Sub(bondedtotal)
if transferAmt.Equal(math.NewInt(1950000000)) { // manually checked amount
// last_block_height":"1062219"

err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, sdk.NewCoins(sdk.NewCoin("loya", transferAmt)))
if err != nil {
return nil, err
Expand Down

0 comments on commit f1b9c1d

Please sign in to comment.