0g-chain/x/committee/abci.go

33 lines
895 B
Go
Raw Normal View History

2020-03-04 19:16:27 +00:00
package committee
2020-03-12 17:05:40 +00:00
import (
2020-03-27 20:28:51 +00:00
"fmt"
2020-03-12 17:05:40 +00:00
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/committee/types"
)
// BeginBlocker runs at the start of every block.
func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k Keeper) {
// Close all expired proposals
k.IterateProposals(ctx, func(proposal types.Proposal) bool {
if proposal.HasExpiredBy(ctx.BlockTime()) {
2020-03-27 20:28:51 +00:00
2020-03-26 20:17:49 +00:00
k.DeleteProposalAndVotes(ctx, proposal.ID)
2020-03-27 20:28:51 +00:00
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeProposalClose,
sdk.NewAttribute(types.AttributeKeyCommitteeID, fmt.Sprintf("%d", proposal.CommitteeID)),
sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposal.ID)),
sdk.NewAttribute(types.AttributeKeyProposalCloseStatus, types.AttributeValueProposalTimeout),
),
)
2020-03-12 17:05:40 +00:00
}
return false
})
}