mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-21 22:56:22 +00:00
Starting to use tmsp.BlockchainAware
This commit is contained in:
@@ -2,6 +2,7 @@ package proxy
|
||||
|
||||
import (
|
||||
tmspcli "github.com/tendermint/tmsp/client"
|
||||
tmsp "github.com/tendermint/tmsp/types"
|
||||
)
|
||||
|
||||
type AppConn interface {
|
||||
@@ -18,4 +19,7 @@ type AppConn interface {
|
||||
InfoSync() (info string, err error)
|
||||
FlushSync() error
|
||||
CommitSync() (hash []byte, log string, err error)
|
||||
InitChainSync(validators []*tmsp.Validator) (err error)
|
||||
BeginBlockSync(height uint64) (err error)
|
||||
EndBlockSync() (changedValidators []*tmsp.Validator, err error)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user