Compare commits

...

3 Commits

Author SHA1 Message Date
Ethan Buchman
cc628c358e Update types/tx.go 2019-08-22 20:00:49 -04:00
Marko Baricevic
b50aa9a9ca bring back omitempty to *pb.go 2019-08-22 17:39:06 +02:00
Marko Baricevic
60368ac164 Remove omitempty from *pb.go
- remove omitempty from *pb.go files
- added command to makefile for everytime `make protoc_all` is run

- open question:
  - Do we want to further remove omitempty from other places
	- https://github.com/tendermint/tendermint/blob/master/rpc/lib/types/types.go#L151
	- and other places
ref #3882

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
2019-08-08 12:02:46 +02:00
5 changed files with 24 additions and 26 deletions

View File

@@ -3,7 +3,6 @@ package types
import (
"bytes"
"encoding/json"
"strings"
"testing"
"github.com/gogo/protobuf/proto"
@@ -13,10 +12,9 @@ import (
)
func TestMarshalJSON(t *testing.T) {
b, err := json.Marshal(&ResponseDeliverTx{})
_, err := json.Marshal(&ResponseDeliverTx{})
assert.Nil(t, err)
// Do not include empty fields.
assert.False(t, strings.Contains(string(b), "code"))
// include empty fields.
r1 := ResponseCheckTx{
Code: 1,
@@ -31,7 +29,7 @@ func TestMarshalJSON(t *testing.T) {
},
},
}
b, err = json.Marshal(&r1)
b, err := json.Marshal(&r1)
assert.Nil(t, err)
var r2 ResponseCheckTx

View File

@@ -42,14 +42,14 @@ func (r ResponseQuery) IsErr() bool {
}
//---------------------------------------------------------------------------
// override JSON marshalling so we dont emit defaults (ie. disable omitempty)
// override JSON marshalling so we emit defaults (ie. disable omitempty)
// note we need Unmarshal functions too because protobuf had the bright idea
// to marshal int64->string. cool. cool, cool, cool: https://developers.google.com/protocol-buffers/docs/proto3#json
var (
jsonpbMarshaller = jsonpb.Marshaler{
EnumsAsInts: true,
EmitDefaults: false,
EmitDefaults: true,
}
jsonpbUnmarshaller = jsonpb.Unmarshaler{}
)

View File

@@ -34,11 +34,11 @@ var _ = math.Inf
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ResultStatus struct {
NodeInfo *NodeInfo `protobuf:"bytes,1,opt,name=nodeInfo" json:"nodeInfo,omitempty"`
PubKey *PubKey `protobuf:"bytes,2,req,name=pubKey" json:"pubKey,omitempty"`
LatestBlockHash []byte `protobuf:"bytes,3,req,name=latestBlockHash" json:"latestBlockHash,omitempty"`
LatestBlockHeight *int64 `protobuf:"varint,4,req,name=latestBlockHeight" json:"latestBlockHeight,omitempty"`
LatestBlocktime *int64 `protobuf:"varint,5,req,name=latestBlocktime" json:"latestBlocktime,omitempty"`
NodeInfo *NodeInfo `protobuf:"bytes,1,opt,name=nodeInfo" json:"nodeInfo"`
PubKey *PubKey `protobuf:"bytes,2,req,name=pubKey" json:"pubKey"`
LatestBlockHash []byte `protobuf:"bytes,3,req,name=latestBlockHash" json:"latestBlockHash"`
LatestBlockHeight *int64 `protobuf:"varint,4,req,name=latestBlockHeight" json:"latestBlockHeight"`
LatestBlocktime *int64 `protobuf:"varint,5,req,name=latestBlocktime" json:"latestBlocktime"`
XXX_unrecognized []byte `json:"-"`
}
@@ -83,13 +83,13 @@ func (m *ResultStatus) GetLatestBlocktime() int64 {
}
type NodeInfo struct {
Id *ID `protobuf:"bytes,1,req,name=id" json:"id,omitempty"`
Moniker *string `protobuf:"bytes,2,req,name=moniker" json:"moniker,omitempty"`
Network *string `protobuf:"bytes,3,req,name=network" json:"network,omitempty"`
RemoteAddr *string `protobuf:"bytes,4,req,name=remoteAddr" json:"remoteAddr,omitempty"`
ListenAddr *string `protobuf:"bytes,5,req,name=listenAddr" json:"listenAddr,omitempty"`
Version *string `protobuf:"bytes,6,req,name=version" json:"version,omitempty"`
Other []string `protobuf:"bytes,7,rep,name=other" json:"other,omitempty"`
Id *ID `protobuf:"bytes,1,req,name=id" json:"id"`
Moniker *string `protobuf:"bytes,2,req,name=moniker" json:"moniker"`
Network *string `protobuf:"bytes,3,req,name=network" json:"network"`
RemoteAddr *string `protobuf:"bytes,4,req,name=remoteAddr" json:"remoteAddr"`
ListenAddr *string `protobuf:"bytes,5,req,name=listenAddr" json:"listenAddr"`
Version *string `protobuf:"bytes,6,req,name=version" json:"version"`
Other []string `protobuf:"bytes,7,rep,name=other" json:"other"`
XXX_unrecognized []byte `json:"-"`
}
@@ -148,7 +148,7 @@ func (m *NodeInfo) GetOther() []string {
}
type ID struct {
Id *string `protobuf:"bytes,1,req,name=id" json:"id,omitempty"`
Id *string `protobuf:"bytes,1,req,name=id" json:"id"`
XXX_unrecognized []byte `json:"-"`
}
@@ -165,7 +165,7 @@ func (m *ID) GetId() string {
}
type PubKey struct {
Ed25519 *PubKeyEd25519 `protobuf:"bytes,1,opt,name=ed25519" json:"ed25519,omitempty"`
Ed25519 *PubKeyEd25519 `protobuf:"bytes,1,opt,name=ed25519" json:"ed25519"`
XXX_unrecognized []byte `json:"-"`
}
@@ -182,7 +182,7 @@ func (m *PubKey) GetEd25519() *PubKeyEd25519 {
}
type PubKeyEd25519 struct {
Bytes []byte `protobuf:"bytes,1,req,name=bytes" json:"bytes,omitempty"`
Bytes []byte `protobuf:"bytes,1,req,name=bytes" json:"bytes"`
XXX_unrecognized []byte `json:"-"`
}

View File

@@ -1,7 +1,7 @@
package privval
import (
"github.com/tendermint/go-amino"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/types"
)

View File

@@ -83,9 +83,9 @@ 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 {
RootHash cmn.HexBytes
Data Tx
Proof merkle.SimpleProof
RootHash cmn.HexBytes `json:"root_hash"`
Data Tx `json:"data"`
Proof merkle.SimpleProof `json:"proof"`
}
// Leaf returns the hash(tx), which is the leaf in the merkle tree which this proof refers to.