Skip to content

Commit

Permalink
added method to get votes on state for a specific block number
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsuryansh committed Jul 2, 2023
1 parent cdfde59 commit 5a72b84
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion x/evmstorechain/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"strconv"
)

var (
Expand Down Expand Up @@ -143,6 +144,17 @@ func (AppModule) ConsensusVersion() uint64 { return 1 }
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

// EndBlock contains the logic that is automatically triggered at the end of each block
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
votes := am.keeper.GetAllVote(ctx)

for _, vote := range votes {
blockNum := vote.Blocknumber
state, ok := am.keeper.HasMaxVotes(ctx, blockNum)
if ok {
// Maximum votes reached, set the state
cs := types.Blockstoragestate{Blocknumber : strconv.Itoa(int(blockNum)), State: state}
am.keeper.SetBlockstoragestate(ctx, cs)
}
}
return []abci.ValidatorUpdate{}
}

0 comments on commit 5a72b84

Please sign in to comment.