tendermint/proxy/app_conn.go

145 lines
3.7 KiB
Go
Raw Normal View History

2015-12-01 20:12:01 -08:00
package proxy
import (
2018-06-21 21:59:02 -07:00
abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/types"
2015-12-01 20:12:01 -08:00
)
2016-08-17 19:28:08 -07:00
//----------------------------------------------------------------------------------------
2017-01-12 12:53:32 -08:00
// Enforce which abci msgs can be sent on a connection at the type level
2016-08-17 19:28:08 -07:00
type AppConnConsensus interface {
2017-01-12 12:53:32 -08:00
SetResponseCallback(abcicli.Callback)
2016-08-17 19:28:08 -07:00
Error() error
2017-11-29 09:22:52 -08:00
InitChainSync(types.RequestInitChain) (*types.ResponseInitChain, error)
2016-08-17 19:28:08 -07:00
2017-11-29 09:22:52 -08:00
BeginBlockSync(types.RequestBeginBlock) (*types.ResponseBeginBlock, error)
2017-01-12 12:55:03 -08:00
DeliverTxAsync(tx []byte) *abcicli.ReqRes
2017-11-29 09:22:52 -08:00
EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)
CommitSync() (*types.ResponseCommit, error)
2016-08-17 19:28:08 -07:00
}
type AppConnMempool interface {
2017-01-12 12:53:32 -08:00
SetResponseCallback(abcicli.Callback)
2016-08-17 19:28:08 -07:00
Error() error
2017-01-12 12:53:32 -08:00
CheckTxAsync(tx []byte) *abcicli.ReqRes
2016-08-17 19:28:08 -07:00
2017-01-12 12:53:32 -08:00
FlushAsync() *abcicli.ReqRes
2016-08-17 19:28:08 -07:00
FlushSync() error
}
type AppConnQuery interface {
Error() error
EchoSync(string) (*types.ResponseEcho, error)
InfoSync(types.RequestInfo) (*types.ResponseInfo, error)
QuerySync(types.RequestQuery) (*types.ResponseQuery, error)
2016-08-17 19:28:08 -07:00
// SetOptionSync(key string, value string) (res types.Result)
}
//-----------------------------------------------------------------------------------------
2017-01-12 12:53:32 -08:00
// Implements AppConnConsensus (subset of abcicli.Client)
2016-08-17 19:28:08 -07:00
type appConnConsensus struct {
2017-01-12 12:53:32 -08:00
appConn abcicli.Client
2016-08-17 19:28:08 -07:00
}
2017-01-12 12:53:32 -08:00
func NewAppConnConsensus(appConn abcicli.Client) *appConnConsensus {
2016-08-17 19:28:08 -07:00
return &appConnConsensus{
appConn: appConn,
}
}
2017-01-12 12:53:32 -08:00
func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
2016-08-17 19:28:08 -07:00
app.appConn.SetResponseCallback(cb)
}
2016-08-23 18:44:07 -07:00
2016-08-17 19:28:08 -07:00
func (app *appConnConsensus) Error() error {
return app.appConn.Error()
}
2016-08-23 18:44:07 -07:00
2017-11-29 09:22:52 -08:00
func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (*types.ResponseInitChain, error) {
return app.appConn.InitChainSync(req)
2016-08-17 19:28:08 -07:00
}
2016-08-23 18:44:07 -07:00
2017-11-29 09:22:52 -08:00
func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
return app.appConn.BeginBlockSync(req)
2016-08-17 19:28:08 -07:00
}
2016-08-23 18:44:07 -07:00
2017-01-12 12:55:03 -08:00
func (app *appConnConsensus) DeliverTxAsync(tx []byte) *abcicli.ReqRes {
return app.appConn.DeliverTxAsync(tx)
2016-08-17 19:28:08 -07:00
}
2017-11-29 09:22:52 -08:00
func (app *appConnConsensus) EndBlockSync(req types.RequestEndBlock) (*types.ResponseEndBlock, error) {
return app.appConn.EndBlockSync(req)
2016-08-17 19:28:08 -07:00
}
func (app *appConnConsensus) CommitSync() (*types.ResponseCommit, error) {
2016-08-17 19:28:08 -07:00
return app.appConn.CommitSync()
}
//------------------------------------------------
2017-01-12 12:53:32 -08:00
// Implements AppConnMempool (subset of abcicli.Client)
2016-08-17 19:28:08 -07:00
type appConnMempool struct {
2017-01-12 12:53:32 -08:00
appConn abcicli.Client
2016-08-17 19:28:08 -07:00
}
2017-01-12 12:53:32 -08:00
func NewAppConnMempool(appConn abcicli.Client) *appConnMempool {
2016-08-17 19:28:08 -07:00
return &appConnMempool{
appConn: appConn,
}
}
2017-01-12 12:53:32 -08:00
func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
2016-08-17 19:28:08 -07:00
app.appConn.SetResponseCallback(cb)
}
func (app *appConnMempool) Error() error {
return app.appConn.Error()
}
2017-01-12 12:53:32 -08:00
func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
2016-08-17 19:28:08 -07:00
return app.appConn.FlushAsync()
}
func (app *appConnMempool) FlushSync() error {
return app.appConn.FlushSync()
}
2017-01-12 12:53:32 -08:00
func (app *appConnMempool) CheckTxAsync(tx []byte) *abcicli.ReqRes {
2016-08-17 19:28:08 -07:00
return app.appConn.CheckTxAsync(tx)
}
//------------------------------------------------
2017-01-12 12:53:32 -08:00
// Implements AppConnQuery (subset of abcicli.Client)
2016-08-17 19:28:08 -07:00
type appConnQuery struct {
2017-01-12 12:53:32 -08:00
appConn abcicli.Client
2016-08-17 19:28:08 -07:00
}
2017-01-12 12:53:32 -08:00
func NewAppConnQuery(appConn abcicli.Client) *appConnQuery {
2016-08-17 19:28:08 -07:00
return &appConnQuery{
appConn: appConn,
}
}
func (app *appConnQuery) Error() error {
return app.appConn.Error()
}
func (app *appConnQuery) EchoSync(msg string) (*types.ResponseEcho, error) {
2016-08-25 11:16:28 -07:00
return app.appConn.EchoSync(msg)
}
func (app *appConnQuery) InfoSync(req types.RequestInfo) (*types.ResponseInfo, error) {
return app.appConn.InfoSync(req)
2016-08-17 19:28:08 -07:00
}
func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (*types.ResponseQuery, error) {
2017-01-28 08:27:13 -08:00
return app.appConn.QuerySync(reqQuery)
2015-12-01 20:12:01 -08:00
}