From 7a5060dc520e1b014570bd15e3f15c4f6f3f8d66 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 3 Feb 2018 03:42:59 -0500 Subject: [PATCH] replace data.Bytes with cmn.HexBytes --- lite/proxy/query.go | 4 +--- lite/proxy/wrapper.go | 6 ++---- rpc/client/httpclient.go | 5 ++--- rpc/client/interface.go | 5 ++--- rpc/client/localclient.go | 6 +++--- rpc/client/mock/abci.go | 16 ++++++++-------- rpc/client/mock/abci_test.go | 10 +++++----- rpc/client/mock/client.go | 5 ++--- rpc/client/mock/status_test.go | 6 +++--- rpc/core/abci.go | 4 ++-- rpc/core/mempool.go | 4 ++-- rpc/core/status.go | 6 +++--- rpc/core/types/responses.go | 15 +++++++-------- rpc/lib/rpc_test.go | 9 ++++----- rpc/lib/server/parse_test.go | 20 ++++++++++---------- types/block.go | 33 ++++++++++++++++----------------- types/canonical_json.go | 8 ++++---- types/genesis.go | 3 +-- types/part_set.go | 7 +++---- types/priv_validator.go | 5 ++--- types/results.go | 6 +++--- types/tx.go | 4 ++-- 22 files changed, 87 insertions(+), 100 deletions(-) diff --git a/lite/proxy/query.go b/lite/proxy/query.go index 06d7880a0..1da2a0cce 100644 --- a/lite/proxy/query.go +++ b/lite/proxy/query.go @@ -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") diff --git a/lite/proxy/wrapper.go b/lite/proxy/wrapper.go index 7d504217d..02f2f318b 100644 --- a/lite/proxy/wrapper.go +++ b/lite/proxy/wrapper.go @@ -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) } diff --git a/rpc/client/httpclient.go b/rpc/client/httpclient.go index 838fa5249..2b3f5ab28 100644 --- a/rpc/client/httpclient.go +++ b/rpc/client/httpclient.go @@ -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}, diff --git a/rpc/client/interface.go b/rpc/client/interface.go index 6e798c379..6715b64b5 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -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 diff --git a/rpc/client/localclient.go b/rpc/client/localclient.go index 5e0573a1b..be989ee1c 100644 --- a/rpc/client/localclient.go +++ b/rpc/client/localclient.go @@ -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) } diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index 4593d059a..7f4c45df3 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -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", diff --git a/rpc/client/mock/abci_test.go b/rpc/client/mock/abci_test.go index 0f83cc5f2..5a66c997a 100644 --- a/rpc/client/mock/abci_test.go +++ b/rpc/client/mock/abci_test.go @@ -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) diff --git a/rpc/client/mock/client.go b/rpc/client/mock/client.go index 6c4728986..6af9abb27 100644 --- a/rpc/client/mock/client.go +++ b/rpc/client/mock/client.go @@ -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) } diff --git a/rpc/client/mock/status_test.go b/rpc/client/mock/status_test.go index 80ffe7b7d..b3827fb13 100644 --- a/rpc/client/mock/status_test.go +++ b/rpc/client/mock/status_test.go @@ -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, }}, } diff --git a/rpc/core/abci.go b/rpc/core/abci.go index a49b52b6e..874becae3 100644 --- a/rpc/core/abci.go +++ b/rpc/core/abci.go @@ -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, diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 3f663c376..1dbdd8012 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -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, diff --git a/rpc/core/status.go b/rpc/core/status.go index 653c37f50..a8771c8f7 100644 --- a/rpc/core/status.go +++ b/rpc/core/status.go @@ -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 { diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 233b44e93..79904efa7 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -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"` } diff --git a/rpc/lib/rpc_test.go b/rpc/lib/rpc_test.go index be170985f..8c8b57612 100644 --- a/rpc/lib/rpc_test.go +++ b/rpc/lib/rpc_test.go @@ -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) diff --git a/rpc/lib/server/parse_test.go b/rpc/lib/server/parse_test.go index a86226f2c..0703d50ed 100644 --- a/rpc/lib/server/parse_test.go +++ b/rpc/lib/server/parse_test.go @@ -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) } diff --git a/types/block.go b/types/block.go index b9b541a96..3e800e722 100644 --- a/types/block.go +++ b/types/block.go @@ -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"` } diff --git a/types/canonical_json.go b/types/canonical_json.go index d3b7cf2fb..45d12b45f 100644 --- a/types/canonical_json.go +++ b/types/canonical_json.go @@ -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 { diff --git a/types/genesis.go b/types/genesis.go index e33f60258..b7e4f6452 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -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"` } diff --git a/types/part_set.go b/types/part_set.go index d922e34d6..ff11f7d35 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -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 { diff --git a/types/priv_validator.go b/types/priv_validator.go index 020fbc43c..062fe09d2 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -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"` diff --git a/types/results.go b/types/results.go index 8e79e1ac7..4a02f2857 100644 --- a/types/results.go +++ b/types/results.go @@ -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 diff --git a/types/tx.go b/types/tx.go index db42ed8e7..d9e2e2ebd 100644 --- a/types/tx.go +++ b/types/tx.go @@ -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 }