github.com/pokt-network/tendermint@v0.32.11-0.20230426215212-59310158d3e9/proxy/app_conn.go (about)

     1  package proxy
     2  
     3  import (
     4  	abcicli "github.com/tendermint/tendermint/abci/client"
     5  	"github.com/tendermint/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  	EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)
    20  	CommitSync() (*types.ResponseCommit, error)
    21  }
    22  
    23  type AppConnMempool interface {
    24  	SetResponseCallback(abcicli.Callback)
    25  	Error() error
    26  
    27  	CheckTxAsync(types.RequestCheckTx) *abcicli.ReqRes
    28  
    29  	FlushAsync() *abcicli.ReqRes
    30  	FlushSync() error
    31  }
    32  
    33  type AppConnQuery interface {
    34  	Error() error
    35  
    36  	EchoSync(string) (*types.ResponseEcho, error)
    37  	InfoSync(types.RequestInfo) (*types.ResponseInfo, error)
    38  	QuerySync(types.RequestQuery) (*types.ResponseQuery, error)
    39  
    40  	//	SetOptionSync(key string, value string) (res types.Result)
    41  }
    42  
    43  //-----------------------------------------------------------------------------------------
    44  // Implements AppConnConsensus (subset of abcicli.Client)
    45  
    46  type appConnConsensus struct {
    47  	appConn abcicli.Client
    48  }
    49  
    50  func NewAppConnConsensus(appConn abcicli.Client) AppConnConsensus {
    51  	return &appConnConsensus{
    52  		appConn: appConn,
    53  	}
    54  }
    55  
    56  func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
    57  	app.appConn.SetResponseCallback(cb)
    58  }
    59  
    60  func (app *appConnConsensus) Error() error {
    61  	return app.appConn.Error()
    62  }
    63  
    64  func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (*types.ResponseInitChain, error) {
    65  	return app.appConn.InitChainSync(req)
    66  }
    67  
    68  func (app *appConnConsensus) BeginBlockSync(req types.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
    69  	return app.appConn.BeginBlockSync(req)
    70  }
    71  
    72  func (app *appConnConsensus) DeliverTxAsync(req types.RequestDeliverTx) *abcicli.ReqRes {
    73  	return app.appConn.DeliverTxAsync(req)
    74  }
    75  
    76  func (app *appConnConsensus) EndBlockSync(req types.RequestEndBlock) (*types.ResponseEndBlock, error) {
    77  	return app.appConn.EndBlockSync(req)
    78  }
    79  
    80  func (app *appConnConsensus) CommitSync() (*types.ResponseCommit, error) {
    81  	return app.appConn.CommitSync()
    82  }
    83  
    84  //------------------------------------------------
    85  // Implements AppConnMempool (subset of abcicli.Client)
    86  
    87  type appConnMempool struct {
    88  	appConn abcicli.Client
    89  }
    90  
    91  func NewAppConnMempool(appConn abcicli.Client) AppConnMempool {
    92  	return &appConnMempool{
    93  		appConn: appConn,
    94  	}
    95  }
    96  
    97  func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
    98  	app.appConn.SetResponseCallback(cb)
    99  }
   100  
   101  func (app *appConnMempool) Error() error {
   102  	return app.appConn.Error()
   103  }
   104  
   105  func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
   106  	return app.appConn.FlushAsync()
   107  }
   108  
   109  func (app *appConnMempool) FlushSync() error {
   110  	return app.appConn.FlushSync()
   111  }
   112  
   113  func (app *appConnMempool) CheckTxAsync(req types.RequestCheckTx) *abcicli.ReqRes {
   114  	return app.appConn.CheckTxAsync(req)
   115  }
   116  
   117  //------------------------------------------------
   118  // Implements AppConnQuery (subset of abcicli.Client)
   119  
   120  type appConnQuery struct {
   121  	appConn abcicli.Client
   122  }
   123  
   124  func NewAppConnQuery(appConn abcicli.Client) AppConnQuery {
   125  	return &appConnQuery{
   126  		appConn: appConn,
   127  	}
   128  }
   129  
   130  func (app *appConnQuery) Error() error {
   131  	return app.appConn.Error()
   132  }
   133  
   134  func (app *appConnQuery) EchoSync(msg string) (*types.ResponseEcho, error) {
   135  	return app.appConn.EchoSync(msg)
   136  }
   137  
   138  func (app *appConnQuery) InfoSync(req types.RequestInfo) (*types.ResponseInfo, error) {
   139  	return app.appConn.InfoSync(req)
   140  }
   141  
   142  func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (*types.ResponseQuery, error) {
   143  	return app.appConn.QuerySync(reqQuery)
   144  }