use request structs for InitChain and BeginBlock

This commit is contained in:
Ethan Buchman
2017-09-18 15:51:48 -04:00
parent a072429659
commit f279171a28
12 changed files with 56 additions and 54 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ func (app *ChainAwareApplication) Query(reqQuery types.RequestQuery) (resQuery t
}
}
func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) {
func (app *ChainAwareApplication) BeginBlock(reqBeginBlock types.RequestBeginBlock) {
app.beginCount++
return
}
+1 -1
View File
@@ -37,7 +37,7 @@ func TestChainAware(t *testing.T) {
hash := []byte("fake block hash")
header := &types.Header{}
for i := uint64(0); i < n; i++ {
client.BeginBlockSync(hash, header)
client.BeginBlockSync(&types.RequestBeginBlock{hash, header})
client.EndBlockSync(i)
client.CommitSync()
}
+4 -4
View File
@@ -106,8 +106,8 @@ func (app *PersistentDummyApplication) Query(reqQuery types.RequestQuery) types.
}
// Save the validators in the merkle tree
func (app *PersistentDummyApplication) InitChain(validators []*types.Validator) {
for _, v := range validators {
func (app *PersistentDummyApplication) InitChain(params types.RequestInitChain) {
for _, v := range params.Validators {
r := app.updateValidator(v)
if r.IsErr() {
app.logger.Error("Error updating validators", "r", r)
@@ -116,9 +116,9 @@ func (app *PersistentDummyApplication) InitChain(validators []*types.Validator)
}
// Track the block hash and header information
func (app *PersistentDummyApplication) BeginBlock(hash []byte, header *types.Header) {
func (app *PersistentDummyApplication) BeginBlock(params types.RequestBeginBlock) {
// update latest block info
app.blockHeader = header
app.blockHeader = params.Header
// reset valset changes
app.changes = make([]*types.Validator, 0)