mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 14:34:17 +00:00
Begin adding proof calls
This commit is contained in:
@@ -21,6 +21,7 @@ type Client interface {
|
||||
DeliverTxAsync(tx []byte) *ReqRes
|
||||
CheckTxAsync(tx []byte) *ReqRes
|
||||
QueryAsync(tx []byte) *ReqRes
|
||||
ProofAsync(tx []byte) *ReqRes
|
||||
CommitAsync() *ReqRes
|
||||
|
||||
FlushSync() error
|
||||
@@ -30,6 +31,7 @@ type Client interface {
|
||||
DeliverTxSync(tx []byte) (res types.Result)
|
||||
CheckTxSync(tx []byte) (res types.Result)
|
||||
QuerySync(tx []byte) (res types.Result)
|
||||
ProofSync(tx []byte) (res types.Result)
|
||||
CommitSync() (res types.Result)
|
||||
|
||||
InitChainAsync(validators []*types.Validator) *ReqRes
|
||||
|
||||
@@ -182,6 +182,15 @@ func (cli *grpcClient) QueryAsync(query []byte) *ReqRes {
|
||||
return cli.finishAsyncCall(req, &types.Response{&types.Response_Query{res}})
|
||||
}
|
||||
|
||||
func (cli *grpcClient) ProofAsync(key []byte) *ReqRes {
|
||||
req := types.ToRequestProof(key)
|
||||
res, err := cli.client.Proof(context.Background(), req.GetProof(), grpc.FailFast(true))
|
||||
if err != nil {
|
||||
cli.StopForError(err)
|
||||
}
|
||||
return cli.finishAsyncCall(req, &types.Response{&types.Response_Proof{res}})
|
||||
}
|
||||
|
||||
func (cli *grpcClient) CommitAsync() *ReqRes {
|
||||
req := types.ToRequestCommit()
|
||||
res, err := cli.client.Commit(context.Background(), req.GetCommit(), grpc.FailFast(true))
|
||||
@@ -301,6 +310,15 @@ func (cli *grpcClient) CheckTxSync(tx []byte) (res types.Result) {
|
||||
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
|
||||
}
|
||||
|
||||
func (cli *grpcClient) ProofSync(key []byte) (res types.Result) {
|
||||
reqres := cli.ProofAsync(key)
|
||||
if res := cli.checkErrGetResult(); res.IsErr() {
|
||||
return res
|
||||
}
|
||||
resp := reqres.Response.GetProof()
|
||||
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
|
||||
}
|
||||
|
||||
func (cli *grpcClient) QuerySync(query []byte) (res types.Result) {
|
||||
reqres := cli.QueryAsync(query)
|
||||
if res := cli.checkErrGetResult(); res.IsErr() {
|
||||
|
||||
@@ -99,6 +99,16 @@ func (app *localClient) QueryAsync(tx []byte) *ReqRes {
|
||||
)
|
||||
}
|
||||
|
||||
func (app *localClient) ProofAsync(key []byte) *ReqRes {
|
||||
app.mtx.Lock()
|
||||
res := app.Application.Proof(key)
|
||||
app.mtx.Unlock()
|
||||
return app.callback(
|
||||
types.ToRequestProof(key),
|
||||
types.ToResponseQuery(res.Code, res.Data, res.Log),
|
||||
)
|
||||
}
|
||||
|
||||
func (app *localClient) CommitAsync() *ReqRes {
|
||||
app.mtx.Lock()
|
||||
res := app.Application.Commit()
|
||||
@@ -192,6 +202,13 @@ func (app *localClient) QuerySync(query []byte) (res types.Result) {
|
||||
return res
|
||||
}
|
||||
|
||||
func (app *localClient) ProofSync(key []byte) (res types.Result) {
|
||||
app.mtx.Lock()
|
||||
res = app.Application.Proof(key)
|
||||
app.mtx.Unlock()
|
||||
return res
|
||||
}
|
||||
|
||||
func (app *localClient) CommitSync() (res types.Result) {
|
||||
app.mtx.Lock()
|
||||
res = app.Application.Commit()
|
||||
|
||||
@@ -255,6 +255,10 @@ func (cli *socketClient) QueryAsync(query []byte) *ReqRes {
|
||||
return cli.queueRequest(types.ToRequestQuery(query))
|
||||
}
|
||||
|
||||
func (cli *socketClient) ProofAsync(key []byte) *ReqRes {
|
||||
return cli.queueRequest(types.ToRequestProof(key))
|
||||
}
|
||||
|
||||
func (cli *socketClient) CommitAsync() *ReqRes {
|
||||
return cli.queueRequest(types.ToRequestCommit())
|
||||
}
|
||||
@@ -345,6 +349,15 @@ func (cli *socketClient) QuerySync(query []byte) (res types.Result) {
|
||||
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
|
||||
}
|
||||
|
||||
func (cli *socketClient) ProofSync(key []byte) (res types.Result) {
|
||||
reqres := cli.queueRequest(types.ToRequestProof(key))
|
||||
cli.FlushSync()
|
||||
if err := cli.Error(); err != nil {
|
||||
return types.ErrInternalError.SetLog(err.Error())
|
||||
}
|
||||
resp := reqres.Response.GetProof()
|
||||
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
|
||||
}
|
||||
func (cli *socketClient) CommitSync() (res types.Result) {
|
||||
reqres := cli.queueRequest(types.ToRequestCommit())
|
||||
cli.FlushSync()
|
||||
@@ -437,6 +450,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
|
||||
_, ok = res.Value.(*types.Response_Commit)
|
||||
case *types.Request_Query:
|
||||
_, ok = res.Value.(*types.Response_Query)
|
||||
case *types.Request_Proof:
|
||||
_, ok = res.Value.(*types.Response_Proof)
|
||||
case *types.Request_InitChain:
|
||||
_, ok = res.Value.(*types.Response_InitChain)
|
||||
case *types.Request_BeginBlock:
|
||||
|
||||
Reference in New Issue
Block a user