From bb9fa171d6cdeb7ccd78fee588347c3fae33f8ab Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Fri, 18 Feb 2022 12:42:23 -0500 Subject: [PATCH] abci/client: make flush operation sync (#7857) This follows along in the spirit of #7845 but is orthogonal to removing `CheckTxAsync` (which will come after the previous commit lands,) so I thought I'd get it out there earlier. --- abci/client/client.go | 1 - abci/client/grpc_client.go | 9 --------- abci/client/local_client.go | 5 ----- abci/client/mocks/client.go | 23 ----------------------- abci/client/socket_client.go | 4 ---- internal/mempool/mempool.go | 2 +- internal/proxy/app_conn.go | 6 ------ internal/proxy/mocks/app_conn_mempool.go | 23 ----------------------- 8 files changed, 1 insertion(+), 72 deletions(-) diff --git a/abci/client/client.go b/abci/client/client.go index b1d465ff8..dd19425c9 100644 --- a/abci/client/client.go +++ b/abci/client/client.go @@ -31,7 +31,6 @@ type Client interface { Error() error // Asynchronous requests - FlushAsync(context.Context) (*ReqRes, error) CheckTxAsync(context.Context, types.RequestCheckTx) (*ReqRes, error) // Synchronous requests diff --git a/abci/client/grpc_client.go b/abci/client/grpc_client.go index 4c6b966cc..ec9471fd8 100644 --- a/abci/client/grpc_client.go +++ b/abci/client/grpc_client.go @@ -165,15 +165,6 @@ func (cli *grpcClient) Error() error { //---------------------------------------- // NOTE: call is synchronous, use ctx to break early if needed -func (cli *grpcClient) FlushAsync(ctx context.Context) (*ReqRes, error) { - req := types.ToRequestFlush() - res, err := cli.client.Flush(ctx, req.GetFlush(), grpc.WaitForReady(true)) - if err != nil { - return nil, err - } - return cli.finishAsyncCall(ctx, req, &types.Response{Value: &types.Response_Flush{Flush: res}}) -} - // NOTE: call is synchronous, use ctx to break early if needed func (cli *grpcClient) CheckTxAsync(ctx context.Context, params types.RequestCheckTx) (*ReqRes, error) { req := types.ToRequestCheckTx(params) diff --git a/abci/client/local_client.go b/abci/client/local_client.go index bbc45b2eb..d4e8aecd7 100644 --- a/abci/client/local_client.go +++ b/abci/client/local_client.go @@ -42,11 +42,6 @@ func (app *localClient) Error() error { return nil } -func (app *localClient) FlushAsync(ctx context.Context) (*ReqRes, error) { - // Do nothing - return newLocalReqRes(types.ToRequestFlush(), nil), nil -} - func (app *localClient) CheckTxAsync(ctx context.Context, req types.RequestCheckTx) (*ReqRes, error) { app.mtx.Lock() defer app.mtx.Unlock() diff --git a/abci/client/mocks/client.go b/abci/client/mocks/client.go index ce777a07a..429ae404b 100644 --- a/abci/client/mocks/client.go +++ b/abci/client/mocks/client.go @@ -206,29 +206,6 @@ func (_m *Client) Flush(_a0 context.Context) error { return r0 } -// FlushAsync provides a mock function with given fields: _a0 -func (_m *Client) FlushAsync(_a0 context.Context) (*abciclient.ReqRes, error) { - ret := _m.Called(_a0) - - var r0 *abciclient.ReqRes - if rf, ok := ret.Get(0).(func(context.Context) *abciclient.ReqRes); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*abciclient.ReqRes) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // Info provides a mock function with given fields: _a0, _a1 func (_m *Client) Info(_a0 context.Context, _a1 types.RequestInfo) (*types.ResponseInfo, error) { ret := _m.Called(_a0, _a1) diff --git a/abci/client/socket_client.go b/abci/client/socket_client.go index 1b3741aef..8b199e4d9 100644 --- a/abci/client/socket_client.go +++ b/abci/client/socket_client.go @@ -206,10 +206,6 @@ func (cli *socketClient) didRecvResponse(res *types.Response) error { //---------------------------------------- -func (cli *socketClient) FlushAsync(ctx context.Context) (*ReqRes, error) { - return cli.queueRequestAsync(ctx, types.ToRequestFlush()) -} - func (cli *socketClient) CheckTxAsync(ctx context.Context, req types.RequestCheckTx) (*ReqRes, error) { return cli.queueRequestAsync(ctx, types.ToRequestCheckTx(req)) } diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index c4233ba1d..f60ead160 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -730,7 +730,7 @@ func (txmp *TxMempool) updateReCheckTxs(ctx context.Context) { } } - if _, err := txmp.proxyAppConn.FlushAsync(ctx); err != nil { + if err := txmp.proxyAppConn.Flush(ctx); err != nil { txmp.logger.Error("failed to flush transactions during rechecking", "err", err) } } diff --git a/internal/proxy/app_conn.go b/internal/proxy/app_conn.go index 0b94aa3f4..bc67f554a 100644 --- a/internal/proxy/app_conn.go +++ b/internal/proxy/app_conn.go @@ -34,7 +34,6 @@ type AppConnMempool interface { CheckTxAsync(context.Context, types.RequestCheckTx) (*abciclient.ReqRes, error) CheckTx(context.Context, types.RequestCheckTx) (*types.ResponseCheckTx, error) - FlushAsync(context.Context) (*abciclient.ReqRes, error) Flush(context.Context) error } @@ -148,11 +147,6 @@ func (app *appConnMempool) Error() error { return app.appConn.Error() } -func (app *appConnMempool) FlushAsync(ctx context.Context) (*abciclient.ReqRes, error) { - defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "async"))() - return app.appConn.FlushAsync(ctx) -} - func (app *appConnMempool) Flush(ctx context.Context) error { defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "sync"))() return app.appConn.Flush(ctx) diff --git a/internal/proxy/mocks/app_conn_mempool.go b/internal/proxy/mocks/app_conn_mempool.go index 3bb4ceb2c..de2f9d60c 100644 --- a/internal/proxy/mocks/app_conn_mempool.go +++ b/internal/proxy/mocks/app_conn_mempool.go @@ -90,26 +90,3 @@ func (_m *AppConnMempool) Flush(_a0 context.Context) error { return r0 } - -// FlushAsync provides a mock function with given fields: _a0 -func (_m *AppConnMempool) FlushAsync(_a0 context.Context) (*abciclient.ReqRes, error) { - ret := _m.Called(_a0) - - var r0 *abciclient.ReqRes - if rf, ok := ret.Get(0).(func(context.Context) *abciclient.ReqRes); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*abciclient.ReqRes) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -}