cosmos-sdk/x/distribution/abci_app.go

32 lines
833 B
Go
Raw Normal View History

2018-09-13 23:35:02 -07:00
package distribution
import (
abci "github.com/tendermint/tendermint/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
2018-09-13 23:35:02 -07:00
)
// set the proposer for determining distribution during endblock
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) {
2018-10-04 15:37:46 -07:00
consAddr := sdk.ConsAddress(req.Header.ProposerAddress)
2018-09-19 20:01:55 -07:00
k.SetProposerConsAddr(ctx, consAddr)
// determine the total number of signed power
sumPrecommitPower := int64(0)
for _, voteInfo := range req.LastCommitInfo.GetVotes() {
if voteInfo.SignedLastBlock {
sumPrecommitPower += voteInfo.Validator.Power
}
}
k.SetSumPrecommitPower(ctx, sumPrecommitPower)
2018-09-13 23:35:02 -07:00
}
// allocate fees
func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
2018-09-28 01:02:07 -07:00
if ctx.BlockHeight() < 2 {
return
}
2018-09-13 23:35:02 -07:00
k.AllocateFees(ctx)
}