Starting to use tmsp.BlockchainAware

This commit is contained in:
Jae Kwon
2016-03-05 20:57:36 -08:00
parent 11e0f7ed8e
commit 16437867ff
3 changed files with 51 additions and 2 deletions

View File

@ -100,6 +100,33 @@ func (app *localAppConn) CommitSync() (hash []byte, log string, err error) {
return hash, log, nil
}
func (app *localAppConn) InitChainSync(validators []*tmsp.Validator) (err error) {
app.mtx.Lock()
if bcApp, ok := app.Application.(tmsp.BlockchainAware); ok {
bcApp.InitChain(validators)
}
app.mtx.Unlock()
return nil
}
func (app *localAppConn) BeginBlockSync(height uint64) (err error) {
app.mtx.Lock()
if bcApp, ok := app.Application.(tmsp.BlockchainAware); ok {
bcApp.BeginBlock(height)
}
app.mtx.Unlock()
return nil
}
func (app *localAppConn) EndBlockSync() (changedValidators []*tmsp.Validator, err error) {
app.mtx.Lock()
if bcApp, ok := app.Application.(tmsp.BlockchainAware); ok {
changedValidators = bcApp.EndBlock()
}
app.mtx.Unlock()
return changedValidators, nil
}
//-------------------------------------------------------
func (app *localAppConn) callback(req *tmsp.Request, res *tmsp.Response) *tmspcli.ReqRes {