Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: abci extension #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package module

import (
"encoding/json"

"github.com/gorilla/mux"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -144,7 +145,7 @@ type AppModule interface {

// ABCI
BeginBlock(sdk.Context, abci.RequestBeginBlock)
EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
EndBlock(sdk.Context, abci.RequestEndBlock) abci.ModuleEndBlock
}

//___________________________
Expand Down Expand Up @@ -180,8 +181,8 @@ func (gam GenesisOnlyAppModule) NewQuerierHandler() sdk.Querier { return nil }
func (gam GenesisOnlyAppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}

// EndBlock returns an empty module end-block
func (GenesisOnlyAppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
func (GenesisOnlyAppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) abci.ModuleEndBlock {
return abci.ModuleEndBlock{}
}

//____________________________________________________________________________
Expand Down Expand Up @@ -306,10 +307,12 @@ func (m *Manager) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) abci.R
// modules.
func (m *Manager) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
ctx = ctx.WithEventManager(sdk.NewEventManager())
validatorUpdates := []abci.ValidatorUpdate{}
var validatorUpdates []abci.ValidatorUpdate
var seed []byte

for _, moduleName := range m.OrderEndBlockers {
moduleValUpdates := m.Modules[moduleName].EndBlock(ctx, req)
moduleEndBlock := m.Modules[moduleName].EndBlock(ctx, req)
moduleValUpdates := moduleEndBlock.Validators

// use these validator updates if provided, the module manager assumes
// only one module will update the validator set
Expand All @@ -320,6 +323,15 @@ func (m *Manager) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo

validatorUpdates = moduleValUpdates
}

if len(moduleEndBlock.Seed) > 0 {
if len(seed) > 0 {
panic("seed EndBlock updates already set by a previous module")
}

seed = moduleEndBlock.Seed
}

}

return abci.ResponseEndBlock{
Expand Down