From 56e010ba6bee49bcbff03d96d00ae4c286ba8095 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 22 Dec 2021 08:25:05 -0800 Subject: [PATCH] docs: update go ws code snippets (#7486) (#7487) * doc: fix typos in /tx_search and /tx. * docs: update of go snippets for subscribe and unsubscribe operations Co-authored-by: Carlos Rodriguez (cherry picked from commit 2f5ad5f8ccc58da42cfd9fb1170d137e575847fc) Co-authored-by: Carlos Rodriguez --- rpc/openapi/openapi.yaml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/rpc/openapi/openapi.yaml b/rpc/openapi/openapi.yaml index ad3ccbb60..bcb5739dd 100644 --- a/rpc/openapi/openapi.yaml +++ b/rpc/openapi/openapi.yaml @@ -365,10 +365,14 @@ paths: import rpchttp "github.com/tendermint/rpc/client/http" import "github.com/tendermint/tendermint/types" - client := rpchttp.New("tcp://0.0.0.0:26657") - err := client.Start() + client, err := rpchttp.New("tcp://0.0.0.0:26657", "/websocket") if err != nil { - handle error + // handle error + } + + err = client.Start() + if err != nil { + // handle error } defer client.Stop() ctx, cancel := context.WithTimeout(context.Background(), 1 * time.Second) @@ -376,7 +380,7 @@ paths: query := "tm.event = 'Tx' AND tx.height = 3" txs, err := client.Subscribe(ctx, "test-client", query) if err != nil { - handle error + // handle error } go func() { @@ -422,16 +426,20 @@ paths: operationId: unsubscribe description: | ```go - client := rpchttp.New("tcp://0.0.0.0:26657") + client, err := rpchttp.New("tcp://0.0.0.0:26657", "/websocket") + if err != nil { + // handle error + } + err := client.Start() if err != nil { - handle error + // handle error } defer client.Stop() query := "tm.event = 'Tx' AND tx.height = 3" err = client.Unsubscribe(context.Background(), "test-client", query) if err != nil { - handle error + // handle error } ``` parameters: