cleanup: Reduce and normalize import path aliasing. (#6975)

The code in the Tendermint repository makes heavy use of import aliasing.
This is made necessary by our extensive reuse of common base package names, and
by repetition of similar names across different subdirectories.

Unfortunately we have not been very consistent about which packages we alias in
various circumstances, and the aliases we use vary. In the spirit of the advice
in the style guide and https://github.com/golang/go/wiki/CodeReviewComments#imports,
his change makes an effort to clean up and normalize import aliasing.

This change makes no API or behavioral changes. It is a pure cleanup intended
o help make the code more readable to developers (including myself) trying to
understand what is being imported where.

Only unexported names have been modified, and the changes were generated and
applied mechanically with gofmt -r and comby, respecting the lexical and
syntactic rules of Go.  Even so, I did not fix every inconsistency. Where the
changes would be too disruptive, I left it alone.

The principles I followed in this cleanup are:

- Remove aliases that restate the package name.
- Remove aliases where the base package name is unambiguous.
- Move overly-terse abbreviations from the import to the usage site.
- Fix lexical issues (remove underscores, remove capitalization).
- Fix import groupings to more closely match the style guide.
- Group blank (side-effecting) imports and ensure they are commented.
- Add aliases to multiple imports with the same base package name.
This commit is contained in:
M. J. Fromberger
2021-09-23 07:52:07 -07:00
committed by GitHub
parent c9beef796d
commit cf7537ea5f
127 changed files with 1473 additions and 1473 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/types"
)
@@ -127,7 +127,7 @@ func testTxEventsSent(t *testing.T, broadcastMethod string) {
// send
go func() {
var (
txres *ctypes.ResultBroadcastTx
txres *coretypes.ResultBroadcastTx
err error
ctx = context.Background()
)
+2 -2
View File
@@ -11,7 +11,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/crypto/tmhash"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/privval"
@@ -150,7 +150,7 @@ func TestBroadcastEvidence_DuplicateVoteEvidence(t *testing.T) {
err = abci.ReadMessage(bytes.NewReader(qres.Value), &v)
require.NoError(t, err, "Error reading query result, value %v", qres.Value)
pk, err := cryptoenc.PubKeyFromProto(v.PubKey)
pk, err := encoding.PubKeyFromProto(v.PubKey)
require.NoError(t, err)
require.EqualValues(t, rawpub, pk, "Stored PubKey not equal with expected, value %v", string(qres.Value))
+2 -2
View File
@@ -8,7 +8,7 @@ import (
"github.com/tendermint/tendermint/abci/example/kvstore"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
rpctest "github.com/tendermint/tendermint/rpc/test"
)
@@ -138,7 +138,7 @@ func ExampleHTTP_batching() {
// Each result in the returned list is the deserialized result of each
// respective ABCIQuery response
for _, result := range results {
qr, ok := result.(*ctypes.ResultABCIQuery)
qr, ok := result.(*coretypes.ResultABCIQuery)
if !ok {
log.Fatal("invalid result type from ABCIQuery request")
}
+5 -5
View File
@@ -10,7 +10,7 @@ import (
"github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/mock"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
)
func TestWaitForHeight(t *testing.T) {
@@ -33,7 +33,7 @@ func TestWaitForHeight(t *testing.T) {
// now set current block height to 10
m.Call = mock.Call{
Response: &ctypes.ResultStatus{SyncInfo: ctypes.SyncInfo{LatestBlockHeight: 10}},
Response: &coretypes.ResultStatus{SyncInfo: coretypes.SyncInfo{LatestBlockHeight: 10}},
}
// we will not wait for more than 10 blocks
@@ -53,7 +53,7 @@ func TestWaitForHeight(t *testing.T) {
// we use the callback to update the status height
myWaiter := func(delta int64) error {
// update the height for the next call
m.Call.Response = &ctypes.ResultStatus{SyncInfo: ctypes.SyncInfo{LatestBlockHeight: 15}}
m.Call.Response = &coretypes.ResultStatus{SyncInfo: coretypes.SyncInfo{LatestBlockHeight: 15}}
return client.DefaultWaitStrategy(delta)
}
@@ -65,13 +65,13 @@ func TestWaitForHeight(t *testing.T) {
pre := r.Calls[3]
require.Nil(pre.Error)
prer, ok := pre.Response.(*ctypes.ResultStatus)
prer, ok := pre.Response.(*coretypes.ResultStatus)
require.True(ok)
assert.Equal(int64(10), prer.SyncInfo.LatestBlockHeight)
post := r.Calls[4]
require.Nil(post.Error)
postr, ok := post.Response.(*ctypes.ResultStatus)
postr, ok := post.Response.(*coretypes.ResultStatus)
require.True(ok)
assert.Equal(int64(15), postr.SyncInfo.LatestBlockHeight)
}
+54 -54
View File
@@ -7,7 +7,7 @@ import (
"github.com/tendermint/tendermint/libs/bytes"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
jsonrpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
"github.com/tendermint/tendermint/types"
)
@@ -198,8 +198,8 @@ func (b *BatchHTTP) Count() int {
//-----------------------------------------------------------------------------
// baseRPCClient
func (c *baseRPCClient) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
result := new(ctypes.ResultStatus)
func (c *baseRPCClient) Status(ctx context.Context) (*coretypes.ResultStatus, error) {
result := new(coretypes.ResultStatus)
_, err := c.caller.Call(ctx, "status", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -208,8 +208,8 @@ func (c *baseRPCClient) Status(ctx context.Context) (*ctypes.ResultStatus, error
return result, nil
}
func (c *baseRPCClient) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
result := new(ctypes.ResultABCIInfo)
func (c *baseRPCClient) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {
result := new(coretypes.ResultABCIInfo)
_, err := c.caller.Call(ctx, "abci_info", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -222,7 +222,7 @@ func (c *baseRPCClient) ABCIQuery(
ctx context.Context,
path string,
data bytes.HexBytes,
) (*ctypes.ResultABCIQuery, error) {
) (*coretypes.ResultABCIQuery, error) {
return c.ABCIQueryWithOptions(ctx, path, data, rpcclient.DefaultABCIQueryOptions)
}
@@ -230,8 +230,8 @@ func (c *baseRPCClient) ABCIQueryWithOptions(
ctx context.Context,
path string,
data bytes.HexBytes,
opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
result := new(ctypes.ResultABCIQuery)
opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
result := new(coretypes.ResultABCIQuery)
_, err := c.caller.Call(ctx, "abci_query",
map[string]interface{}{"path": path, "data": data, "height": opts.Height, "prove": opts.Prove},
result)
@@ -245,8 +245,8 @@ func (c *baseRPCClient) ABCIQueryWithOptions(
func (c *baseRPCClient) BroadcastTxCommit(
ctx context.Context,
tx types.Tx,
) (*ctypes.ResultBroadcastTxCommit, error) {
result := new(ctypes.ResultBroadcastTxCommit)
) (*coretypes.ResultBroadcastTxCommit, error) {
result := new(coretypes.ResultBroadcastTxCommit)
_, err := c.caller.Call(ctx, "broadcast_tx_commit", map[string]interface{}{"tx": tx}, result)
if err != nil {
return nil, err
@@ -257,14 +257,14 @@ func (c *baseRPCClient) BroadcastTxCommit(
func (c *baseRPCClient) BroadcastTxAsync(
ctx context.Context,
tx types.Tx,
) (*ctypes.ResultBroadcastTx, error) {
) (*coretypes.ResultBroadcastTx, error) {
return c.broadcastTX(ctx, "broadcast_tx_async", tx)
}
func (c *baseRPCClient) BroadcastTxSync(
ctx context.Context,
tx types.Tx,
) (*ctypes.ResultBroadcastTx, error) {
) (*coretypes.ResultBroadcastTx, error) {
return c.broadcastTX(ctx, "broadcast_tx_sync", tx)
}
@@ -272,8 +272,8 @@ func (c *baseRPCClient) broadcastTX(
ctx context.Context,
route string,
tx types.Tx,
) (*ctypes.ResultBroadcastTx, error) {
result := new(ctypes.ResultBroadcastTx)
) (*coretypes.ResultBroadcastTx, error) {
result := new(coretypes.ResultBroadcastTx)
_, err := c.caller.Call(ctx, route, map[string]interface{}{"tx": tx}, result)
if err != nil {
return nil, err
@@ -284,8 +284,8 @@ func (c *baseRPCClient) broadcastTX(
func (c *baseRPCClient) UnconfirmedTxs(
ctx context.Context,
limit *int,
) (*ctypes.ResultUnconfirmedTxs, error) {
result := new(ctypes.ResultUnconfirmedTxs)
) (*coretypes.ResultUnconfirmedTxs, error) {
result := new(coretypes.ResultUnconfirmedTxs)
params := make(map[string]interface{})
if limit != nil {
params["limit"] = limit
@@ -297,8 +297,8 @@ func (c *baseRPCClient) UnconfirmedTxs(
return result, nil
}
func (c *baseRPCClient) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirmedTxs, error) {
result := new(ctypes.ResultUnconfirmedTxs)
func (c *baseRPCClient) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error) {
result := new(coretypes.ResultUnconfirmedTxs)
_, err := c.caller.Call(ctx, "num_unconfirmed_txs", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -306,8 +306,8 @@ func (c *baseRPCClient) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUn
return result, nil
}
func (c *baseRPCClient) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
result := new(ctypes.ResultCheckTx)
func (c *baseRPCClient) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error) {
result := new(coretypes.ResultCheckTx)
_, err := c.caller.Call(ctx, "check_tx", map[string]interface{}{"tx": tx}, result)
if err != nil {
return nil, err
@@ -315,8 +315,8 @@ func (c *baseRPCClient) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.Resul
return result, nil
}
func (c *baseRPCClient) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error) {
result := new(ctypes.ResultNetInfo)
func (c *baseRPCClient) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error) {
result := new(coretypes.ResultNetInfo)
_, err := c.caller.Call(ctx, "net_info", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -324,8 +324,8 @@ func (c *baseRPCClient) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, err
return result, nil
}
func (c *baseRPCClient) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error) {
result := new(ctypes.ResultDumpConsensusState)
func (c *baseRPCClient) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error) {
result := new(coretypes.ResultDumpConsensusState)
_, err := c.caller.Call(ctx, "dump_consensus_state", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -333,8 +333,8 @@ func (c *baseRPCClient) DumpConsensusState(ctx context.Context) (*ctypes.ResultD
return result, nil
}
func (c *baseRPCClient) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error) {
result := new(ctypes.ResultConsensusState)
func (c *baseRPCClient) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error) {
result := new(coretypes.ResultConsensusState)
_, err := c.caller.Call(ctx, "consensus_state", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -345,8 +345,8 @@ func (c *baseRPCClient) ConsensusState(ctx context.Context) (*ctypes.ResultConse
func (c *baseRPCClient) ConsensusParams(
ctx context.Context,
height *int64,
) (*ctypes.ResultConsensusParams, error) {
result := new(ctypes.ResultConsensusParams)
) (*coretypes.ResultConsensusParams, error) {
result := new(coretypes.ResultConsensusParams)
params := make(map[string]interface{})
if height != nil {
params["height"] = height
@@ -358,8 +358,8 @@ func (c *baseRPCClient) ConsensusParams(
return result, nil
}
func (c *baseRPCClient) Health(ctx context.Context) (*ctypes.ResultHealth, error) {
result := new(ctypes.ResultHealth)
func (c *baseRPCClient) Health(ctx context.Context) (*coretypes.ResultHealth, error) {
result := new(coretypes.ResultHealth)
_, err := c.caller.Call(ctx, "health", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -371,8 +371,8 @@ func (c *baseRPCClient) BlockchainInfo(
ctx context.Context,
minHeight,
maxHeight int64,
) (*ctypes.ResultBlockchainInfo, error) {
result := new(ctypes.ResultBlockchainInfo)
) (*coretypes.ResultBlockchainInfo, error) {
result := new(coretypes.ResultBlockchainInfo)
_, err := c.caller.Call(ctx, "blockchain",
map[string]interface{}{"minHeight": minHeight, "maxHeight": maxHeight},
result)
@@ -382,8 +382,8 @@ func (c *baseRPCClient) BlockchainInfo(
return result, nil
}
func (c *baseRPCClient) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error) {
result := new(ctypes.ResultGenesis)
func (c *baseRPCClient) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error) {
result := new(coretypes.ResultGenesis)
_, err := c.caller.Call(ctx, "genesis", map[string]interface{}{}, result)
if err != nil {
return nil, err
@@ -391,8 +391,8 @@ func (c *baseRPCClient) Genesis(ctx context.Context) (*ctypes.ResultGenesis, err
return result, nil
}
func (c *baseRPCClient) GenesisChunked(ctx context.Context, id uint) (*ctypes.ResultGenesisChunk, error) {
result := new(ctypes.ResultGenesisChunk)
func (c *baseRPCClient) GenesisChunked(ctx context.Context, id uint) (*coretypes.ResultGenesisChunk, error) {
result := new(coretypes.ResultGenesisChunk)
_, err := c.caller.Call(ctx, "genesis_chunked", map[string]interface{}{"chunk": id}, result)
if err != nil {
return nil, err
@@ -400,8 +400,8 @@ func (c *baseRPCClient) GenesisChunked(ctx context.Context, id uint) (*ctypes.Re
return result, nil
}
func (c *baseRPCClient) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) {
result := new(ctypes.ResultBlock)
func (c *baseRPCClient) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) {
result := new(coretypes.ResultBlock)
params := make(map[string]interface{})
if height != nil {
params["height"] = height
@@ -413,8 +413,8 @@ func (c *baseRPCClient) Block(ctx context.Context, height *int64) (*ctypes.Resul
return result, nil
}
func (c *baseRPCClient) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*ctypes.ResultBlock, error) {
result := new(ctypes.ResultBlock)
func (c *baseRPCClient) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error) {
result := new(coretypes.ResultBlock)
params := map[string]interface{}{
"hash": hash,
}
@@ -428,8 +428,8 @@ func (c *baseRPCClient) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*
func (c *baseRPCClient) BlockResults(
ctx context.Context,
height *int64,
) (*ctypes.ResultBlockResults, error) {
result := new(ctypes.ResultBlockResults)
) (*coretypes.ResultBlockResults, error) {
result := new(coretypes.ResultBlockResults)
params := make(map[string]interface{})
if height != nil {
params["height"] = height
@@ -441,8 +441,8 @@ func (c *baseRPCClient) BlockResults(
return result, nil
}
func (c *baseRPCClient) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error) {
result := new(ctypes.ResultCommit)
func (c *baseRPCClient) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) {
result := new(coretypes.ResultCommit)
params := make(map[string]interface{})
if height != nil {
params["height"] = height
@@ -454,8 +454,8 @@ func (c *baseRPCClient) Commit(ctx context.Context, height *int64) (*ctypes.Resu
return result, nil
}
func (c *baseRPCClient) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*ctypes.ResultTx, error) {
result := new(ctypes.ResultTx)
func (c *baseRPCClient) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error) {
result := new(coretypes.ResultTx)
params := map[string]interface{}{
"hash": hash,
"prove": prove,
@@ -474,9 +474,9 @@ func (c *baseRPCClient) TxSearch(
page,
perPage *int,
orderBy string,
) (*ctypes.ResultTxSearch, error) {
) (*coretypes.ResultTxSearch, error) {
result := new(ctypes.ResultTxSearch)
result := new(coretypes.ResultTxSearch)
params := map[string]interface{}{
"query": query,
"prove": prove,
@@ -503,9 +503,9 @@ func (c *baseRPCClient) BlockSearch(
query string,
page, perPage *int,
orderBy string,
) (*ctypes.ResultBlockSearch, error) {
) (*coretypes.ResultBlockSearch, error) {
result := new(ctypes.ResultBlockSearch)
result := new(coretypes.ResultBlockSearch)
params := map[string]interface{}{
"query": query,
"order_by": orderBy,
@@ -531,8 +531,8 @@ func (c *baseRPCClient) Validators(
height *int64,
page,
perPage *int,
) (*ctypes.ResultValidators, error) {
result := new(ctypes.ResultValidators)
) (*coretypes.ResultValidators, error) {
result := new(coretypes.ResultValidators)
params := make(map[string]interface{})
if page != nil {
params["page"] = page
@@ -553,8 +553,8 @@ func (c *baseRPCClient) Validators(
func (c *baseRPCClient) BroadcastEvidence(
ctx context.Context,
ev types.Evidence,
) (*ctypes.ResultBroadcastEvidence, error) {
result := new(ctypes.ResultBroadcastEvidence)
) (*coretypes.ResultBroadcastEvidence, error) {
result := new(coretypes.ResultBroadcastEvidence)
_, err := c.caller.Call(ctx, "broadcast_evidence", map[string]interface{}{"evidence": ev}, result)
if err != nil {
return nil, err
+7 -7
View File
@@ -9,9 +9,9 @@ import (
tmsync "github.com/tendermint/tendermint/internal/libs/sync"
tmjson "github.com/tendermint/tendermint/libs/json"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
"github.com/tendermint/tendermint/libs/pubsub"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
jsonrpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
)
@@ -53,7 +53,7 @@ type wsEvents struct {
}
type wsSubscription struct {
res chan ctypes.ResultEvent
res chan coretypes.ResultEvent
id string
query string
}
@@ -119,7 +119,7 @@ func (w *wsEvents) Stop() error { return w.ws.Stop() }
//
// It returns an error if wsEvents is not running.
func (w *wsEvents) Subscribe(ctx context.Context, subscriber, query string,
outCapacity ...int) (out <-chan ctypes.ResultEvent, err error) {
outCapacity ...int) (out <-chan coretypes.ResultEvent, err error) {
if !w.IsRunning() {
return nil, rpcclient.ErrClientNotRunning
@@ -134,7 +134,7 @@ func (w *wsEvents) Subscribe(ctx context.Context, subscriber, query string,
outCap = outCapacity[0]
}
outc := make(chan ctypes.ResultEvent, outCap)
outc := make(chan coretypes.ResultEvent, outCap)
w.mtx.Lock()
defer w.mtx.Unlock()
// subscriber param is ignored because Tendermint will override it with
@@ -213,7 +213,7 @@ func (w *wsEvents) redoSubscriptionsAfter(d time.Duration) {
}
func isErrAlreadySubscribed(err error) bool {
return strings.Contains(err.Error(), tmpubsub.ErrAlreadySubscribed.Error())
return strings.Contains(err.Error(), pubsub.ErrAlreadySubscribed.Error())
}
func (w *wsEvents) eventListener() {
@@ -238,7 +238,7 @@ func (w *wsEvents) eventListener() {
continue
}
result := new(ctypes.ResultEvent)
result := new(coretypes.ResultEvent)
err := tmjson.Unmarshal(resp.Result, result)
if err != nil {
w.Logger.Error("failed to unmarshal response", "err", err)
+29 -29
View File
@@ -24,7 +24,7 @@ import (
"context"
"github.com/tendermint/tendermint/libs/bytes"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/types"
)
@@ -61,26 +61,26 @@ type Client interface {
// is easier to mock.
type ABCIClient interface {
// Reading from abci app
ABCIInfo(context.Context) (*ctypes.ResultABCIInfo, error)
ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)
ABCIInfo(context.Context) (*coretypes.ResultABCIInfo, error)
ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error)
ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes,
opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
opts ABCIQueryOptions) (*coretypes.ResultABCIQuery, error)
// Writing to abci app
BroadcastTxCommit(context.Context, types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
BroadcastTxAsync(context.Context, types.Tx) (*ctypes.ResultBroadcastTx, error)
BroadcastTxSync(context.Context, types.Tx) (*ctypes.ResultBroadcastTx, error)
BroadcastTxCommit(context.Context, types.Tx) (*coretypes.ResultBroadcastTxCommit, error)
BroadcastTxAsync(context.Context, types.Tx) (*coretypes.ResultBroadcastTx, error)
BroadcastTxSync(context.Context, types.Tx) (*coretypes.ResultBroadcastTx, error)
}
// SignClient groups together the functionality needed to get valid signatures
// and prove anything about the chain.
type SignClient interface {
Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error)
BlockByHash(ctx context.Context, hash bytes.HexBytes) (*ctypes.ResultBlock, error)
BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error)
Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error)
Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error)
Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*ctypes.ResultTx, error)
Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)
BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error)
BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error)
Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)
Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error)
Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error)
// TxSearch defines a method to search for a paginated set of transactions by
// DeliverTx event search criteria.
@@ -90,7 +90,7 @@ type SignClient interface {
prove bool,
page, perPage *int,
orderBy string,
) (*ctypes.ResultTxSearch, error)
) (*coretypes.ResultTxSearch, error)
// BlockSearch defines a method to search for a paginated set of blocks by
// BeginBlock and EndBlock event search criteria.
@@ -99,29 +99,29 @@ type SignClient interface {
query string,
page, perPage *int,
orderBy string,
) (*ctypes.ResultBlockSearch, error)
) (*coretypes.ResultBlockSearch, error)
}
// HistoryClient provides access to data from genesis to now in large chunks.
type HistoryClient interface {
Genesis(context.Context) (*ctypes.ResultGenesis, error)
GenesisChunked(context.Context, uint) (*ctypes.ResultGenesisChunk, error)
BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)
Genesis(context.Context) (*coretypes.ResultGenesis, error)
GenesisChunked(context.Context, uint) (*coretypes.ResultGenesisChunk, error)
BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error)
}
// StatusClient provides access to general chain info.
type StatusClient interface {
Status(context.Context) (*ctypes.ResultStatus, error)
Status(context.Context) (*coretypes.ResultStatus, error)
}
// NetworkClient is general info about the network state. May not be needed
// usually.
type NetworkClient interface {
NetInfo(context.Context) (*ctypes.ResultNetInfo, error)
DumpConsensusState(context.Context) (*ctypes.ResultDumpConsensusState, error)
ConsensusState(context.Context) (*ctypes.ResultConsensusState, error)
ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error)
Health(context.Context) (*ctypes.ResultHealth, error)
NetInfo(context.Context) (*coretypes.ResultNetInfo, error)
DumpConsensusState(context.Context) (*coretypes.ResultDumpConsensusState, error)
ConsensusState(context.Context) (*coretypes.ResultConsensusState, error)
ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error)
Health(context.Context) (*coretypes.ResultHealth, error)
}
// EventsClient is reactive, you can subscribe to any message, given the proper
@@ -134,7 +134,7 @@ type EventsClient interface {
//
// ctx cannot be used to unsubscribe. To unsubscribe, use either Unsubscribe
// or UnsubscribeAll.
Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error)
Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error) //nolint:lll
// Unsubscribe unsubscribes given subscriber from query.
Unsubscribe(ctx context.Context, subscriber, query string) error
// UnsubscribeAll unsubscribes given subscriber from all the queries.
@@ -143,15 +143,15 @@ type EventsClient interface {
// MempoolClient shows us data about current mempool state.
type MempoolClient interface {
UnconfirmedTxs(ctx context.Context, limit *int) (*ctypes.ResultUnconfirmedTxs, error)
NumUnconfirmedTxs(context.Context) (*ctypes.ResultUnconfirmedTxs, error)
CheckTx(context.Context, types.Tx) (*ctypes.ResultCheckTx, error)
UnconfirmedTxs(ctx context.Context, limit *int) (*coretypes.ResultUnconfirmedTxs, error)
NumUnconfirmedTxs(context.Context) (*coretypes.ResultUnconfirmedTxs, error)
CheckTx(context.Context, types.Tx) (*coretypes.ResultCheckTx, error)
}
// EvidenceClient is used for submitting an evidence of the malicious
// behavior.
type EvidenceClient interface {
BroadcastEvidence(context.Context, types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
BroadcastEvidence(context.Context, types.Evidence) (*coretypes.ResultBroadcastEvidence, error)
}
// RemoteClient is a Client, which can also return the remote network address.
+49 -49
View File
@@ -9,10 +9,10 @@ import (
rpccore "github.com/tendermint/tendermint/internal/rpc/core"
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/libs/log"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
"github.com/tendermint/tendermint/libs/pubsub"
"github.com/tendermint/tendermint/libs/pubsub/query"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types"
)
@@ -72,15 +72,15 @@ func (c *Local) SetLogger(l log.Logger) {
c.Logger = l
}
func (c *Local) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
func (c *Local) Status(ctx context.Context) (*coretypes.ResultStatus, error) {
return c.env.Status(c.ctx)
}
func (c *Local) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
func (c *Local) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {
return c.env.ABCIInfo(c.ctx)
}
func (c *Local) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error) {
func (c *Local) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error) {
return c.ABCIQueryWithOptions(ctx, path, data, rpcclient.DefaultABCIQueryOptions)
}
@@ -88,55 +88,55 @@ func (c *Local) ABCIQueryWithOptions(
ctx context.Context,
path string,
data bytes.HexBytes,
opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
return c.env.ABCIQuery(c.ctx, path, data, opts.Height, opts.Prove)
}
func (c *Local) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
func (c *Local) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
return c.env.BroadcastTxCommit(c.ctx, tx)
}
func (c *Local) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (c *Local) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
return c.env.BroadcastTxAsync(c.ctx, tx)
}
func (c *Local) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (c *Local) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
return c.env.BroadcastTxSync(c.ctx, tx)
}
func (c *Local) UnconfirmedTxs(ctx context.Context, limit *int) (*ctypes.ResultUnconfirmedTxs, error) {
func (c *Local) UnconfirmedTxs(ctx context.Context, limit *int) (*coretypes.ResultUnconfirmedTxs, error) {
return c.env.UnconfirmedTxs(c.ctx, limit)
}
func (c *Local) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirmedTxs, error) {
func (c *Local) NumUnconfirmedTxs(ctx context.Context) (*coretypes.ResultUnconfirmedTxs, error) {
return c.env.NumUnconfirmedTxs(c.ctx)
}
func (c *Local) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
func (c *Local) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error) {
return c.env.CheckTx(c.ctx, tx)
}
func (c *Local) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error) {
func (c *Local) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error) {
return c.env.NetInfo(c.ctx)
}
func (c *Local) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error) {
func (c *Local) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error) {
return c.env.DumpConsensusState(c.ctx)
}
func (c *Local) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error) {
func (c *Local) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error) {
return c.env.GetConsensusState(c.ctx)
}
func (c *Local) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) {
func (c *Local) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error) {
return c.env.ConsensusParams(c.ctx, height)
}
func (c *Local) Health(ctx context.Context) (*ctypes.ResultHealth, error) {
func (c *Local) Health(ctx context.Context) (*coretypes.ResultHealth, error) {
return c.env.Health(c.ctx)
}
func (c *Local) DialSeeds(ctx context.Context, seeds []string) (*ctypes.ResultDialSeeds, error) {
func (c *Local) DialSeeds(ctx context.Context, seeds []string) (*coretypes.ResultDialSeeds, error) {
return c.env.UnsafeDialSeeds(c.ctx, seeds)
}
@@ -146,76 +146,76 @@ func (c *Local) DialPeers(
persistent,
unconditional,
private bool,
) (*ctypes.ResultDialPeers, error) {
) (*coretypes.ResultDialPeers, error) {
return c.env.UnsafeDialPeers(c.ctx, peers, persistent, unconditional, private)
}
func (c *Local) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) {
func (c *Local) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error) { //nolint:lll
return c.env.BlockchainInfo(c.ctx, minHeight, maxHeight)
}
func (c *Local) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error) {
func (c *Local) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error) {
return c.env.Genesis(c.ctx)
}
func (c *Local) GenesisChunked(ctx context.Context, id uint) (*ctypes.ResultGenesisChunk, error) {
func (c *Local) GenesisChunked(ctx context.Context, id uint) (*coretypes.ResultGenesisChunk, error) {
return c.env.GenesisChunked(c.ctx, id)
}
func (c *Local) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) {
func (c *Local) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) {
return c.env.Block(c.ctx, height)
}
func (c *Local) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*ctypes.ResultBlock, error) {
func (c *Local) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error) {
return c.env.BlockByHash(c.ctx, hash)
}
func (c *Local) BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error) {
func (c *Local) BlockResults(ctx context.Context, height *int64) (*coretypes.ResultBlockResults, error) {
return c.env.BlockResults(c.ctx, height)
}
func (c *Local) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error) {
func (c *Local) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) {
return c.env.Commit(c.ctx, height)
}
func (c *Local) Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error) {
func (c *Local) Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error) { //nolint:lll
return c.env.Validators(c.ctx, height, page, perPage)
}
func (c *Local) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*ctypes.ResultTx, error) {
func (c *Local) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error) {
return c.env.Tx(c.ctx, hash, prove)
}
func (c *Local) TxSearch(
_ context.Context,
query string,
queryString string,
prove bool,
page,
perPage *int,
orderBy string,
) (*ctypes.ResultTxSearch, error) {
return c.env.TxSearch(c.ctx, query, prove, page, perPage, orderBy)
) (*coretypes.ResultTxSearch, error) {
return c.env.TxSearch(c.ctx, queryString, prove, page, perPage, orderBy)
}
func (c *Local) BlockSearch(
_ context.Context,
query string,
queryString string,
page, perPage *int,
orderBy string,
) (*ctypes.ResultBlockSearch, error) {
return c.env.BlockSearch(c.ctx, query, page, perPage, orderBy)
) (*coretypes.ResultBlockSearch, error) {
return c.env.BlockSearch(c.ctx, queryString, page, perPage, orderBy)
}
func (c *Local) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
func (c *Local) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error) {
return c.env.BroadcastEvidence(c.ctx, ev)
}
func (c *Local) Subscribe(
ctx context.Context,
subscriber,
query string,
outCapacity ...int) (out <-chan ctypes.ResultEvent, err error) {
q, err := tmquery.New(query)
queryString string,
outCapacity ...int) (out <-chan coretypes.ResultEvent, err error) {
q, err := query.New(queryString)
if err != nil {
return nil, fmt.Errorf("failed to parse query: %w", err)
}
@@ -235,7 +235,7 @@ func (c *Local) Subscribe(
return nil, fmt.Errorf("failed to subscribe: %w", err)
}
outc := make(chan ctypes.ResultEvent, outCap)
outc := make(chan coretypes.ResultEvent, outCap)
go c.eventsRoutine(sub, subscriber, q, outc)
return outc, nil
@@ -244,12 +244,12 @@ func (c *Local) Subscribe(
func (c *Local) eventsRoutine(
sub types.Subscription,
subscriber string,
q tmpubsub.Query,
outc chan<- ctypes.ResultEvent) {
q pubsub.Query,
outc chan<- coretypes.ResultEvent) {
for {
select {
case msg := <-sub.Out():
result := ctypes.ResultEvent{
result := coretypes.ResultEvent{
SubscriptionID: msg.SubscriptionID(),
Query: q.String(),
Data: msg.Data(),
@@ -266,7 +266,7 @@ func (c *Local) eventsRoutine(
}
}
case <-sub.Canceled():
if sub.Err() == tmpubsub.ErrUnsubscribed {
if sub.Err() == pubsub.ErrUnsubscribed {
return
}
@@ -282,7 +282,7 @@ func (c *Local) eventsRoutine(
}
// Try to resubscribe with exponential backoff.
func (c *Local) resubscribe(subscriber string, q tmpubsub.Query) types.Subscription {
func (c *Local) resubscribe(subscriber string, q pubsub.Query) types.Subscription {
attempts := 0
for {
if !c.IsRunning() {
@@ -299,17 +299,17 @@ func (c *Local) resubscribe(subscriber string, q tmpubsub.Query) types.Subscript
}
}
func (c *Local) Unsubscribe(ctx context.Context, subscriber, query string) error {
args := tmpubsub.UnsubscribeArgs{Subscriber: subscriber}
func (c *Local) Unsubscribe(ctx context.Context, subscriber, queryString string) error {
args := pubsub.UnsubscribeArgs{Subscriber: subscriber}
var err error
args.Query, err = tmquery.New(query)
args.Query, err = query.New(queryString)
if err != nil {
// if this isn't a valid query it might be an ID, so
// we'll try that. It'll turn into an error when we
// try to unsubscribe. Eventually, perhaps, we'll want
// to change the interface to only allow
// unsubscription by ID, but that's a larger change.
args.ID = query
args.ID = queryString
}
return c.EventBus.Unsubscribe(ctx, args)
}
+29 -29
View File
@@ -7,7 +7,7 @@ import (
"github.com/tendermint/tendermint/internal/proxy"
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/types"
)
@@ -24,11 +24,11 @@ var (
_ client.ABCIClient = (*ABCIRecorder)(nil)
)
func (a ABCIApp) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
return &ctypes.ResultABCIInfo{Response: a.App.Info(proxy.RequestInfo)}, nil
func (a ABCIApp) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {
return &coretypes.ResultABCIInfo{Response: a.App.Info(proxy.RequestInfo)}, nil
}
func (a ABCIApp) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error) {
func (a ABCIApp) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error) {
return a.ABCIQueryWithOptions(ctx, path, data, client.DefaultABCIQueryOptions)
}
@@ -36,21 +36,21 @@ func (a ABCIApp) ABCIQueryWithOptions(
ctx context.Context,
path string,
data bytes.HexBytes,
opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
q := a.App.Query(abci.RequestQuery{
Data: data,
Path: path,
Height: opts.Height,
Prove: opts.Prove,
})
return &ctypes.ResultABCIQuery{Response: q}, nil
return &coretypes.ResultABCIQuery{Response: q}, nil
}
// NOTE: Caller should call a.App.Commit() separately,
// this function does not actually wait for a commit.
// TODO: Make it wait for a commit and set res.Height appropriately.
func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
res := ctypes.ResultBroadcastTxCommit{}
func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
res := coretypes.ResultBroadcastTxCommit{}
res.CheckTx = a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
if res.CheckTx.IsErr() {
return &res, nil
@@ -60,13 +60,13 @@ func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.Re
return &res, nil
}
func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
c := a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
// and this gets written in a background thread...
if !c.IsErr() {
go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }()
}
return &ctypes.ResultBroadcastTx{
return &coretypes.ResultBroadcastTx{
Code: c.Code,
Data: c.Data,
Log: c.Log,
@@ -75,13 +75,13 @@ func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.Res
}, nil
}
func (a ABCIApp) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (a ABCIApp) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
c := a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
// and this gets written in a background thread...
if !c.IsErr() {
go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }()
}
return &ctypes.ResultBroadcastTx{
return &coretypes.ResultBroadcastTx{
Code: c.Code,
Data: c.Data,
Log: c.Log,
@@ -100,15 +100,15 @@ type ABCIMock struct {
Broadcast Call
}
func (m ABCIMock) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
func (m ABCIMock) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {
res, err := m.Info.GetResponse(nil)
if err != nil {
return nil, err
}
return &ctypes.ResultABCIInfo{Response: res.(abci.ResponseInfo)}, nil
return &coretypes.ResultABCIInfo{Response: res.(abci.ResponseInfo)}, nil
}
func (m ABCIMock) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error) {
func (m ABCIMock) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error) {
return m.ABCIQueryWithOptions(ctx, path, data, client.DefaultABCIQueryOptions)
}
@@ -116,37 +116,37 @@ func (m ABCIMock) ABCIQueryWithOptions(
ctx context.Context,
path string,
data bytes.HexBytes,
opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Prove})
if err != nil {
return nil, err
}
resQuery := res.(abci.ResponseQuery)
return &ctypes.ResultABCIQuery{Response: resQuery}, nil
return &coretypes.ResultABCIQuery{Response: resQuery}, nil
}
func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
res, err := m.BroadcastCommit.GetResponse(tx)
if err != nil {
return nil, err
}
return res.(*ctypes.ResultBroadcastTxCommit), nil
return res.(*coretypes.ResultBroadcastTxCommit), nil
}
func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
res, err := m.Broadcast.GetResponse(tx)
if err != nil {
return nil, err
}
return res.(*ctypes.ResultBroadcastTx), nil
return res.(*coretypes.ResultBroadcastTx), nil
}
func (m ABCIMock) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (m ABCIMock) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
res, err := m.Broadcast.GetResponse(tx)
if err != nil {
return nil, err
}
return res.(*ctypes.ResultBroadcastTx), nil
return res.(*coretypes.ResultBroadcastTx), nil
}
// ABCIRecorder can wrap another type (ABCIApp, ABCIMock, or Client)
@@ -174,7 +174,7 @@ func (r *ABCIRecorder) addCall(call Call) {
r.Calls = append(r.Calls, call)
}
func (r *ABCIRecorder) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
func (r *ABCIRecorder) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {
res, err := r.Client.ABCIInfo(ctx)
r.addCall(Call{
Name: "abci_info",
@@ -188,7 +188,7 @@ func (r *ABCIRecorder) ABCIQuery(
ctx context.Context,
path string,
data bytes.HexBytes,
) (*ctypes.ResultABCIQuery, error) {
) (*coretypes.ResultABCIQuery, error) {
return r.ABCIQueryWithOptions(ctx, path, data, client.DefaultABCIQueryOptions)
}
@@ -196,7 +196,7 @@ func (r *ABCIRecorder) ABCIQueryWithOptions(
ctx context.Context,
path string,
data bytes.HexBytes,
opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
res, err := r.Client.ABCIQueryWithOptions(ctx, path, data, opts)
r.addCall(Call{
Name: "abci_query",
@@ -207,7 +207,7 @@ func (r *ABCIRecorder) ABCIQueryWithOptions(
return res, err
}
func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
res, err := r.Client.BroadcastTxCommit(ctx, tx)
r.addCall(Call{
Name: "broadcast_tx_commit",
@@ -218,7 +218,7 @@ func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*cty
return res, err
}
func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
res, err := r.Client.BroadcastTxAsync(ctx, tx)
r.addCall(Call{
Name: "broadcast_tx_async",
@@ -229,7 +229,7 @@ func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctyp
return res, err
}
func (r *ABCIRecorder) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (r *ABCIRecorder) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
res, err := r.Client.BroadcastTxSync(ctx, tx)
r.addCall(Call{
Name: "broadcast_tx_sync",
+3 -3
View File
@@ -14,7 +14,7 @@ import (
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/mock"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/types"
)
@@ -36,7 +36,7 @@ func TestABCIMock(t *testing.T) {
// Broadcast commit depends on call
BroadcastCommit: mock.Call{
Args: goodTx,
Response: &ctypes.ResultBroadcastTxCommit{
Response: &coretypes.ResultBroadcastTxCommit{
CheckTx: abci.ResponseCheckTx{Data: bytes.HexBytes("stand")},
DeliverTx: abci.ResponseDeliverTx{Data: bytes.HexBytes("deliver")},
},
@@ -112,7 +112,7 @@ func TestABCIRecorder(t *testing.T) {
assert.Nil(info.Error)
assert.Nil(info.Args)
require.NotNil(info.Response)
ir, ok := info.Response.(*ctypes.ResultABCIInfo)
ir, ok := info.Response.(*coretypes.ResultABCIInfo)
require.True(ok)
assert.Equal("data", ir.Response.Data)
assert.Equal("v0.9.9", ir.Response.Version)
+23 -23
View File
@@ -21,7 +21,7 @@ import (
"github.com/tendermint/tendermint/internal/rpc/core"
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types"
)
@@ -75,15 +75,15 @@ func (c Call) GetResponse(args interface{}) (interface{}, error) {
return nil, c.Error
}
func (c Client) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
func (c Client) Status(ctx context.Context) (*coretypes.ResultStatus, error) {
return c.env.Status(&rpctypes.Context{})
}
func (c Client) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
func (c Client) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {
return c.env.ABCIInfo(&rpctypes.Context{})
}
func (c Client) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error) {
func (c Client) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error) {
return c.ABCIQueryWithOptions(ctx, path, data, client.DefaultABCIQueryOptions)
}
@@ -91,47 +91,47 @@ func (c Client) ABCIQueryWithOptions(
ctx context.Context,
path string,
data bytes.HexBytes,
opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
opts client.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
return c.env.ABCIQuery(&rpctypes.Context{}, path, data, opts.Height, opts.Prove)
}
func (c Client) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
func (c Client) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
return c.env.BroadcastTxCommit(&rpctypes.Context{}, tx)
}
func (c Client) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (c Client) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
return c.env.BroadcastTxAsync(&rpctypes.Context{}, tx)
}
func (c Client) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (c Client) BroadcastTxSync(ctx context.Context, tx types.Tx) (*coretypes.ResultBroadcastTx, error) {
return c.env.BroadcastTxSync(&rpctypes.Context{}, tx)
}
func (c Client) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
func (c Client) CheckTx(ctx context.Context, tx types.Tx) (*coretypes.ResultCheckTx, error) {
return c.env.CheckTx(&rpctypes.Context{}, tx)
}
func (c Client) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error) {
func (c Client) NetInfo(ctx context.Context) (*coretypes.ResultNetInfo, error) {
return c.env.NetInfo(&rpctypes.Context{})
}
func (c Client) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error) {
func (c Client) ConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error) {
return c.env.GetConsensusState(&rpctypes.Context{})
}
func (c Client) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error) {
func (c Client) DumpConsensusState(ctx context.Context) (*coretypes.ResultDumpConsensusState, error) {
return c.env.DumpConsensusState(&rpctypes.Context{})
}
func (c Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) {
func (c Client) ConsensusParams(ctx context.Context, height *int64) (*coretypes.ResultConsensusParams, error) {
return c.env.ConsensusParams(&rpctypes.Context{}, height)
}
func (c Client) Health(ctx context.Context) (*ctypes.ResultHealth, error) {
func (c Client) Health(ctx context.Context) (*coretypes.ResultHealth, error) {
return c.env.Health(&rpctypes.Context{})
}
func (c Client) DialSeeds(ctx context.Context, seeds []string) (*ctypes.ResultDialSeeds, error) {
func (c Client) DialSeeds(ctx context.Context, seeds []string) (*coretypes.ResultDialSeeds, error) {
return c.env.UnsafeDialSeeds(&rpctypes.Context{}, seeds)
}
@@ -141,34 +141,34 @@ func (c Client) DialPeers(
persistent,
unconditional,
private bool,
) (*ctypes.ResultDialPeers, error) {
) (*coretypes.ResultDialPeers, error) {
return c.env.UnsafeDialPeers(&rpctypes.Context{}, peers, persistent, unconditional, private)
}
func (c Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) {
func (c Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error) { //nolint:lll
return c.env.BlockchainInfo(&rpctypes.Context{}, minHeight, maxHeight)
}
func (c Client) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error) {
func (c Client) Genesis(ctx context.Context) (*coretypes.ResultGenesis, error) {
return c.env.Genesis(&rpctypes.Context{})
}
func (c Client) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) {
func (c Client) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) {
return c.env.Block(&rpctypes.Context{}, height)
}
func (c Client) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*ctypes.ResultBlock, error) {
func (c Client) BlockByHash(ctx context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error) {
return c.env.BlockByHash(&rpctypes.Context{}, hash)
}
func (c Client) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error) {
func (c Client) Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) {
return c.env.Commit(&rpctypes.Context{}, height)
}
func (c Client) Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error) {
func (c Client) Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error) { //nolint:lll
return c.env.Validators(&rpctypes.Context{}, height, page, perPage)
}
func (c Client) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
func (c Client) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*coretypes.ResultBroadcastEvidence, error) {
return c.env.BroadcastEvidence(&rpctypes.Context{}, ev)
}
+4 -4
View File
@@ -4,7 +4,7 @@ import (
"context"
"github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
)
// StatusMock returns the result specified by the Call
@@ -17,12 +17,12 @@ var (
_ client.StatusClient = (*StatusRecorder)(nil)
)
func (m *StatusMock) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
func (m *StatusMock) Status(ctx context.Context) (*coretypes.ResultStatus, error) {
res, err := m.GetResponse(nil)
if err != nil {
return nil, err
}
return res.(*ctypes.ResultStatus), nil
return res.(*coretypes.ResultStatus), nil
}
// StatusRecorder can wrap another type (StatusMock, full client)
@@ -43,7 +43,7 @@ func (r *StatusRecorder) addCall(call Call) {
r.Calls = append(r.Calls, call)
}
func (r *StatusRecorder) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
func (r *StatusRecorder) Status(ctx context.Context) (*coretypes.ResultStatus, error) {
res, err := r.Client.Status(ctx)
r.addCall(Call{
Name: "status",
+4 -4
View File
@@ -10,7 +10,7 @@ import (
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/rpc/client/mock"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
)
func TestStatus(t *testing.T) {
@@ -18,8 +18,8 @@ func TestStatus(t *testing.T) {
m := &mock.StatusMock{
Call: mock.Call{
Response: &ctypes.ResultStatus{
SyncInfo: ctypes.SyncInfo{
Response: &coretypes.ResultStatus{
SyncInfo: coretypes.SyncInfo{
LatestBlockHash: bytes.HexBytes("block"),
LatestAppHash: bytes.HexBytes("app"),
LatestBlockHeight: 10,
@@ -56,7 +56,7 @@ func TestStatus(t *testing.T) {
assert.Nil(rs.Args)
assert.Nil(rs.Error)
require.NotNil(rs.Response)
st, ok := rs.Response.(*ctypes.ResultStatus)
st, ok := rs.Response.(*coretypes.ResultStatus)
require.True(ok)
assert.EqualValues("block", st.SyncInfo.LatestBlockHash)
assert.EqualValues(10, st.SyncInfo.LatestBlockHeight)
+26 -26
View File
@@ -16,7 +16,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/config"
mempl "github.com/tendermint/tendermint/internal/mempool"
"github.com/tendermint/tendermint/internal/mempool"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmmath "github.com/tendermint/tendermint/libs/math"
@@ -24,7 +24,7 @@ import (
"github.com/tendermint/tendermint/rpc/client"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
rpclocal "github.com/tendermint/tendermint/rpc/client/local"
ctypes "github.com/tendermint/tendermint/rpc/coretypes"
"github.com/tendermint/tendermint/rpc/coretypes"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
"github.com/tendermint/tendermint/types"
)
@@ -425,8 +425,8 @@ func TestBroadcastTxSync(t *testing.T) {
defer cancel()
// TODO (melekes): use mempool which is set on RPC rather than getting it from node
mempool := getMempool(t, n)
initMempoolSize := mempool.Size()
pool := getMempool(t, n)
initMempoolSize := pool.Size()
for i, c := range GetClients(t, n, conf) {
_, _, tx := MakeTxKV()
@@ -434,18 +434,18 @@ func TestBroadcastTxSync(t *testing.T) {
require.Nil(t, err, "%d: %+v", i, err)
require.Equal(t, bres.Code, abci.CodeTypeOK) // FIXME
require.Equal(t, initMempoolSize+1, mempool.Size())
require.Equal(t, initMempoolSize+1, pool.Size())
txs := mempool.ReapMaxTxs(len(tx))
txs := pool.ReapMaxTxs(len(tx))
require.EqualValues(t, tx, txs[0])
mempool.Flush()
pool.Flush()
}
}
func getMempool(t *testing.T, srv service.Service) mempl.Mempool {
func getMempool(t *testing.T, srv service.Service) mempool.Mempool {
t.Helper()
n, ok := srv.(interface {
Mempool() mempl.Mempool
Mempool() mempool.Mempool
})
require.True(t, ok)
return n.Mempool()
@@ -457,7 +457,7 @@ func TestBroadcastTxCommit(t *testing.T) {
n, conf := NodeSuite(t)
mempool := getMempool(t, n)
pool := getMempool(t, n)
for i, c := range GetClients(t, n, conf) {
_, _, tx := MakeTxKV()
bres, err := c.BroadcastTxCommit(ctx, tx)
@@ -465,7 +465,7 @@ func TestBroadcastTxCommit(t *testing.T) {
require.True(t, bres.CheckTx.IsOK())
require.True(t, bres.DeliverTx.IsOK())
require.Equal(t, 0, mempool.Size())
require.Equal(t, 0, pool.Size())
}
}
@@ -477,8 +477,8 @@ func TestUnconfirmedTxs(t *testing.T) {
ch := make(chan *abci.Response, 1)
n, conf := NodeSuite(t)
mempool := getMempool(t, n)
err := mempool.CheckTx(ctx, tx, func(resp *abci.Response) { ch <- resp }, mempl.TxInfo{})
pool := getMempool(t, n)
err := pool.CheckTx(ctx, tx, func(resp *abci.Response) { ch <- resp }, mempool.TxInfo{})
require.NoError(t, err)
@@ -497,11 +497,11 @@ func TestUnconfirmedTxs(t *testing.T) {
assert.Equal(t, 1, res.Count)
assert.Equal(t, 1, res.Total)
assert.Equal(t, mempool.SizeBytes(), res.TotalBytes)
assert.Equal(t, pool.SizeBytes(), res.TotalBytes)
assert.Exactly(t, types.Txs{tx}, types.Txs(res.Txs))
}
mempool.Flush()
pool.Flush()
}
func TestNumUnconfirmedTxs(t *testing.T) {
@@ -512,9 +512,9 @@ func TestNumUnconfirmedTxs(t *testing.T) {
n, conf := NodeSuite(t)
ch := make(chan *abci.Response, 1)
mempool := getMempool(t, n)
pool := getMempool(t, n)
err := mempool.CheckTx(ctx, tx, func(resp *abci.Response) { ch <- resp }, mempl.TxInfo{})
err := pool.CheckTx(ctx, tx, func(resp *abci.Response) { ch <- resp }, mempool.TxInfo{})
require.NoError(t, err)
// wait for tx to arrive in mempoool.
@@ -524,7 +524,7 @@ func TestNumUnconfirmedTxs(t *testing.T) {
t.Error("Timed out waiting for CheckTx callback")
}
mempoolSize := mempool.Size()
mempoolSize := pool.Size()
for i, c := range GetClients(t, n, conf) {
mc, ok := c.(client.MempoolClient)
require.True(t, ok, "%d", i)
@@ -533,10 +533,10 @@ func TestNumUnconfirmedTxs(t *testing.T) {
assert.Equal(t, mempoolSize, res.Count)
assert.Equal(t, mempoolSize, res.Total)
assert.Equal(t, mempool.SizeBytes(), res.TotalBytes)
assert.Equal(t, pool.SizeBytes(), res.TotalBytes)
}
mempool.Flush()
pool.Flush()
}
func TestCheckTx(t *testing.T) {
@@ -544,7 +544,7 @@ func TestCheckTx(t *testing.T) {
defer cancel()
n, conf := NodeSuite(t)
mempool := getMempool(t, n)
pool := getMempool(t, n)
for _, c := range GetClients(t, n, conf) {
_, _, tx := MakeTxKV()
@@ -553,7 +553,7 @@ func TestCheckTx(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, abci.CodeTypeOK, res.Code)
assert.Equal(t, 0, mempool.Size(), "mempool must be empty")
assert.Equal(t, 0, pool.Size(), "mempool must be empty")
}
}
@@ -781,10 +781,10 @@ func testBatchedJSONRPCCalls(ctx context.Context, t *testing.T, c *rpchttp.HTTP)
require.Len(t, bresults, 2)
require.Equal(t, 0, batch.Count())
bresult1, ok := bresults[0].(*ctypes.ResultBroadcastTxCommit)
bresult1, ok := bresults[0].(*coretypes.ResultBroadcastTxCommit)
require.True(t, ok)
require.Equal(t, *bresult1, *r1)
bresult2, ok := bresults[1].(*ctypes.ResultBroadcastTxCommit)
bresult2, ok := bresults[1].(*coretypes.ResultBroadcastTxCommit)
require.True(t, ok)
require.Equal(t, *bresult2, *r2)
apph := tmmath.MaxInt64(bresult1.Height, bresult2.Height) + 1
@@ -802,10 +802,10 @@ func testBatchedJSONRPCCalls(ctx context.Context, t *testing.T, c *rpchttp.HTTP)
require.Len(t, qresults, 2)
require.Equal(t, 0, batch.Count())
qresult1, ok := qresults[0].(*ctypes.ResultABCIQuery)
qresult1, ok := qresults[0].(*coretypes.ResultABCIQuery)
require.True(t, ok)
require.Equal(t, *qresult1, *q1)
qresult2, ok := qresults[1].(*ctypes.ResultABCIQuery)
qresult2, ok := qresults[1].(*coretypes.ResultABCIQuery)
require.True(t, ok)
require.Equal(t, *qresult2, *q2)