github.com/line/ostracon@v1.0.10-0.20230328032236-7f20145f065d/proxy/app_conn.go (about)

     1  package proxy
     2  
     3  import (
     4  	"github.com/tendermint/tendermint/abci/types"
     5  
     6  	abcicli "github.com/line/ostracon/abci/client"
     7  	ocabci "github.com/line/ostracon/abci/types"
     8  )
     9  
    10  //nolint
    11  //go:generate mockery --case underscore --name AppConnConsensus|AppConnMempool|AppConnQuery|AppConnSnapshot|ClientCreator
    12  
    13  //----------------------------------------------------------------------------------------
    14  // Enforce which abci msgs can be sent on a connection at the type level
    15  
    16  type AppConnConsensus interface {
    17  	SetGlobalCallback(abcicli.GlobalCallback)
    18  	Error() error
    19  
    20  	InitChainSync(types.RequestInitChain) (*types.ResponseInitChain, error)
    21  
    22  	BeginBlockSync(ocabci.RequestBeginBlock) (*types.ResponseBeginBlock, error)
    23  	DeliverTxAsync(types.RequestDeliverTx, abcicli.ResponseCallback) *abcicli.ReqRes
    24  	EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)
    25  	CommitSync() (*types.ResponseCommit, error)
    26  }
    27  
    28  type AppConnMempool interface {
    29  	SetGlobalCallback(abcicli.GlobalCallback)
    30  	Error() error
    31  
    32  	CheckTxAsync(types.RequestCheckTx, abcicli.ResponseCallback) *abcicli.ReqRes
    33  	CheckTxSync(types.RequestCheckTx) (*ocabci.ResponseCheckTx, error)
    34  
    35  	BeginRecheckTxSync(ocabci.RequestBeginRecheckTx) (*ocabci.ResponseBeginRecheckTx, error)
    36  	EndRecheckTxSync(ocabci.RequestEndRecheckTx) (*ocabci.ResponseEndRecheckTx, error)
    37  
    38  	FlushAsync(abcicli.ResponseCallback) *abcicli.ReqRes
    39  	FlushSync() (*types.ResponseFlush, 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 ocabci.Result)
    50  }
    51  
    52  type AppConnSnapshot interface {
    53  	Error() error
    54  
    55  	ListSnapshotsSync(types.RequestListSnapshots) (*types.ResponseListSnapshots, error)
    56  	OfferSnapshotSync(types.RequestOfferSnapshot) (*types.ResponseOfferSnapshot, error)
    57  	LoadSnapshotChunkSync(types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error)
    58  	ApplySnapshotChunkSync(types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error)
    59  }
    60  
    61  //-----------------------------------------------------------------------------------------
    62  // Implements AppConnConsensus (subset of abcicli.Client)
    63  
    64  type appConnConsensus struct {
    65  	appConn abcicli.Client
    66  }
    67  
    68  func NewAppConnConsensus(appConn abcicli.Client) AppConnConsensus {
    69  	return &appConnConsensus{
    70  		appConn: appConn,
    71  	}
    72  }
    73  
    74  func (app *appConnConsensus) SetGlobalCallback(globalCb abcicli.GlobalCallback) {
    75  	app.appConn.SetGlobalCallback(globalCb)
    76  }
    77  
    78  func (app *appConnConsensus) Error() error {
    79  	return app.appConn.Error()
    80  }
    81  
    82  func (app *appConnConsensus) InitChainSync(req types.RequestInitChain) (*types.ResponseInitChain, error) {
    83  	return app.appConn.InitChainSync(req)
    84  }
    85  
    86  func (app *appConnConsensus) BeginBlockSync(req ocabci.RequestBeginBlock) (*types.ResponseBeginBlock, error) {
    87  	return app.appConn.BeginBlockSync(req)
    88  }
    89  
    90  func (app *appConnConsensus) DeliverTxAsync(req types.RequestDeliverTx, cb abcicli.ResponseCallback) *abcicli.ReqRes {
    91  	return app.appConn.DeliverTxAsync(req, cb)
    92  }
    93  
    94  func (app *appConnConsensus) EndBlockSync(req types.RequestEndBlock) (*types.ResponseEndBlock, error) {
    95  	return app.appConn.EndBlockSync(req)
    96  }
    97  
    98  func (app *appConnConsensus) CommitSync() (*types.ResponseCommit, error) {
    99  	return app.appConn.CommitSync()
   100  }
   101  
   102  //------------------------------------------------
   103  // Implements AppConnMempool (subset of abcicli.Client)
   104  
   105  type appConnMempool struct {
   106  	appConn abcicli.Client
   107  }
   108  
   109  func NewAppConnMempool(appConn abcicli.Client) AppConnMempool {
   110  	return &appConnMempool{
   111  		appConn: appConn,
   112  	}
   113  }
   114  
   115  func (app *appConnMempool) SetGlobalCallback(globalCb abcicli.GlobalCallback) {
   116  	app.appConn.SetGlobalCallback(globalCb)
   117  }
   118  
   119  func (app *appConnMempool) Error() error {
   120  	return app.appConn.Error()
   121  }
   122  
   123  func (app *appConnMempool) FlushAsync(cb abcicli.ResponseCallback) *abcicli.ReqRes {
   124  	return app.appConn.FlushAsync(cb)
   125  }
   126  
   127  func (app *appConnMempool) FlushSync() (*types.ResponseFlush, error) {
   128  	return app.appConn.FlushSync()
   129  }
   130  
   131  func (app *appConnMempool) CheckTxAsync(req types.RequestCheckTx, cb abcicli.ResponseCallback) *abcicli.ReqRes {
   132  	return app.appConn.CheckTxAsync(req, cb)
   133  }
   134  
   135  func (app *appConnMempool) CheckTxSync(req types.RequestCheckTx) (*ocabci.ResponseCheckTx, error) {
   136  	return app.appConn.CheckTxSync(req)
   137  }
   138  
   139  func (app *appConnMempool) BeginRecheckTxSync(req ocabci.RequestBeginRecheckTx) (*ocabci.ResponseBeginRecheckTx, error) {
   140  	return app.appConn.BeginRecheckTxSync(req)
   141  }
   142  
   143  func (app *appConnMempool) EndRecheckTxSync(req ocabci.RequestEndRecheckTx) (*ocabci.ResponseEndRecheckTx, error) {
   144  	return app.appConn.EndRecheckTxSync(req)
   145  }
   146  
   147  //------------------------------------------------
   148  // Implements AppConnQuery (subset of abcicli.Client)
   149  
   150  type appConnQuery struct {
   151  	appConn abcicli.Client
   152  }
   153  
   154  func NewAppConnQuery(appConn abcicli.Client) AppConnQuery {
   155  	return &appConnQuery{
   156  		appConn: appConn,
   157  	}
   158  }
   159  
   160  func (app *appConnQuery) Error() error {
   161  	return app.appConn.Error()
   162  }
   163  
   164  func (app *appConnQuery) EchoSync(msg string) (*types.ResponseEcho, error) {
   165  	return app.appConn.EchoSync(msg)
   166  }
   167  
   168  func (app *appConnQuery) InfoSync(req types.RequestInfo) (*types.ResponseInfo, error) {
   169  	return app.appConn.InfoSync(req)
   170  }
   171  
   172  func (app *appConnQuery) QuerySync(reqQuery types.RequestQuery) (*types.ResponseQuery, error) {
   173  	return app.appConn.QuerySync(reqQuery)
   174  }
   175  
   176  //------------------------------------------------
   177  // Implements AppConnSnapshot (subset of abcicli.Client)
   178  
   179  type appConnSnapshot struct {
   180  	appConn abcicli.Client
   181  }
   182  
   183  func NewAppConnSnapshot(appConn abcicli.Client) AppConnSnapshot {
   184  	return &appConnSnapshot{
   185  		appConn: appConn,
   186  	}
   187  }
   188  
   189  func (app *appConnSnapshot) Error() error {
   190  	return app.appConn.Error()
   191  }
   192  
   193  func (app *appConnSnapshot) ListSnapshotsSync(req types.RequestListSnapshots) (*types.ResponseListSnapshots, error) {
   194  	return app.appConn.ListSnapshotsSync(req)
   195  }
   196  
   197  func (app *appConnSnapshot) OfferSnapshotSync(req types.RequestOfferSnapshot) (*types.ResponseOfferSnapshot, error) {
   198  	return app.appConn.OfferSnapshotSync(req)
   199  }
   200  
   201  func (app *appConnSnapshot) LoadSnapshotChunkSync(
   202  	req types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error) {
   203  	return app.appConn.LoadSnapshotChunkSync(req)
   204  }
   205  
   206  func (app *appConnSnapshot) ApplySnapshotChunkSync(
   207  	req types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error) {
   208  	return app.appConn.ApplySnapshotChunkSync(req)
   209  }