Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Created July 5, 2022 00:35
Show Gist options
  • Select an option

  • Save zeroFruit/6aa3a1d0a1c9fcf31dcb14d72a03e5b5 to your computer and use it in GitHub Desktop.

Select an option

Save zeroFruit/6aa3a1d0a1c9fcf31dcb14d72a03e5b5 to your computer and use it in GitHub Desktop.
Cosmos Dev Series: Cosmos-SDK-based Blockchain Upgrade - x/gov
// EndBlocker called every block, process inflation, update validator set.
func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) {
keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal types.Proposal) bool {
passes, burnDeposits, tallyResults := keeper.Tally(ctx, proposal)
...
if passes {
handler := keeper.Router().GetRoute(proposal.ProposalRoute())
cacheCtx, writeCache := ctx.CacheContext()
err := handler(cacheCtx, proposal.GetContent())
if err == nil {
...
// write state to the underlying multi-store
writeCache()
}
...
}
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment