parent
95317d2fd6
commit
5ce15cb963
|
@ -1,6 +1,7 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
@ -90,7 +91,7 @@ func (ctx Context) BroadcastTxCommit(txBytes []byte) (*sdk.TxResponse, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res, err := node.BroadcastTxCommit(txBytes)
|
||||
res, err := node.BroadcastTxCommit(context.Background(), txBytes)
|
||||
if err != nil {
|
||||
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
|
||||
return errRes, nil
|
||||
|
@ -118,7 +119,7 @@ func (ctx Context) BroadcastTxSync(txBytes []byte) (*sdk.TxResponse, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res, err := node.BroadcastTxSync(txBytes)
|
||||
res, err := node.BroadcastTxSync(context.Background(), txBytes)
|
||||
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
|
||||
return errRes, nil
|
||||
}
|
||||
|
@ -134,7 +135,7 @@ func (ctx Context) BroadcastTxAsync(txBytes []byte) (*sdk.TxResponse, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res, err := node.BroadcastTxAsync(txBytes)
|
||||
res, err := node.BroadcastTxAsync(context.Background(), txBytes)
|
||||
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
|
||||
return errRes, nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
|
@ -20,15 +21,15 @@ type MockClient struct {
|
|||
err error
|
||||
}
|
||||
|
||||
func (c MockClient) BroadcastTxCommit(tx tmtypes.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func (c MockClient) BroadcastTxCommit(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
return nil, c.err
|
||||
}
|
||||
|
||||
func (c MockClient) BroadcastTxAsync(tx tmtypes.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (c MockClient) BroadcastTxAsync(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
return nil, c.err
|
||||
}
|
||||
|
||||
func (c MockClient) BroadcastTxSync(tx tmtypes.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (c MockClient) BroadcastTxSync(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
return nil, c.err
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
|
@ -85,7 +86,7 @@ func (ctx Context) queryABCI(req abci.RequestQuery) (abci.ResponseQuery, error)
|
|||
Prove: req.Prove,
|
||||
}
|
||||
|
||||
result, err := node.ABCIQueryWithOptions(req.Path, req.Data, opts)
|
||||
result, err := node.ABCIQueryWithOptions(context.Background(), req.Path, req.Data, opts)
|
||||
if err != nil {
|
||||
return abci.ResponseQuery{}, err
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -62,7 +63,7 @@ func getBlock(clientCtx client.Context, height *int64) ([]byte, error) {
|
|||
// header -> BlockchainInfo
|
||||
// header, tx -> Block
|
||||
// results -> BlockResults
|
||||
res, err := node.Block(height)
|
||||
res, err := node.Block(context.Background(), height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ func GetChainHeight(clientCtx client.Context) (int64, error) {
|
|||
return -1, err
|
||||
}
|
||||
|
||||
status, err := node.Status()
|
||||
status, err := node.Status(context.Background())
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
@ -51,7 +52,7 @@ func getNodeStatus(clientCtx client.Context) (*ctypes.ResultStatus, error) {
|
|||
return &ctypes.ResultStatus{}, err
|
||||
}
|
||||
|
||||
return node.Status()
|
||||
return node.Status(context.Background())
|
||||
}
|
||||
|
||||
// NodeInfoResponse defines a response type that contains node status and version
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -119,7 +120,7 @@ func GetValidators(clientCtx client.Context, height *int64, page, limit *int) (R
|
|||
return ResultValidatorsOutput{}, err
|
||||
}
|
||||
|
||||
validatorsRes, err := node.Validators(height, page, limit)
|
||||
validatorsRes, err := node.Validators(context.Background(), height, page, limit)
|
||||
if err != nil {
|
||||
return ResultValidatorsOutput{}, err
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -40,7 +40,7 @@ require (
|
|||
github.com/tendermint/btcd v0.1.1
|
||||
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
|
||||
github.com/tendermint/go-amino v0.16.0
|
||||
github.com/tendermint/tendermint v0.34.0-rc3.0.20200922082254-ed002cea7e4a
|
||||
github.com/tendermint/tendermint v0.34.0-rc3.0.20200923104252-a2bbc2984bcc
|
||||
github.com/tendermint/tm-db v0.6.2
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987
|
||||
|
|
2
go.sum
2
go.sum
|
@ -589,6 +589,8 @@ github.com/tendermint/tendermint v0.34.0-rc3 h1:d7Fsd5rdbxq4GmJ0kRfx7l7LesQM7e70
|
|||
github.com/tendermint/tendermint v0.34.0-rc3/go.mod h1:BoHcEpjfpBHc1Be7RQz3AHaXFNObcDG7SNHCev6Or4g=
|
||||
github.com/tendermint/tendermint v0.34.0-rc3.0.20200922082254-ed002cea7e4a h1:5dw+rRXNj23q8eW++U5uXE8t/K5mLWK8EobqR3wDD0s=
|
||||
github.com/tendermint/tendermint v0.34.0-rc3.0.20200922082254-ed002cea7e4a/go.mod h1:yotsojf2C1QBOw4dZrTcxbyxmPUrT4hNuOQWX9XUwB4=
|
||||
github.com/tendermint/tendermint v0.34.0-rc3.0.20200923104252-a2bbc2984bcc h1:3XcxG8ey0/+lHnyxt/qRkZtGkpWirzYDd67z3W4aS2s=
|
||||
github.com/tendermint/tendermint v0.34.0-rc3.0.20200923104252-a2bbc2984bcc/go.mod h1:yotsojf2C1QBOw4dZrTcxbyxmPUrT4hNuOQWX9XUwB4=
|
||||
github.com/tendermint/tm-db v0.6.1 h1:w3X87itMPXopcRPlFiqspEKhw4FXihPk2rnFFkP0zGk=
|
||||
github.com/tendermint/tm-db v0.6.1/go.mod h1:m3x9kRP4UFd7JODJL0yBAZqE7wTw+S37uAE90cTx7OA=
|
||||
github.com/tendermint/tm-db v0.6.2 h1:DOn8jwCdjJblrCFJbtonEIPD1IuJWpbRUUdR8GWE4RM=
|
||||
|
|
|
@ -2,6 +2,7 @@ package network
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -374,7 +375,7 @@ func (n *Network) LatestHeight() (int64, error) {
|
|||
return 0, errors.New("no validators available")
|
||||
}
|
||||
|
||||
status, err := n.Validators[0].RPCClient.Status()
|
||||
status, err := n.Validators[0].RPCClient.Status(context.Background())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
@ -408,7 +409,7 @@ func (n *Network) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, err
|
|||
ticker.Stop()
|
||||
return latestHeight, errors.New("timeout exceeded waiting for block")
|
||||
case <-ticker.C:
|
||||
status, err := val.RPCClient.Status()
|
||||
status, err := val.RPCClient.Status(context.Background())
|
||||
if err == nil && status != nil {
|
||||
latestHeight = status.SyncInfo.LatestBlockHeight
|
||||
if latestHeight >= h {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -43,7 +44,7 @@ func QueryTxsByEvents(clientCtx client.Context, events []string, page, limit int
|
|||
|
||||
// TODO: this may not always need to be proven
|
||||
// https://github.com/cosmos/cosmos-sdk/issues/6807
|
||||
resTxs, err := node.TxSearch(query, true, &page, &limit, orderBy)
|
||||
resTxs, err := node.TxSearch(context.Background(), query, true, &page, &limit, orderBy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ func QueryTx(clientCtx client.Context, hashHexStr string) (*sdk.TxResponse, erro
|
|||
|
||||
//TODO: this may not always need to be proven
|
||||
// https://github.com/cosmos/cosmos-sdk/issues/6807
|
||||
resTx, err := node.Tx(hash, true)
|
||||
resTx, err := node.Tx(context.Background(), hash, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ func getBlocksForTxResults(clientCtx client.Context, resTxs []*ctypes.ResultTx)
|
|||
|
||||
for _, resTx := range resTxs {
|
||||
if _, ok := resBlocks[resTx.Height]; !ok {
|
||||
resBlock, err := node.Block(&resTx.Height)
|
||||
resBlock, err := node.Block(context.Background(), &resTx.Height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
@ -13,7 +14,7 @@ import (
|
|||
// QueryGenesisTxs writes the genesis transactions to the response if no error
|
||||
// occurs.
|
||||
func QueryGenesisTxs(clientCtx client.Context, w http.ResponseWriter) {
|
||||
resultGenesis, err := clientCtx.Client.Genesis()
|
||||
resultGenesis, err := clientCtx.Client.Genesis(context.Background())
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(
|
||||
w, http.StatusInternalServerError,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package utils_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
|
@ -23,7 +24,7 @@ type TxSearchMock struct {
|
|||
txs []tmtypes.Tx
|
||||
}
|
||||
|
||||
func (mock TxSearchMock) TxSearch(query string, prove bool, page, perPage *int, orderBy string) (*ctypes.ResultTxSearch, error) {
|
||||
func (mock TxSearchMock) TxSearch(ctx context.Context, query string, prove bool, page, perPage *int, orderBy string) (*ctypes.ResultTxSearch, error) {
|
||||
if page == nil {
|
||||
*page = 0
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ func (mock TxSearchMock) TxSearch(query string, prove bool, page, perPage *int,
|
|||
return rst, nil
|
||||
}
|
||||
|
||||
func (mock TxSearchMock) Block(height *int64) (*ctypes.ResultBlock, error) {
|
||||
func (mock TxSearchMock) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) {
|
||||
// any non nil Block needs to be returned. used to get time value
|
||||
return &ctypes.ResultBlock{Block: &tmtypes.Block{}}, nil
|
||||
}
|
||||
|
|
|
@ -126,14 +126,14 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctmtypes.Header, int64,
|
|||
return ibctmtypes.Header{}, 0, err
|
||||
}
|
||||
|
||||
info, err := node.ABCIInfo()
|
||||
info, err := node.ABCIInfo(context.Background())
|
||||
if err != nil {
|
||||
return ibctmtypes.Header{}, 0, err
|
||||
}
|
||||
|
||||
height := info.Response.LastBlockHeight
|
||||
|
||||
commit, err := node.Commit(&height)
|
||||
commit, err := node.Commit(context.Background(), &height)
|
||||
if err != nil {
|
||||
return ibctmtypes.Header{}, 0, err
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctmtypes.Header, int64,
|
|||
page := 0
|
||||
count := 10_000
|
||||
|
||||
validators, err := node.Validators(&height, &page, &count)
|
||||
validators, err := node.Validators(context.Background(), &height, &page, &count)
|
||||
if err != nil {
|
||||
return ibctmtypes.Header{}, 0, err
|
||||
}
|
||||
|
@ -168,14 +168,14 @@ func QueryNodeConsensusState(clientCtx client.Context) (*ibctmtypes.ConsensusSta
|
|||
return &ibctmtypes.ConsensusState{}, 0, err
|
||||
}
|
||||
|
||||
info, err := node.ABCIInfo()
|
||||
info, err := node.ABCIInfo(context.Background())
|
||||
if err != nil {
|
||||
return &ibctmtypes.ConsensusState{}, 0, err
|
||||
}
|
||||
|
||||
height := info.Response.LastBlockHeight
|
||||
|
||||
commit, err := node.Commit(&height)
|
||||
commit, err := node.Commit(context.Background(), &height)
|
||||
if err != nil {
|
||||
return &ibctmtypes.ConsensusState{}, 0, err
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func QueryNodeConsensusState(clientCtx client.Context) (*ibctmtypes.ConsensusSta
|
|||
count := 10_000
|
||||
|
||||
nextHeight := height + 1
|
||||
nextVals, err := node.Validators(&nextHeight, &page, &count)
|
||||
nextVals, err := node.Validators(context.Background(), &nextHeight, &page, &count)
|
||||
if err != nil {
|
||||
return &ibctmtypes.ConsensusState{}, 0, err
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ func GetAppliedPlanCmd() *cobra.Command {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
headers, err := node.BlockchainInfo(res.Height, res.Height)
|
||||
headers, err := node.BlockchainInfo(context.Background(), res.Height, res.Height)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue