mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 23:57:04 +00:00
New TMSP message BeginBlock
This commit is contained in:
@@ -28,7 +28,12 @@ type Client interface {
|
||||
QuerySync(tx []byte) (res types.Result)
|
||||
CommitSync() (res types.Result)
|
||||
|
||||
InitChainAsync(validators []*types.Validator) *ReqRes
|
||||
BeginBlockAsync(height uint64) *ReqRes
|
||||
EndBlockAsync(height uint64) *ReqRes
|
||||
|
||||
InitChainSync(validators []*types.Validator) (err error)
|
||||
BeginBlockSync(height uint64) (err error)
|
||||
EndBlockSync(height uint64) (changedValidators []*types.Validator, err error)
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,44 @@ func (app *localClient) CommitAsync() *ReqRes {
|
||||
)
|
||||
}
|
||||
|
||||
func (app *localClient) InitChainAsync(validators []*types.Validator) *ReqRes {
|
||||
app.mtx.Lock()
|
||||
if bcApp, ok := app.Application.(types.BlockchainAware); ok {
|
||||
bcApp.InitChain(validators)
|
||||
}
|
||||
reqRes := app.callback(
|
||||
types.RequestInitChain(validators),
|
||||
types.ResponseInitChain(),
|
||||
)
|
||||
app.mtx.Unlock()
|
||||
return reqRes
|
||||
}
|
||||
|
||||
func (app *localClient) BeginBlockAsync(height uint64) *ReqRes {
|
||||
app.mtx.Lock()
|
||||
if bcApp, ok := app.Application.(types.BlockchainAware); ok {
|
||||
bcApp.BeginBlock(height)
|
||||
}
|
||||
app.mtx.Unlock()
|
||||
return app.callback(
|
||||
types.RequestBeginBlock(height),
|
||||
types.ResponseBeginBlock(),
|
||||
)
|
||||
}
|
||||
|
||||
func (app *localClient) EndBlockAsync(height uint64) *ReqRes {
|
||||
app.mtx.Lock()
|
||||
var validators []*types.Validator
|
||||
if bcApp, ok := app.Application.(types.BlockchainAware); ok {
|
||||
validators = bcApp.EndBlock(height)
|
||||
}
|
||||
app.mtx.Unlock()
|
||||
return app.callback(
|
||||
types.RequestEndBlock(height),
|
||||
types.ResponseEndBlock(validators),
|
||||
)
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
||||
func (app *localClient) FlushSync() error {
|
||||
@@ -169,6 +207,15 @@ func (app *localClient) InitChainSync(validators []*types.Validator) (err error)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (app *localClient) BeginBlockSync(height uint64) (err error) {
|
||||
app.mtx.Lock()
|
||||
if bcApp, ok := app.Application.(types.BlockchainAware); ok {
|
||||
bcApp.BeginBlock(height)
|
||||
}
|
||||
app.mtx.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (app *localClient) EndBlockSync(height uint64) (changedValidators []*types.Validator, err error) {
|
||||
app.mtx.Lock()
|
||||
if bcApp, ok := app.Application.(types.BlockchainAware); ok {
|
||||
|
||||
@@ -246,6 +246,10 @@ func (cli *remoteClient) InitChainAsync(validators []*types.Validator) *ReqRes {
|
||||
return cli.queueRequest(types.RequestInitChain(validators))
|
||||
}
|
||||
|
||||
func (cli *remoteClient) BeginBlockAsync(height uint64) *ReqRes {
|
||||
return cli.queueRequest(types.RequestBeginBlock(height))
|
||||
}
|
||||
|
||||
func (cli *remoteClient) EndBlockAsync(height uint64) *ReqRes {
|
||||
return cli.queueRequest(types.RequestEndBlock(height))
|
||||
}
|
||||
@@ -336,6 +340,15 @@ func (cli *remoteClient) InitChainSync(validators []*types.Validator) (err error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cli *remoteClient) BeginBlockSync(height uint64) (err error) {
|
||||
cli.queueRequest(types.RequestBeginBlock(height))
|
||||
cli.FlushSync()
|
||||
if cli.err != nil {
|
||||
return cli.err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cli *remoteClient) EndBlockSync(height uint64) (validators []*types.Validator, err error) {
|
||||
reqres := cli.queueRequest(types.RequestEndBlock(height))
|
||||
cli.FlushSync()
|
||||
|
||||
Reference in New Issue
Block a user