mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-18 22:14:35 +00:00
rpc/client: take context as first param (#5347)
Closes #5145 also applies to light/client
This commit is contained in:
@@ -2,6 +2,7 @@ package client_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
@@ -31,7 +32,7 @@ func ExampleHTTP_simple() {
|
||||
|
||||
// Broadcast the transaction and wait for it to commit (rather use
|
||||
// c.BroadcastTxSync though in production).
|
||||
bres, err := c.BroadcastTxCommit(tx)
|
||||
bres, err := c.BroadcastTxCommit(context.Background(), tx)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -40,7 +41,7 @@ func ExampleHTTP_simple() {
|
||||
}
|
||||
|
||||
// Now try to fetch the value for the key
|
||||
qres, err := c.ABCIQuery("/key", k)
|
||||
qres, err := c.ABCIQuery(context.Background(), "/key", k)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -95,26 +96,26 @@ func ExampleHTTP_batching() {
|
||||
for _, tx := range txs {
|
||||
// Broadcast the transaction and wait for it to commit (rather use
|
||||
// c.BroadcastTxSync though in production).
|
||||
if _, err := batch.BroadcastTxCommit(tx); err != nil {
|
||||
if _, err := batch.BroadcastTxCommit(context.Background(), tx); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Send the batch of 2 transactions
|
||||
if _, err := batch.Send(); err != nil {
|
||||
if _, err := batch.Send(context.Background()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Now let's query for the original results as a batch
|
||||
keys := [][]byte{k1, k2}
|
||||
for _, key := range keys {
|
||||
if _, err := batch.ABCIQuery("/key", key); err != nil {
|
||||
if _, err := batch.ABCIQuery(context.Background(), "/key", key); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Send the 2 queries and keep the results
|
||||
results, err := batch.Send()
|
||||
results, err := batch.Send(context.Background())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user