replace data.Bytes with cmn.HexBytes
This commit is contained in:
parent
426379dc47
commit
7a5060dc52
|
@ -3,8 +3,6 @@ package proxy
|
|||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/tendermint/lite"
|
||||
"github.com/tendermint/tendermint/lite/client"
|
||||
certerr "github.com/tendermint/tendermint/lite/errors"
|
||||
|
@ -34,7 +32,7 @@ type KeyProof interface {
|
|||
// If val is empty, proof should be KeyMissingProof
|
||||
func GetWithProof(key []byte, reqHeight int64, node rpcclient.Client,
|
||||
cert lite.Certifier) (
|
||||
val data.Bytes, height int64, proof KeyProof, err error) {
|
||||
val cmn.HexBytes, height int64, proof KeyProof, err error) {
|
||||
|
||||
if reqHeight < 0 {
|
||||
err = errors.Errorf("Height cannot be negative")
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package proxy
|
||||
|
||||
import (
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/tendermint/lite"
|
||||
certclient "github.com/tendermint/tendermint/lite/client"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
|
@ -34,7 +32,7 @@ func SecureClient(c rpcclient.Client, cert *lite.InquiringCertifier) Wrapper {
|
|||
}
|
||||
|
||||
// ABCIQueryWithOptions exposes all options for the ABCI query and verifies the returned proof
|
||||
func (w Wrapper) ABCIQueryWithOptions(path string, data data.Bytes,
|
||||
func (w Wrapper) ABCIQueryWithOptions(path string, data cmn.HexBytes,
|
||||
opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
|
||||
res, _, err := GetWithProofOptions(path, data, opts, w.Client, w.cert)
|
||||
|
@ -42,7 +40,7 @@ func (w Wrapper) ABCIQueryWithOptions(path string, data data.Bytes,
|
|||
}
|
||||
|
||||
// ABCIQuery uses default options for the ABCI query and verifies the returned proof
|
||||
func (w Wrapper) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (w Wrapper) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return w.ABCIQueryWithOptions(path, data, rpcclient.DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
@ -64,11 +63,11 @@ func (c *HTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (c *HTTP) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
func (c *HTTP) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
func (c *HTTP) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
result := new(ctypes.ResultABCIQuery)
|
||||
_, err := c.rpc.Call("abci_query",
|
||||
map[string]interface{}{"path": path, "data": data, "height": opts.Height, "trusted": opts.Trusted},
|
||||
|
|
|
@ -20,7 +20,6 @@ implementation.
|
|||
package client
|
||||
|
||||
import (
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
|
@ -32,8 +31,8 @@ import (
|
|||
type ABCIClient interface {
|
||||
// reading from abci app
|
||||
ABCIInfo() (*ctypes.ResultABCIInfo, error)
|
||||
ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error)
|
||||
ABCIQueryWithOptions(path string, data data.Bytes,
|
||||
ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error)
|
||||
ABCIQueryWithOptions(path string, data cmn.HexBytes,
|
||||
opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
|
||||
|
||||
// writing to abci app
|
||||
|
|
|
@ -3,11 +3,11 @@ package client
|
|||
import (
|
||||
"context"
|
||||
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
nm "github.com/tendermint/tendermint/node"
|
||||
"github.com/tendermint/tendermint/rpc/core"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
tmpubsub "github.com/tendermint/tmlibs/pubsub"
|
||||
)
|
||||
|
||||
|
@ -56,11 +56,11 @@ func (Local) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||
return core.ABCIInfo()
|
||||
}
|
||||
|
||||
func (c *Local) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (c *Local) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
func (Local) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
func (Local) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
return core.ABCIQuery(path, data, opts.Height, opts.Trusted)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package mock
|
|||
|
||||
import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
// ABCIApp will send all abci related request to the named app,
|
||||
|
@ -26,11 +26,11 @@ func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||
return &ctypes.ResultABCIInfo{a.App.Info(abci.RequestInfo{version.Version})}, nil
|
||||
}
|
||||
|
||||
func (a ABCIApp) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (a ABCIApp) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return a.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
func (a ABCIApp) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
func (a ABCIApp) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
q := a.App.Query(abci.RequestQuery{data, path, opts.Height, opts.Trusted})
|
||||
return &ctypes.ResultABCIQuery{q}, nil
|
||||
}
|
||||
|
@ -81,11 +81,11 @@ func (m ABCIMock) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||
return &ctypes.ResultABCIInfo{res.(abci.ResponseInfo)}, nil
|
||||
}
|
||||
|
||||
func (m ABCIMock) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (m ABCIMock) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return m.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
func (m ABCIMock) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
func (m ABCIMock) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Trusted})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -134,7 +134,7 @@ func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder {
|
|||
|
||||
type QueryArgs struct {
|
||||
Path string
|
||||
Data data.Bytes
|
||||
Data cmn.HexBytes
|
||||
Height int64
|
||||
Trusted bool
|
||||
}
|
||||
|
@ -153,11 +153,11 @@ func (r *ABCIRecorder) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||
return res, err
|
||||
}
|
||||
|
||||
func (r *ABCIRecorder) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (r *ABCIRecorder) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return r.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
res, err := r.Client.ABCIQueryWithOptions(path, data, opts)
|
||||
r.addCall(Call{
|
||||
Name: "abci_query",
|
||||
|
|
|
@ -11,11 +11,11 @@ import (
|
|||
|
||||
"github.com/tendermint/abci/example/dummy"
|
||||
abci "github.com/tendermint/abci/types"
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
"github.com/tendermint/tendermint/rpc/client/mock"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
func TestABCIMock(t *testing.T) {
|
||||
|
@ -37,8 +37,8 @@ func TestABCIMock(t *testing.T) {
|
|||
BroadcastCommit: mock.Call{
|
||||
Args: goodTx,
|
||||
Response: &ctypes.ResultBroadcastTxCommit{
|
||||
CheckTx: abci.ResponseCheckTx{Data: data.Bytes("stand")},
|
||||
DeliverTx: abci.ResponseDeliverTx{Data: data.Bytes("deliver")},
|
||||
CheckTx: abci.ResponseCheckTx{Data: cmn.HexBytes("stand")},
|
||||
DeliverTx: abci.ResponseDeliverTx{Data: cmn.HexBytes("deliver")},
|
||||
},
|
||||
Error: errors.New("bad tx"),
|
||||
},
|
||||
|
@ -98,7 +98,7 @@ func TestABCIRecorder(t *testing.T) {
|
|||
_, err := r.ABCIInfo()
|
||||
assert.Nil(err, "expected no err on info")
|
||||
|
||||
_, err = r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false})
|
||||
_, err = r.ABCIQueryWithOptions("path", cmn.HexBytes("data"), client.ABCIQueryOptions{Trusted: false})
|
||||
assert.NotNil(err, "expected error on query")
|
||||
require.Equal(2, len(r.Calls))
|
||||
|
||||
|
@ -174,7 +174,7 @@ func TestABCIApp(t *testing.T) {
|
|||
assert.True(res.DeliverTx.IsOK())
|
||||
|
||||
// check the key
|
||||
_qres, err := m.ABCIQueryWithOptions("/key", data.Bytes(key), client.ABCIQueryOptions{Trusted: true})
|
||||
_qres, err := m.ABCIQueryWithOptions("/key", cmn.HexBytes(key), client.ABCIQueryOptions{Trusted: true})
|
||||
qres := _qres.Response
|
||||
require.Nil(err)
|
||||
assert.EqualValues(value, qres.Value)
|
||||
|
|
|
@ -16,7 +16,6 @@ package mock
|
|||
import (
|
||||
"reflect"
|
||||
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
"github.com/tendermint/tendermint/rpc/core"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
@ -83,11 +82,11 @@ func (c Client) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||
return core.ABCIInfo()
|
||||
}
|
||||
|
||||
func (c Client) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||
func (c Client) ABCIQuery(path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||
return c.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||
}
|
||||
|
||||
func (c Client) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
func (c Client) ABCIQueryWithOptions(path string, data cmn.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||
return core.ABCIQuery(path, data, opts.Height, opts.Trusted)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
"github.com/tendermint/tendermint/rpc/client/mock"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
func TestStatus(t *testing.T) {
|
||||
|
@ -17,8 +17,8 @@ func TestStatus(t *testing.T) {
|
|||
m := &mock.StatusMock{
|
||||
Call: mock.Call{
|
||||
Response: &ctypes.ResultStatus{
|
||||
LatestBlockHash: data.Bytes("block"),
|
||||
LatestAppHash: data.Bytes("app"),
|
||||
LatestBlockHash: cmn.HexBytes("block"),
|
||||
LatestAppHash: cmn.HexBytes("app"),
|
||||
LatestBlockHeight: 10,
|
||||
}},
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package core
|
|||
|
||||
import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
// Query the application for some information.
|
||||
|
@ -47,7 +47,7 @@ import (
|
|||
// | data | []byte | false | true | Data |
|
||||
// | height | int64 | 0 | false | Height (0 means latest) |
|
||||
// | trusted | bool | false | false | Does not include a proof of the data inclusion |
|
||||
func ABCIQuery(path string, data data.Bytes, height int64, trusted bool) (*ctypes.ResultABCIQuery, error) {
|
||||
func ABCIQuery(path string, data cmn.HexBytes, height int64, trusted bool) (*ctypes.ResultABCIQuery, error) {
|
||||
resQuery, err := proxyAppQuery.QuerySync(abci.RequestQuery{
|
||||
Path: path,
|
||||
Data: data,
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -192,7 +192,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
|||
deliverTxRes := deliverTxResMsg.(types.TMEventData).Unwrap().(types.EventDataTx)
|
||||
// The tx was included in a block.
|
||||
deliverTxR := deliverTxRes.Result
|
||||
logger.Info("DeliverTx passed ", "tx", data.Bytes(tx), "response", deliverTxR)
|
||||
logger.Info("DeliverTx passed ", "tx", cmn.HexBytes(tx), "response", deliverTxR)
|
||||
return &ctypes.ResultBroadcastTxCommit{
|
||||
CheckTx: *checkTxR,
|
||||
DeliverTx: deliverTxR,
|
||||
|
|
|
@ -3,9 +3,9 @@ package core
|
|||
import (
|
||||
"time"
|
||||
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
// Get Tendermint status including node info, pubkey, latest block
|
||||
|
@ -59,8 +59,8 @@ func Status() (*ctypes.ResultStatus, error) {
|
|||
latestHeight := blockStore.Height()
|
||||
var (
|
||||
latestBlockMeta *types.BlockMeta
|
||||
latestBlockHash data.Bytes
|
||||
latestAppHash data.Bytes
|
||||
latestBlockHash cmn.HexBytes
|
||||
latestAppHash cmn.HexBytes
|
||||
latestBlockTimeNano int64
|
||||
)
|
||||
if latestHeight != 0 {
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cstypes "github.com/tendermint/tendermint/consensus/types"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
|
@ -56,8 +55,8 @@ func NewResultCommit(header *types.Header, commit *types.Commit,
|
|||
type ResultStatus struct {
|
||||
NodeInfo p2p.NodeInfo `json:"node_info"`
|
||||
PubKey crypto.PubKey `json:"pub_key"`
|
||||
LatestBlockHash data.Bytes `json:"latest_block_hash"`
|
||||
LatestAppHash data.Bytes `json:"latest_app_hash"`
|
||||
LatestBlockHash cmn.HexBytes `json:"latest_block_hash"`
|
||||
LatestAppHash cmn.HexBytes `json:"latest_app_hash"`
|
||||
LatestBlockHeight int64 `json:"latest_block_height"`
|
||||
LatestBlockTime time.Time `json:"latest_block_time"`
|
||||
Syncing bool `json:"syncing"`
|
||||
|
@ -107,17 +106,17 @@ type ResultDumpConsensusState struct {
|
|||
}
|
||||
|
||||
type ResultBroadcastTx struct {
|
||||
Code uint32 `json:"code"`
|
||||
Data data.Bytes `json:"data"`
|
||||
Log string `json:"log"`
|
||||
Code uint32 `json:"code"`
|
||||
Data cmn.HexBytes `json:"data"`
|
||||
Log string `json:"log"`
|
||||
|
||||
Hash data.Bytes `json:"hash"`
|
||||
Hash cmn.HexBytes `json:"hash"`
|
||||
}
|
||||
|
||||
type ResultBroadcastTxCommit struct {
|
||||
CheckTx abci.ResponseCheckTx `json:"check_tx"`
|
||||
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
|
||||
Hash data.Bytes `json:"hash"`
|
||||
Hash cmn.HexBytes `json:"hash"`
|
||||
Height int64 `json:"height"`
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/go-wire/data"
|
||||
client "github.com/tendermint/tendermint/rpc/lib/client"
|
||||
server "github.com/tendermint/tendermint/rpc/lib/server"
|
||||
types "github.com/tendermint/tendermint/rpc/lib/types"
|
||||
|
@ -47,7 +46,7 @@ type ResultEchoBytes struct {
|
|||
}
|
||||
|
||||
type ResultEchoDataBytes struct {
|
||||
Value data.Bytes `json:"value"`
|
||||
Value cmn.HexBytes `json:"value"`
|
||||
}
|
||||
|
||||
// Define some routes
|
||||
|
@ -75,7 +74,7 @@ func EchoBytesResult(v []byte) (*ResultEchoBytes, error) {
|
|||
return &ResultEchoBytes{v}, nil
|
||||
}
|
||||
|
||||
func EchoDataBytesResult(v data.Bytes) (*ResultEchoDataBytes, error) {
|
||||
func EchoDataBytesResult(v cmn.HexBytes) (*ResultEchoDataBytes, error) {
|
||||
return &ResultEchoDataBytes{v}, nil
|
||||
}
|
||||
|
||||
|
@ -174,7 +173,7 @@ func echoBytesViaHTTP(cl client.HTTPClient, bytes []byte) ([]byte, error) {
|
|||
return result.Value, nil
|
||||
}
|
||||
|
||||
func echoDataBytesViaHTTP(cl client.HTTPClient, bytes data.Bytes) (data.Bytes, error) {
|
||||
func echoDataBytesViaHTTP(cl client.HTTPClient, bytes cmn.HexBytes) (cmn.HexBytes, error) {
|
||||
params := map[string]interface{}{
|
||||
"arg": bytes,
|
||||
}
|
||||
|
@ -196,7 +195,7 @@ func testWithHTTPClient(t *testing.T, cl client.HTTPClient) {
|
|||
require.Nil(t, err)
|
||||
assert.Equal(t, got2, val2)
|
||||
|
||||
val3 := data.Bytes(randBytes(t))
|
||||
val3 := cmn.HexBytes(randBytes(t))
|
||||
got3, err := echoDataBytesViaHTTP(cl, val3)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, got3, val3)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
func TestParseJSONMap(t *testing.T) {
|
||||
|
@ -31,7 +31,7 @@ func TestParseJSONMap(t *testing.T) {
|
|||
// preloading map with values doesn't help
|
||||
tmp := 0
|
||||
p2 := map[string]interface{}{
|
||||
"value": &data.Bytes{},
|
||||
"value": &cmn.HexBytes{},
|
||||
"height": &tmp,
|
||||
}
|
||||
err = json.Unmarshal(input, &p2)
|
||||
|
@ -54,7 +54,7 @@ func TestParseJSONMap(t *testing.T) {
|
|||
Height interface{} `json:"height"`
|
||||
}{
|
||||
Height: &tmp,
|
||||
Value: &data.Bytes{},
|
||||
Value: &cmn.HexBytes{},
|
||||
}
|
||||
err = json.Unmarshal(input, &p3)
|
||||
if assert.Nil(err) {
|
||||
|
@ -62,7 +62,7 @@ func TestParseJSONMap(t *testing.T) {
|
|||
if assert.True(ok, "%#v", p3.Height) {
|
||||
assert.Equal(22, *h)
|
||||
}
|
||||
v, ok := p3.Value.(*data.Bytes)
|
||||
v, ok := p3.Value.(*cmn.HexBytes)
|
||||
if assert.True(ok, "%#v", p3.Value) {
|
||||
assert.EqualValues([]byte{0x12, 0x34}, *v)
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ func TestParseJSONMap(t *testing.T) {
|
|||
|
||||
// simplest solution, but hard-coded
|
||||
p4 := struct {
|
||||
Value data.Bytes `json:"value"`
|
||||
Height int `json:"height"`
|
||||
Value cmn.HexBytes `json:"value"`
|
||||
Height int `json:"height"`
|
||||
}{}
|
||||
err = json.Unmarshal(input, &p4)
|
||||
if assert.Nil(err) {
|
||||
|
@ -90,10 +90,10 @@ func TestParseJSONMap(t *testing.T) {
|
|||
assert.Equal(22, h)
|
||||
}
|
||||
|
||||
var v data.Bytes
|
||||
var v cmn.HexBytes
|
||||
err = json.Unmarshal(*p5["value"], &v)
|
||||
if assert.Nil(err) {
|
||||
assert.Equal(data.Bytes{0x12, 0x34}, v)
|
||||
assert.Equal(cmn.HexBytes{0x12, 0x34}, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,10 +119,10 @@ func TestParseJSONArray(t *testing.T) {
|
|||
|
||||
// preloading map with values helps here (unlike map - p2 above)
|
||||
tmp := 0
|
||||
p2 := []interface{}{&data.Bytes{}, &tmp}
|
||||
p2 := []interface{}{&cmn.HexBytes{}, &tmp}
|
||||
err = json.Unmarshal(input, &p2)
|
||||
if assert.Nil(err) {
|
||||
v, ok := p2[0].(*data.Bytes)
|
||||
v, ok := p2[0].(*cmn.HexBytes)
|
||||
if assert.True(ok, "%#v", p2[0]) {
|
||||
assert.EqualValues([]byte{0x12, 0x34}, *v)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"time"
|
||||
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/merkle"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
|
@ -86,7 +85,7 @@ func (b *Block) FillHeader() {
|
|||
|
||||
// Hash computes and returns the block hash.
|
||||
// If the block is incomplete, block hash is nil for safety.
|
||||
func (b *Block) Hash() data.Bytes {
|
||||
func (b *Block) Hash() cmn.HexBytes {
|
||||
if b == nil || b.Header == nil || b.Data == nil || b.LastCommit == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -161,22 +160,22 @@ type Header struct {
|
|||
TotalTxs int64 `json:"total_txs"`
|
||||
|
||||
// hashes of block data
|
||||
LastCommitHash data.Bytes `json:"last_commit_hash"` // commit from validators from the last block
|
||||
DataHash data.Bytes `json:"data_hash"` // transactions
|
||||
LastCommitHash cmn.HexBytes `json:"last_commit_hash"` // commit from validators from the last block
|
||||
DataHash cmn.HexBytes `json:"data_hash"` // transactions
|
||||
|
||||
// hashes from the app output from the prev block
|
||||
ValidatorsHash data.Bytes `json:"validators_hash"` // validators for the current block
|
||||
ConsensusHash data.Bytes `json:"consensus_hash"` // consensus params for current block
|
||||
AppHash data.Bytes `json:"app_hash"` // state after txs from the previous block
|
||||
LastResultsHash data.Bytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block
|
||||
ValidatorsHash cmn.HexBytes `json:"validators_hash"` // validators for the current block
|
||||
ConsensusHash cmn.HexBytes `json:"consensus_hash"` // consensus params for current block
|
||||
AppHash cmn.HexBytes `json:"app_hash"` // state after txs from the previous block
|
||||
LastResultsHash cmn.HexBytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block
|
||||
|
||||
// consensus info
|
||||
EvidenceHash data.Bytes `json:"evidence_hash"` // evidence included in the block
|
||||
EvidenceHash cmn.HexBytes `json:"evidence_hash"` // evidence included in the block
|
||||
}
|
||||
|
||||
// Hash returns the hash of the header.
|
||||
// Returns nil if ValidatorHash is missing.
|
||||
func (h *Header) Hash() data.Bytes {
|
||||
func (h *Header) Hash() cmn.HexBytes {
|
||||
if len(h.ValidatorsHash) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
@ -246,7 +245,7 @@ type Commit struct {
|
|||
|
||||
// Volatile
|
||||
firstPrecommit *Vote
|
||||
hash data.Bytes
|
||||
hash cmn.HexBytes
|
||||
bitArray *cmn.BitArray
|
||||
}
|
||||
|
||||
|
@ -355,7 +354,7 @@ func (commit *Commit) ValidateBasic() error {
|
|||
}
|
||||
|
||||
// Hash returns the hash of the commit
|
||||
func (commit *Commit) Hash() data.Bytes {
|
||||
func (commit *Commit) Hash() cmn.HexBytes {
|
||||
if commit.hash == nil {
|
||||
bs := make([]merkle.Hasher, len(commit.Precommits))
|
||||
for i, precommit := range commit.Precommits {
|
||||
|
@ -403,11 +402,11 @@ type Data struct {
|
|||
Txs Txs `json:"txs"`
|
||||
|
||||
// Volatile
|
||||
hash data.Bytes
|
||||
hash cmn.HexBytes
|
||||
}
|
||||
|
||||
// Hash returns the hash of the data
|
||||
func (data *Data) Hash() data.Bytes {
|
||||
func (data *Data) Hash() cmn.HexBytes {
|
||||
if data.hash == nil {
|
||||
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
|
||||
}
|
||||
|
@ -441,11 +440,11 @@ type EvidenceData struct {
|
|||
Evidence EvidenceList `json:"evidence"`
|
||||
|
||||
// Volatile
|
||||
hash data.Bytes
|
||||
hash cmn.HexBytes
|
||||
}
|
||||
|
||||
// Hash returns the hash of the data.
|
||||
func (data *EvidenceData) Hash() data.Bytes {
|
||||
func (data *EvidenceData) Hash() cmn.HexBytes {
|
||||
if data.hash == nil {
|
||||
data.hash = data.Evidence.Hash()
|
||||
}
|
||||
|
@ -477,7 +476,7 @@ func (data *EvidenceData) StringIndented(indent string) string {
|
|||
|
||||
// BlockID defines the unique ID of a block as its Hash and its PartSetHeader
|
||||
type BlockID struct {
|
||||
Hash data.Bytes `json:"hash"`
|
||||
Hash cmn.HexBytes `json:"hash"`
|
||||
PartsHeader PartSetHeader `json:"parts"`
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
// canonical json is go-wire's json for structs with fields in alphabetical order
|
||||
|
@ -13,13 +13,13 @@ import (
|
|||
const timeFormat = wire.RFC3339Millis
|
||||
|
||||
type CanonicalJSONBlockID struct {
|
||||
Hash data.Bytes `json:"hash,omitempty"`
|
||||
Hash cmn.HexBytes `json:"hash,omitempty"`
|
||||
PartsHeader CanonicalJSONPartSetHeader `json:"parts,omitempty"`
|
||||
}
|
||||
|
||||
type CanonicalJSONPartSetHeader struct {
|
||||
Hash data.Bytes `json:"hash"`
|
||||
Total int `json:"total"`
|
||||
Hash cmn.HexBytes `json:"hash"`
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type CanonicalJSONProposal struct {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
|
@ -28,7 +27,7 @@ type GenesisDoc struct {
|
|||
ChainID string `json:"chain_id"`
|
||||
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
|
||||
Validators []GenesisValidator `json:"validators"`
|
||||
AppHash data.Bytes `json:"app_hash"`
|
||||
AppHash cmn.HexBytes `json:"app_hash"`
|
||||
AppOptions interface{} `json:"app_options,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"golang.org/x/crypto/ripemd160"
|
||||
|
||||
"github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/merkle"
|
||||
)
|
||||
|
@ -22,7 +21,7 @@ var (
|
|||
|
||||
type Part struct {
|
||||
Index int `json:"index"`
|
||||
Bytes data.Bytes `json:"bytes"`
|
||||
Bytes cmn.HexBytes `json:"bytes"`
|
||||
Proof merkle.SimpleProof `json:"proof"`
|
||||
|
||||
// Cache
|
||||
|
@ -58,8 +57,8 @@ func (part *Part) StringIndented(indent string) string {
|
|||
//-------------------------------------
|
||||
|
||||
type PartSetHeader struct {
|
||||
Total int `json:"total"`
|
||||
Hash data.Bytes `json:"hash"`
|
||||
Total int `json:"total"`
|
||||
Hash cmn.HexBytes `json:"hash"`
|
||||
}
|
||||
|
||||
func (psh PartSetHeader) String() string {
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"time"
|
||||
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
data "github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
)
|
||||
|
||||
|
@ -50,13 +49,13 @@ type PrivValidator interface {
|
|||
// to prevent double signing. The Signer itself can be mutated to use
|
||||
// something besides the default, for instance a hardware signer.
|
||||
type PrivValidatorFS struct {
|
||||
Address Address `json:"address"`
|
||||
Address Address `json:"address"`
|
||||
PubKey crypto.PubKey `json:"pub_key"`
|
||||
LastHeight int64 `json:"last_height"`
|
||||
LastRound int `json:"last_round"`
|
||||
LastStep int8 `json:"last_step"`
|
||||
LastSignature crypto.Signature `json:"last_signature,omitempty"` // so we dont lose signatures
|
||||
LastSignBytes data.Bytes `json:"last_signbytes,omitempty"` // so we dont lose signatures
|
||||
LastSignBytes cmn.HexBytes `json:"last_signbytes,omitempty"` // so we dont lose signatures
|
||||
|
||||
// PrivKey should be empty if a Signer other than the default is being used.
|
||||
PrivKey crypto.PrivKey `json:"priv_key"`
|
||||
|
|
|
@ -3,7 +3,7 @@ package types
|
|||
import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/merkle"
|
||||
)
|
||||
|
||||
|
@ -12,8 +12,8 @@ import (
|
|||
// ABCIResult is the deterministic component of a ResponseDeliverTx.
|
||||
// TODO: add Tags
|
||||
type ABCIResult struct {
|
||||
Code uint32 `json:"code"`
|
||||
Data data.Bytes `json:"data"`
|
||||
Code uint32 `json:"code"`
|
||||
Data cmn.HexBytes `json:"data"`
|
||||
}
|
||||
|
||||
// Hash returns the canonical hash of the ABCIResult
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/merkle"
|
||||
)
|
||||
|
||||
|
@ -90,7 +90,7 @@ func (txs Txs) Proof(i int) TxProof {
|
|||
// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
|
||||
type TxProof struct {
|
||||
Index, Total int
|
||||
RootHash data.Bytes
|
||||
RootHash cmn.HexBytes
|
||||
Data Tx
|
||||
Proof merkle.SimpleProof
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue