github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/abci/client/local_client.go (about) 1 package abciclient 2 3 import ( 4 "context" 5 6 types "github.com/ari-anchor/sei-tendermint/abci/types" 7 "github.com/ari-anchor/sei-tendermint/libs/log" 8 "github.com/ari-anchor/sei-tendermint/libs/service" 9 ) 10 11 // NOTE: use defer to unlock mutex because Application might panic (e.g., in 12 // case of malicious tx or query). It only makes sense for publicly exposed 13 // methods like CheckTx (/broadcast_tx_* RPC endpoint) or Query (/abci_query 14 // RPC endpoint), but defers are used everywhere for the sake of consistency. 15 type localClient struct { 16 service.BaseService 17 types.Application 18 } 19 20 var _ Client = (*localClient)(nil) 21 22 // NewLocalClient creates a local client, which will be directly calling the 23 // methods of the given app. 24 // 25 // The client methods ignore their context argument. 26 func NewLocalClient(logger log.Logger, app types.Application) Client { 27 cli := &localClient{ 28 Application: app, 29 } 30 cli.BaseService = *service.NewBaseService(logger, "localClient", cli) 31 return cli 32 } 33 34 func (*localClient) OnStart(context.Context) error { return nil } 35 func (*localClient) OnStop() {} 36 func (*localClient) Error() error { return nil } 37 func (*localClient) Flush(context.Context) error { return nil } 38 func (*localClient) Echo(_ context.Context, msg string) (*types.ResponseEcho, error) { 39 return &types.ResponseEcho{Message: msg}, nil 40 }