github.com/okex/exchain@v1.8.0/libs/tendermint/proxy/app_conn.go (about)

     1  package proxy
     2  
     3  import (
     4  	abcicli "github.com/okex/exchain/libs/tendermint/abci/client"
     5  	"github.com/okex/exchain/libs/tendermint/abci/types"
     6  )
     7  
     8  //----------------------------------------------------------------------------------------
     9  // Enforce which abci msgs can be sent on a connection at the type level
    10  
    11  type AppConnConsensus interface {
    12  	SetResponseCallback(abcicli.Callback)
    13  	Error() error
    14  
    15  	InitChainSync(types.RequestInitChain) (*types.ResponseInitChain, error)
    16  
    17  	BeginBlockSync(types.RequestBeginBlock) (*types.ResponseBeginBlock, error)
    18  	DeliverTxAsync(types.RequestDeliverTx) *abcicli.ReqRes
    19  	PreDeliverRealTxAsync(req []byte) types.TxEssentials
    20  	DeliverRealTxAsync(essentials types.TxEssentials) *abcicli.ReqRes
    21  	EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)
    22  	CommitSync(types.RequestCommit) (*types.ResponseCommit, error)
    23  	SetOptionAsync(req types.RequestSetOption) *abcicli.ReqRes
    24  	ParallelTxs([][]byte, bool) []*types.ResponseDeliverTx
    25  	SetOptionSync(req types.RequestSetOption) (*types.ResponseSetOption, error)
    26  }
    27  
    28  type AppConnMempool interface {
    29  	SetResponseCallback(abcicli.Callback)
    30  	Error() error
    31  
    32  	CheckTxAsync(types.RequestCheckTx) *abcicli.ReqRes
    33  
    34  	FlushAsync() *abcicli.ReqRes
    35  	FlushSync() error
    36  
    37  	SetOptionAsync(types.RequestSetOption) *abcicli.ReqRes
    38  
    39  	QuerySync(req types.RequestQuery) (*types.ResponseQuery, error)
    40  }
    41  
    42  type AppConnQuery interface {
    43  	Error() error
    44  
    45  	EchoSync(string) (*types.ResponseEcho, error)
    46  	InfoSync(types.RequestInfo) (*types.ResponseInfo, error)
    47  	QuerySync(types.RequestQuery) (*types.ResponseQuery, error)
    48  
    49  	//	SetOptionSync(key string, value string) (res types.Result)
    50  }
    51  
    52  //-----------------------------------------------------------------------------------------
    53  // Implements AppConnConsensus (subset of abcicli.Client)
    54  
    55  type appConnConsensus struct {
    56  	appConn abcicli.Client
    57  }
    58  
    59  func NewAppConnConsensus(appConn abcicli.Client) AppConnConsensus {
    60  	return &appConnConsensus{
    61  		appConn: appConn,
    62  	}
    63  }
    64  
    65  func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
    66  	app.appConn.SetResponseCallback(cb)
    67  }
    68  
    69  func (app *appConnConsensus) Error() error {
    70  	return app.appConn.Error()
    71  }
    72  
    73  func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (*types.ResponseInitChain, error) {
    74  	return app.appConn.InitChainSync(req)
    75  }
    76  
    77  func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
    78  	return app.appConn.BeginBlockSync(req)
    79  }
    80  
    81  func (app *appConnConsensus) DeliverTxAsync(req types.RequestDeliverTx) *abcicli.ReqRes {
    82  	return app.appConn.DeliverTxAsync(req)
    83  }
    84  
    85  func (app *appConnConsensus) PreDeliverRealTxAsync(req []byte) types.TxEssentials {
    86  	return app.appConn.PreDeliverRealTxAsync(req)
    87  }
    88  
    89  func (app *appConnConsensus) DeliverRealTxAsync(req types.TxEssentials) *abcicli.ReqRes {
    90  	return app.appConn.DeliverRealTxAsync(req)
    91  }
    92  
    93  func (app *appConnConsensus) EndBlockSync(req types.RequestEndBlock) (*types.ResponseEndBlock, error) {
    94  	return app.appConn.EndBlockSync(req)
    95  }
    96  
    97  func (app *appConnConsensus) CommitSync(req types.RequestCommit) (*types.ResponseCommit, error) {
    98  	return app.appConn.CommitSync(req)
    99  }
   100  
   101  func (app *appConnConsensus) SetOptionAsync(req types.RequestSetOption) *abcicli.ReqRes {
   102  	return app.appConn.SetOptionAsync(req)
   103  }
   104  
   105  func (app *appConnConsensus) SetOptionSync(req types.RequestSetOption) (*types.ResponseSetOption, error) {
   106  	return app.appConn.SetOptionSync(req)
   107  }
   108  
   109  //------------------------------------------------
   110  // Implements AppConnMempool (subset of abcicli.Client)
   111  
   112  type appConnMempool struct {
   113  	appConn abcicli.Client
   114  }
   115  
   116  func NewAppConnMempool(appConn abcicli.Client) AppConnMempool {
   117  	return &appConnMempool{
   118  		appConn: appConn,
   119  	}
   120  }
   121  
   122  func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
   123  	app.appConn.SetResponseCallback(cb)
   124  }
   125  
   126  func (app *appConnMempool) Error() error {
   127  	return app.appConn.Error()
   128  }
   129  
   130  func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
   131  	return app.appConn.FlushAsync()
   132  }
   133  
   134  func (app *appConnMempool) FlushSync() error {
   135  	return app.appConn.FlushSync()
   136  }
   137  
   138  func (app *appConnMempool) CheckTxAsync(req types.RequestCheckTx) *abcicli.ReqRes {
   139  	return app.appConn.CheckTxAsync(req)
   140  }
   141  
   142  func (app *appConnMempool) SetOptionAsync(req types.RequestSetOption) *abcicli.ReqRes {
   143  	return app.appConn.SetOptionAsync(req)
   144  }
   145  
   146  func (app *appConnMempool) QuerySync(req types.RequestQuery) (*types.ResponseQuery, error) {
   147  	return app.appConn.QuerySync(req)
   148  }
   149  
   150  func (app *appConnConsensus) ParallelTxs(txs [][]byte, onlyCalSender bool) []*types.ResponseDeliverTx {
   151  	return app.appConn.ParallelTxs(txs, onlyCalSender)
   152  }
   153  
   154  //------------------------------------------------
   155  // Implements AppConnQuery (subset of abcicli.Client)
   156  
   157  type appConnQuery struct {
   158  	appConn abcicli.Client
   159  }
   160  
   161  func NewAppConnQuery(appConn abcicli.Client) AppConnQuery {
   162  	return &appConnQuery{
   163  		appConn: appConn,
   164  	}
   165  }
   166  
   167  func (app *appConnQuery) Error() error {
   168  	return app.appConn.Error()
   169  }
   170  
   171  func (app *appConnQuery) EchoSync(msg string) (*types.ResponseEcho, error) {
   172  	return app.appConn.EchoSync(msg)
   173  }
   174  
   175  func (app *appConnQuery) InfoSync(req types.RequestInfo) (*types.ResponseInfo, error) {
   176  	return app.appConn.InfoSync(req)
   177  }
   178  
   179  func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (*types.ResponseQuery, error) {
   180  	return app.appConn.QuerySync(reqQuery)
   181  }