Browse Source

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.
wb/state-serialize
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
bb9fa171d6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1 additions and 72 deletions
  1. +0
    -1
      abci/client/client.go
  2. +0
    -9
      abci/client/grpc_client.go
  3. +0
    -5
      abci/client/local_client.go
  4. +0
    -23
      abci/client/mocks/client.go
  5. +0
    -4
      abci/client/socket_client.go
  6. +1
    -1
      internal/mempool/mempool.go
  7. +0
    -6
      internal/proxy/app_conn.go
  8. +0
    -23
      internal/proxy/mocks/app_conn_mempool.go

+ 0
- 1
abci/client/client.go View File

@ -31,7 +31,6 @@ type Client interface {
Error() error Error() error
// Asynchronous requests // Asynchronous requests
FlushAsync(context.Context) (*ReqRes, error)
CheckTxAsync(context.Context, types.RequestCheckTx) (*ReqRes, error) CheckTxAsync(context.Context, types.RequestCheckTx) (*ReqRes, error)
// Synchronous requests // Synchronous requests


+ 0
- 9
abci/client/grpc_client.go View File

@ -165,15 +165,6 @@ func (cli *grpcClient) Error() error {
//---------------------------------------- //----------------------------------------
// NOTE: call is synchronous, use ctx to break early if needed // 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 // NOTE: call is synchronous, use ctx to break early if needed
func (cli *grpcClient) CheckTxAsync(ctx context.Context, params types.RequestCheckTx) (*ReqRes, error) { func (cli *grpcClient) CheckTxAsync(ctx context.Context, params types.RequestCheckTx) (*ReqRes, error) {
req := types.ToRequestCheckTx(params) req := types.ToRequestCheckTx(params)


+ 0
- 5
abci/client/local_client.go View File

@ -42,11 +42,6 @@ func (app *localClient) Error() error {
return nil 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) { func (app *localClient) CheckTxAsync(ctx context.Context, req types.RequestCheckTx) (*ReqRes, error) {
app.mtx.Lock() app.mtx.Lock()
defer app.mtx.Unlock() defer app.mtx.Unlock()


+ 0
- 23
abci/client/mocks/client.go View File

@ -206,29 +206,6 @@ func (_m *Client) Flush(_a0 context.Context) error {
return r0 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 // Info provides a mock function with given fields: _a0, _a1
func (_m *Client) Info(_a0 context.Context, _a1 types.RequestInfo) (*types.ResponseInfo, error) { func (_m *Client) Info(_a0 context.Context, _a1 types.RequestInfo) (*types.ResponseInfo, error) {
ret := _m.Called(_a0, _a1) ret := _m.Called(_a0, _a1)


+ 0
- 4
abci/client/socket_client.go View File

@ -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) { func (cli *socketClient) CheckTxAsync(ctx context.Context, req types.RequestCheckTx) (*ReqRes, error) {
return cli.queueRequestAsync(ctx, types.ToRequestCheckTx(req)) return cli.queueRequestAsync(ctx, types.ToRequestCheckTx(req))
} }


+ 1
- 1
internal/mempool/mempool.go View File

@ -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) txmp.logger.Error("failed to flush transactions during rechecking", "err", err)
} }
} }


+ 0
- 6
internal/proxy/app_conn.go View File

@ -34,7 +34,6 @@ type AppConnMempool interface {
CheckTxAsync(context.Context, types.RequestCheckTx) (*abciclient.ReqRes, error) CheckTxAsync(context.Context, types.RequestCheckTx) (*abciclient.ReqRes, error)
CheckTx(context.Context, types.RequestCheckTx) (*types.ResponseCheckTx, error) CheckTx(context.Context, types.RequestCheckTx) (*types.ResponseCheckTx, error)
FlushAsync(context.Context) (*abciclient.ReqRes, error)
Flush(context.Context) error Flush(context.Context) error
} }
@ -148,11 +147,6 @@ func (app *appConnMempool) Error() error {
return app.appConn.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 { func (app *appConnMempool) Flush(ctx context.Context) error {
defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "sync"))() defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "sync"))()
return app.appConn.Flush(ctx) return app.appConn.Flush(ctx)


+ 0
- 23
internal/proxy/mocks/app_conn_mempool.go View File

@ -90,26 +90,3 @@ func (_m *AppConnMempool) Flush(_a0 context.Context) error {
return r0 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
}

Loading…
Cancel
Save