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