EndBlock also returns ResponseEndBlock

This commit is contained in:
Jae Kwon
2017-01-12 14:50:41 -05:00
committed by Ethan Buchman
parent 8b76f3dd00
commit f8167872d8
13 changed files with 46 additions and 32 deletions
+4 -3
View File
@@ -15,7 +15,7 @@ func main() {
flag.Parse()
// Start the listener
_, err := server.NewServer(*addrPtr, *tmspPtr, NewChainAwareApplication())
srv, err := server.NewServer(*addrPtr, *tmspPtr, NewChainAwareApplication())
if err != nil {
Exit(err.Error())
}
@@ -23,6 +23,7 @@ func main() {
// Wait forever
TrapSignal(func() {
// Cleanup
srv.Stop()
})
}
@@ -65,9 +66,9 @@ func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header)
return
}
func (app *ChainAwareApplication) EndBlock(height uint64) []*types.Validator {
func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {
app.endCount += 1
return nil
return
}
func (app *ChainAwareApplication) InitChain(vals []*types.Validator) {
+2 -1
View File
@@ -16,10 +16,11 @@ func TestChainAware(t *testing.T) {
app := NewChainAwareApplication()
// Start the listener
_, err := server.NewServer("unix://test.sock", "socket", app)
srv, err := server.NewServer("unix://test.sock", "socket", app)
if err != nil {
t.Fatal(err)
}
defer srv.Stop()
// Connect to the socket
client, err := tmspcli.NewSocketClient("unix://test.sock", false)
+2 -2
View File
@@ -179,10 +179,10 @@ func makeApplyBlock(t *testing.T, dummy types.Application, heightInt int, diff [
t.Fatal(r)
}
}
diff2 := dummyChain.EndBlock(height)
resEndBlock := dummyChain.EndBlock(height)
dummy.Commit()
valsEqual(t, diff, diff2)
valsEqual(t, diff, resEndBlock.Diffs)
}
+2 -2
View File
@@ -113,8 +113,8 @@ func (app *PersistentDummyApplication) BeginBlock(hash []byte, header *types.Hea
}
// Update the validator set
func (app *PersistentDummyApplication) EndBlock(height uint64) (diffs []*types.Validator) {
return app.changes
func (app *PersistentDummyApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) {
return types.ResponseEndBlock{Diffs: app.changes}
}
//-----------------------------------------