diff --git a/benchmarks/codec_test.go b/benchmarks/codec_test.go index 83e25e212..2f24b776d 100644 --- a/benchmarks/codec_test.go +++ b/benchmarks/codec_test.go @@ -16,17 +16,17 @@ func BenchmarkEncodeStatusWire(b *testing.B) { b.StopTimer() cdc := amino.NewCodec() ctypes.RegisterAmino(cdc) - pubKey := crypto.GenPrivKeyEd25519().PubKey() + nodeKey := p2p.NodeKey{PrivKey: crypto.GenPrivKeyEd25519()} status := &ctypes.ResultStatus{ NodeInfo: p2p.NodeInfo{ - PubKey: pubKey, + ID: nodeKey.ID(), Moniker: "SOMENAME", Network: "SOMENAME", ListenAddr: "SOMEADDR", Version: "SOMEVER", Other: []string{"SOMESTRING", "OTHERSTRING"}, }, - PubKey: pubKey, + PubKey: nodeKey.PubKey(), LatestBlockHash: []byte("SOMEBYTES"), LatestBlockHeight: 123, LatestBlockTime: time.Unix(0, 1234), @@ -48,9 +48,9 @@ func BenchmarkEncodeNodeInfoWire(b *testing.B) { b.StopTimer() cdc := amino.NewCodec() ctypes.RegisterAmino(cdc) - pubKey := crypto.GenPrivKeyEd25519().PubKey() + nodeKey := p2p.NodeKey{PrivKey: crypto.GenPrivKeyEd25519()} nodeInfo := p2p.NodeInfo{ - PubKey: pubKey, + ID: nodeKey.ID(), Moniker: "SOMENAME", Network: "SOMENAME", ListenAddr: "SOMEADDR", @@ -73,9 +73,9 @@ func BenchmarkEncodeNodeInfoBinary(b *testing.B) { b.StopTimer() cdc := amino.NewCodec() ctypes.RegisterAmino(cdc) - pubKey := crypto.GenPrivKeyEd25519().PubKey() + nodeKey := p2p.NodeKey{PrivKey: crypto.GenPrivKeyEd25519()} nodeInfo := p2p.NodeInfo{ - PubKey: pubKey, + ID: nodeKey.ID(), Moniker: "SOMENAME", Network: "SOMENAME", ListenAddr: "SOMEADDR", @@ -94,15 +94,20 @@ func BenchmarkEncodeNodeInfoBinary(b *testing.B) { func BenchmarkEncodeNodeInfoProto(b *testing.B) { b.StopTimer() - pubKey := crypto.GenPrivKeyEd25519().PubKey().(crypto.PubKeyEd25519) - pubKey2 := &proto.PubKey{Ed25519: &proto.PubKeyEd25519{Bytes: pubKey[:]}} + nodeKey := p2p.NodeKey{PrivKey: crypto.GenPrivKeyEd25519()} + nodeID := string(nodeKey.ID()) + someName := "SOMENAME" + someAddr := "SOMEADDR" + someVer := "SOMEVER" + someString := "SOMESTRING" + otherString := "OTHERSTRING" nodeInfo := proto.NodeInfo{ - PubKey: pubKey2, - Moniker: "SOMENAME", - Network: "SOMENAME", - ListenAddr: "SOMEADDR", - Version: "SOMEVER", - Other: []string{"SOMESTRING", "OTHERSTRING"}, + Id: &proto.ID{Id: &nodeID}, + Moniker: &someName, + Network: &someName, + ListenAddr: &someAddr, + Version: &someVer, + Other: []string{someString, otherString}, } b.StartTimer() diff --git a/benchmarks/proto/test.pb.go b/benchmarks/proto/test.pb.go index dc21a2a82..d430eeb08 100644 --- a/benchmarks/proto/test.pb.go +++ b/benchmarks/proto/test.pb.go @@ -1,6 +1,5 @@ -// Code generated by protoc-gen-gogo. +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: test.proto -// DO NOT EDIT! /* Package test is a generated protocol buffer package. @@ -11,6 +10,7 @@ It has these top-level messages: ResultStatus NodeInfo + ID PubKey PubKeyEd25519 */ @@ -20,11 +20,6 @@ import proto "github.com/gogo/protobuf/proto" import fmt "fmt" import math "math" -import bytes "bytes" - -import strings "strings" -import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" - import io "io" // Reference imports to suppress errors if they are not otherwise used. @@ -32,16 +27,25 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +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"` - LatestBlockHeight int64 `protobuf:"varint,4,req,name=latestBlockHeight" json:"latestBlockHeight"` - LatestBlocktime int64 `protobuf:"varint,5,req,name=latestBlocktime" json:"latestBlocktime"` + 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"` + XXX_unrecognized []byte `json:"-"` } -func (m *ResultStatus) Reset() { *m = ResultStatus{} } -func (*ResultStatus) ProtoMessage() {} +func (m *ResultStatus) Reset() { *m = ResultStatus{} } +func (m *ResultStatus) String() string { return proto.CompactTextString(m) } +func (*ResultStatus) ProtoMessage() {} +func (*ResultStatus) Descriptor() ([]byte, []int) { return fileDescriptorTest, []int{0} } func (m *ResultStatus) GetNodeInfo() *NodeInfo { if m != nil { @@ -65,70 +69,73 @@ func (m *ResultStatus) GetLatestBlockHash() []byte { } func (m *ResultStatus) GetLatestBlockHeight() int64 { - if m != nil { - return m.LatestBlockHeight + if m != nil && m.LatestBlockHeight != nil { + return *m.LatestBlockHeight } return 0 } func (m *ResultStatus) GetLatestBlocktime() int64 { - if m != nil { - return m.LatestBlocktime + if m != nil && m.LatestBlocktime != nil { + return *m.LatestBlocktime } return 0 } type NodeInfo struct { - PubKey *PubKey `protobuf:"bytes,1,req,name=pubKey" json:"pubKey,omitempty"` - 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,omitempty"` + 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"` + XXX_unrecognized []byte `json:"-"` } -func (m *NodeInfo) Reset() { *m = NodeInfo{} } -func (*NodeInfo) ProtoMessage() {} +func (m *NodeInfo) Reset() { *m = NodeInfo{} } +func (m *NodeInfo) String() string { return proto.CompactTextString(m) } +func (*NodeInfo) ProtoMessage() {} +func (*NodeInfo) Descriptor() ([]byte, []int) { return fileDescriptorTest, []int{1} } -func (m *NodeInfo) GetPubKey() *PubKey { +func (m *NodeInfo) GetId() *ID { if m != nil { - return m.PubKey + return m.Id } return nil } func (m *NodeInfo) GetMoniker() string { - if m != nil { - return m.Moniker + if m != nil && m.Moniker != nil { + return *m.Moniker } return "" } func (m *NodeInfo) GetNetwork() string { - if m != nil { - return m.Network + if m != nil && m.Network != nil { + return *m.Network } return "" } func (m *NodeInfo) GetRemoteAddr() string { - if m != nil { - return m.RemoteAddr + if m != nil && m.RemoteAddr != nil { + return *m.RemoteAddr } return "" } func (m *NodeInfo) GetListenAddr() string { - if m != nil { - return m.ListenAddr + if m != nil && m.ListenAddr != nil { + return *m.ListenAddr } return "" } func (m *NodeInfo) GetVersion() string { - if m != nil { - return m.Version + if m != nil && m.Version != nil { + return *m.Version } return "" } @@ -140,12 +147,32 @@ func (m *NodeInfo) GetOther() []string { return nil } +type ID struct { + Id *string `protobuf:"bytes,1,req,name=id" json:"id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ID) Reset() { *m = ID{} } +func (m *ID) String() string { return proto.CompactTextString(m) } +func (*ID) ProtoMessage() {} +func (*ID) Descriptor() ([]byte, []int) { return fileDescriptorTest, []int{2} } + +func (m *ID) GetId() string { + if m != nil && m.Id != nil { + return *m.Id + } + return "" +} + type PubKey struct { - Ed25519 *PubKeyEd25519 `protobuf:"bytes,1,opt,name=ed25519" json:"ed25519,omitempty"` + Ed25519 *PubKeyEd25519 `protobuf:"bytes,1,opt,name=ed25519" json:"ed25519,omitempty"` + XXX_unrecognized []byte `json:"-"` } -func (m *PubKey) Reset() { *m = PubKey{} } -func (*PubKey) ProtoMessage() {} +func (m *PubKey) Reset() { *m = PubKey{} } +func (m *PubKey) String() string { return proto.CompactTextString(m) } +func (*PubKey) ProtoMessage() {} +func (*PubKey) Descriptor() ([]byte, []int) { return fileDescriptorTest, []int{3} } func (m *PubKey) GetEd25519() *PubKeyEd25519 { if m != nil { @@ -155,11 +182,14 @@ func (m *PubKey) GetEd25519() *PubKeyEd25519 { } type PubKeyEd25519 struct { - Bytes []byte `protobuf:"bytes,1,req,name=bytes" json:"bytes"` + Bytes []byte `protobuf:"bytes,1,req,name=bytes" json:"bytes,omitempty"` + XXX_unrecognized []byte `json:"-"` } -func (m *PubKeyEd25519) Reset() { *m = PubKeyEd25519{} } -func (*PubKeyEd25519) ProtoMessage() {} +func (m *PubKeyEd25519) Reset() { *m = PubKeyEd25519{} } +func (m *PubKeyEd25519) String() string { return proto.CompactTextString(m) } +func (*PubKeyEd25519) ProtoMessage() {} +func (*PubKeyEd25519) Descriptor() ([]byte, []int) { return fileDescriptorTest, []int{4} } func (m *PubKeyEd25519) GetBytes() []byte { if m != nil { @@ -171,400 +201,259 @@ func (m *PubKeyEd25519) GetBytes() []byte { func init() { proto.RegisterType((*ResultStatus)(nil), "ResultStatus") proto.RegisterType((*NodeInfo)(nil), "NodeInfo") + proto.RegisterType((*ID)(nil), "ID") proto.RegisterType((*PubKey)(nil), "PubKey") proto.RegisterType((*PubKeyEd25519)(nil), "PubKeyEd25519") } -func (this *ResultStatus) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*ResultStatus) - if !ok { - that2, ok := that.(ResultStatus) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.NodeInfo.Equal(that1.NodeInfo) { - return false - } - if !this.PubKey.Equal(that1.PubKey) { - return false - } - if !bytes.Equal(this.LatestBlockHash, that1.LatestBlockHash) { - return false - } - if this.LatestBlockHeight != that1.LatestBlockHeight { - return false - } - if this.LatestBlocktime != that1.LatestBlocktime { - return false - } - return true -} -func (this *NodeInfo) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*NodeInfo) - if !ok { - that2, ok := that.(NodeInfo) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.PubKey.Equal(that1.PubKey) { - return false - } - if this.Moniker != that1.Moniker { - return false - } - if this.Network != that1.Network { - return false - } - if this.RemoteAddr != that1.RemoteAddr { - return false - } - if this.ListenAddr != that1.ListenAddr { - return false - } - if this.Version != that1.Version { - return false - } - if len(this.Other) != len(that1.Other) { - return false - } - for i := range this.Other { - if this.Other[i] != that1.Other[i] { - return false - } - } - return true -} -func (this *PubKey) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*PubKey) - if !ok { - that2, ok := that.(PubKey) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.Ed25519.Equal(that1.Ed25519) { - return false - } - return true -} -func (this *PubKeyEd25519) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*PubKeyEd25519) - if !ok { - that2, ok := that.(PubKeyEd25519) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !bytes.Equal(this.Bytes, that1.Bytes) { - return false - } - return true -} -func (this *ResultStatus) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 9) - s = append(s, "&test.ResultStatus{") - if this.NodeInfo != nil { - s = append(s, "NodeInfo: "+fmt.Sprintf("%#v", this.NodeInfo)+",\n") - } - if this.PubKey != nil { - s = append(s, "PubKey: "+fmt.Sprintf("%#v", this.PubKey)+",\n") - } - s = append(s, "LatestBlockHash: "+fmt.Sprintf("%#v", this.LatestBlockHash)+",\n") - s = append(s, "LatestBlockHeight: "+fmt.Sprintf("%#v", this.LatestBlockHeight)+",\n") - s = append(s, "LatestBlocktime: "+fmt.Sprintf("%#v", this.LatestBlocktime)+",\n") - s = append(s, "}") - return strings.Join(s, "") -} -func (this *NodeInfo) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 11) - s = append(s, "&test.NodeInfo{") - if this.PubKey != nil { - s = append(s, "PubKey: "+fmt.Sprintf("%#v", this.PubKey)+",\n") - } - s = append(s, "Moniker: "+fmt.Sprintf("%#v", this.Moniker)+",\n") - s = append(s, "Network: "+fmt.Sprintf("%#v", this.Network)+",\n") - s = append(s, "RemoteAddr: "+fmt.Sprintf("%#v", this.RemoteAddr)+",\n") - s = append(s, "ListenAddr: "+fmt.Sprintf("%#v", this.ListenAddr)+",\n") - s = append(s, "Version: "+fmt.Sprintf("%#v", this.Version)+",\n") - if this.Other != nil { - s = append(s, "Other: "+fmt.Sprintf("%#v", this.Other)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *PubKey) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&test.PubKey{") - if this.Ed25519 != nil { - s = append(s, "Ed25519: "+fmt.Sprintf("%#v", this.Ed25519)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *PubKeyEd25519) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&test.PubKeyEd25519{") - s = append(s, "Bytes: "+fmt.Sprintf("%#v", this.Bytes)+",\n") - s = append(s, "}") - return strings.Join(s, "") -} -func (m *ResultStatus) Marshal() (data []byte, err error) { +func (m *ResultStatus) Marshal() (dAtA []byte, err error) { size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } - return data[:n], nil + return dAtA[:n], nil } -func (m *ResultStatus) MarshalTo(data []byte) (int, error) { +func (m *ResultStatus) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l if m.NodeInfo != nil { - data[i] = 0xa + dAtA[i] = 0xa i++ - i = encodeVarintTest(data, i, uint64(m.NodeInfo.Size())) - n1, err := m.NodeInfo.MarshalTo(data[i:]) + i = encodeVarintTest(dAtA, i, uint64(m.NodeInfo.Size())) + n1, err := m.NodeInfo.MarshalTo(dAtA[i:]) if err != nil { return 0, err } i += n1 } if m.PubKey == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("pubKey") + return 0, proto.NewRequiredNotSetError("pubKey") } else { - data[i] = 0x12 + dAtA[i] = 0x12 i++ - i = encodeVarintTest(data, i, uint64(m.PubKey.Size())) - n2, err := m.PubKey.MarshalTo(data[i:]) + i = encodeVarintTest(dAtA, i, uint64(m.PubKey.Size())) + n2, err := m.PubKey.MarshalTo(dAtA[i:]) if err != nil { return 0, err } i += n2 } - if m.LatestBlockHash != nil { - data[i] = 0x1a + if m.LatestBlockHash == nil { + return 0, proto.NewRequiredNotSetError("latestBlockHash") + } else { + dAtA[i] = 0x1a i++ - i = encodeVarintTest(data, i, uint64(len(m.LatestBlockHash))) - i += copy(data[i:], m.LatestBlockHash) - } - data[i] = 0x20 - i++ - i = encodeVarintTest(data, i, uint64(m.LatestBlockHeight)) - data[i] = 0x28 - i++ - i = encodeVarintTest(data, i, uint64(m.LatestBlocktime)) + i = encodeVarintTest(dAtA, i, uint64(len(m.LatestBlockHash))) + i += copy(dAtA[i:], m.LatestBlockHash) + } + if m.LatestBlockHeight == nil { + return 0, proto.NewRequiredNotSetError("latestBlockHeight") + } else { + dAtA[i] = 0x20 + i++ + i = encodeVarintTest(dAtA, i, uint64(*m.LatestBlockHeight)) + } + if m.LatestBlocktime == nil { + return 0, proto.NewRequiredNotSetError("latestBlocktime") + } else { + dAtA[i] = 0x28 + i++ + i = encodeVarintTest(dAtA, i, uint64(*m.LatestBlocktime)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } return i, nil } -func (m *NodeInfo) Marshal() (data []byte, err error) { +func (m *NodeInfo) Marshal() (dAtA []byte, err error) { size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } - return data[:n], nil + return dAtA[:n], nil } -func (m *NodeInfo) MarshalTo(data []byte) (int, error) { +func (m *NodeInfo) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - if m.PubKey == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("pubKey") + if m.Id == nil { + return 0, proto.NewRequiredNotSetError("id") } else { - data[i] = 0xa + dAtA[i] = 0xa i++ - i = encodeVarintTest(data, i, uint64(m.PubKey.Size())) - n3, err := m.PubKey.MarshalTo(data[i:]) + i = encodeVarintTest(dAtA, i, uint64(m.Id.Size())) + n3, err := m.Id.MarshalTo(dAtA[i:]) if err != nil { return 0, err } i += n3 } - data[i] = 0x12 - i++ - i = encodeVarintTest(data, i, uint64(len(m.Moniker))) - i += copy(data[i:], m.Moniker) - data[i] = 0x1a - i++ - i = encodeVarintTest(data, i, uint64(len(m.Network))) - i += copy(data[i:], m.Network) - data[i] = 0x22 - i++ - i = encodeVarintTest(data, i, uint64(len(m.RemoteAddr))) - i += copy(data[i:], m.RemoteAddr) - data[i] = 0x2a - i++ - i = encodeVarintTest(data, i, uint64(len(m.ListenAddr))) - i += copy(data[i:], m.ListenAddr) - data[i] = 0x32 - i++ - i = encodeVarintTest(data, i, uint64(len(m.Version))) - i += copy(data[i:], m.Version) + if m.Moniker == nil { + return 0, proto.NewRequiredNotSetError("moniker") + } else { + dAtA[i] = 0x12 + i++ + i = encodeVarintTest(dAtA, i, uint64(len(*m.Moniker))) + i += copy(dAtA[i:], *m.Moniker) + } + if m.Network == nil { + return 0, proto.NewRequiredNotSetError("network") + } else { + dAtA[i] = 0x1a + i++ + i = encodeVarintTest(dAtA, i, uint64(len(*m.Network))) + i += copy(dAtA[i:], *m.Network) + } + if m.RemoteAddr == nil { + return 0, proto.NewRequiredNotSetError("remoteAddr") + } else { + dAtA[i] = 0x22 + i++ + i = encodeVarintTest(dAtA, i, uint64(len(*m.RemoteAddr))) + i += copy(dAtA[i:], *m.RemoteAddr) + } + if m.ListenAddr == nil { + return 0, proto.NewRequiredNotSetError("listenAddr") + } else { + dAtA[i] = 0x2a + i++ + i = encodeVarintTest(dAtA, i, uint64(len(*m.ListenAddr))) + i += copy(dAtA[i:], *m.ListenAddr) + } + if m.Version == nil { + return 0, proto.NewRequiredNotSetError("version") + } else { + dAtA[i] = 0x32 + i++ + i = encodeVarintTest(dAtA, i, uint64(len(*m.Version))) + i += copy(dAtA[i:], *m.Version) + } if len(m.Other) > 0 { for _, s := range m.Other { - data[i] = 0x3a + dAtA[i] = 0x3a i++ l = len(s) for l >= 1<<7 { - data[i] = uint8(uint64(l)&0x7f | 0x80) + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) l >>= 7 i++ } - data[i] = uint8(l) + dAtA[i] = uint8(l) i++ - i += copy(data[i:], s) + i += copy(dAtA[i:], s) } } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } return i, nil } -func (m *PubKey) Marshal() (data []byte, err error) { +func (m *ID) Marshal() (dAtA []byte, err error) { size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } - return data[:n], nil + return dAtA[:n], nil } -func (m *PubKey) MarshalTo(data []byte) (int, error) { +func (m *ID) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Id == nil { + return 0, proto.NewRequiredNotSetError("id") + } else { + dAtA[i] = 0xa + i++ + i = encodeVarintTest(dAtA, i, uint64(len(*m.Id))) + i += copy(dAtA[i:], *m.Id) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *PubKey) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PubKey) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l if m.Ed25519 != nil { - data[i] = 0xa + dAtA[i] = 0xa i++ - i = encodeVarintTest(data, i, uint64(m.Ed25519.Size())) - n4, err := m.Ed25519.MarshalTo(data[i:]) + i = encodeVarintTest(dAtA, i, uint64(m.Ed25519.Size())) + n4, err := m.Ed25519.MarshalTo(dAtA[i:]) if err != nil { return 0, err } i += n4 } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } return i, nil } -func (m *PubKeyEd25519) Marshal() (data []byte, err error) { +func (m *PubKeyEd25519) Marshal() (dAtA []byte, err error) { size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) if err != nil { return nil, err } - return data[:n], nil + return dAtA[:n], nil } -func (m *PubKeyEd25519) MarshalTo(data []byte) (int, error) { +func (m *PubKeyEd25519) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - if m.Bytes != nil { - data[i] = 0xa + if m.Bytes == nil { + return 0, proto.NewRequiredNotSetError("bytes") + } else { + dAtA[i] = 0xa i++ - i = encodeVarintTest(data, i, uint64(len(m.Bytes))) - i += copy(data[i:], m.Bytes) + i = encodeVarintTest(dAtA, i, uint64(len(m.Bytes))) + i += copy(dAtA[i:], m.Bytes) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) } return i, nil } -func encodeVarintTest(data []byte, offset int, v uint64) int { +func encodeVarintTest(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { - data[offset] = uint8(v&0x7f | 0x80) + dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } - data[offset] = uint8(v) + dAtA[offset] = uint8(v) return offset + 1 } func (m *ResultStatus) Size() (n int) { @@ -582,34 +471,67 @@ func (m *ResultStatus) Size() (n int) { l = len(m.LatestBlockHash) n += 1 + l + sovTest(uint64(l)) } - n += 1 + sovTest(uint64(m.LatestBlockHeight)) - n += 1 + sovTest(uint64(m.LatestBlocktime)) + if m.LatestBlockHeight != nil { + n += 1 + sovTest(uint64(*m.LatestBlockHeight)) + } + if m.LatestBlocktime != nil { + n += 1 + sovTest(uint64(*m.LatestBlocktime)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } return n } func (m *NodeInfo) Size() (n int) { var l int _ = l - if m.PubKey != nil { - l = m.PubKey.Size() + if m.Id != nil { + l = m.Id.Size() + n += 1 + l + sovTest(uint64(l)) + } + if m.Moniker != nil { + l = len(*m.Moniker) + n += 1 + l + sovTest(uint64(l)) + } + if m.Network != nil { + l = len(*m.Network) + n += 1 + l + sovTest(uint64(l)) + } + if m.RemoteAddr != nil { + l = len(*m.RemoteAddr) + n += 1 + l + sovTest(uint64(l)) + } + if m.ListenAddr != nil { + l = len(*m.ListenAddr) + n += 1 + l + sovTest(uint64(l)) + } + if m.Version != nil { + l = len(*m.Version) n += 1 + l + sovTest(uint64(l)) } - l = len(m.Moniker) - n += 1 + l + sovTest(uint64(l)) - l = len(m.Network) - n += 1 + l + sovTest(uint64(l)) - l = len(m.RemoteAddr) - n += 1 + l + sovTest(uint64(l)) - l = len(m.ListenAddr) - n += 1 + l + sovTest(uint64(l)) - l = len(m.Version) - n += 1 + l + sovTest(uint64(l)) if len(m.Other) > 0 { for _, s := range m.Other { l = len(s) n += 1 + l + sovTest(uint64(l)) } } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ID) Size() (n int) { + var l int + _ = l + if m.Id != nil { + l = len(*m.Id) + n += 1 + l + sovTest(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } return n } @@ -620,6 +542,9 @@ func (m *PubKey) Size() (n int) { l = m.Ed25519.Size() n += 1 + l + sovTest(uint64(l)) } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } return n } @@ -630,6 +555,9 @@ func (m *PubKeyEd25519) Size() (n int) { l = len(m.Bytes) n += 1 + l + sovTest(uint64(l)) } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } return n } @@ -643,59 +571,10 @@ func sovTest(x uint64) (n int) { } return n } -func (this *ResultStatus) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&ResultStatus{`, - `NodeInfo:` + strings.Replace(fmt.Sprintf("%v", this.NodeInfo), "NodeInfo", "NodeInfo", 1) + `,`, - `PubKey:` + strings.Replace(fmt.Sprintf("%v", this.PubKey), "PubKey", "PubKey", 1) + `,`, - `LatestBlockHash:` + fmt.Sprintf("%v", this.LatestBlockHash) + `,`, - `LatestBlockHeight:` + fmt.Sprintf("%v", this.LatestBlockHeight) + `,`, - `LatestBlocktime:` + fmt.Sprintf("%v", this.LatestBlocktime) + `,`, - `}`, - }, "") - return s -} -func (this *NodeInfo) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&NodeInfo{`, - `PubKey:` + strings.Replace(fmt.Sprintf("%v", this.PubKey), "PubKey", "PubKey", 1) + `,`, - `Moniker:` + fmt.Sprintf("%v", this.Moniker) + `,`, - `Network:` + fmt.Sprintf("%v", this.Network) + `,`, - `RemoteAddr:` + fmt.Sprintf("%v", this.RemoteAddr) + `,`, - `ListenAddr:` + fmt.Sprintf("%v", this.ListenAddr) + `,`, - `Version:` + fmt.Sprintf("%v", this.Version) + `,`, - `Other:` + fmt.Sprintf("%v", this.Other) + `,`, - `}`, - }, "") - return s -} -func (this *PubKey) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PubKey{`, - `Ed25519:` + strings.Replace(fmt.Sprintf("%v", this.Ed25519), "PubKeyEd25519", "PubKeyEd25519", 1) + `,`, - `}`, - }, "") - return s -} -func (this *PubKeyEd25519) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PubKeyEd25519{`, - `Bytes:` + fmt.Sprintf("%v", this.Bytes) + `,`, - `}`, - }, "") - return s -} -func (m *ResultStatus) Unmarshal(data []byte) error { + +func (m *ResultStatus) Unmarshal(dAtA []byte) error { var hasFields [1]uint64 - l := len(data) + l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx @@ -707,7 +586,7 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -735,7 +614,7 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ msglen |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -752,7 +631,7 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if m.NodeInfo == nil { m.NodeInfo = &NodeInfo{} } - if err := m.NodeInfo.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.NodeInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -768,7 +647,7 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ msglen |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -785,7 +664,7 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if m.PubKey == nil { m.PubKey = &PubKey{} } - if err := m.PubKey.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -802,7 +681,7 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -816,14 +695,17 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LatestBlockHash = append([]byte{}, data[iNdEx:postIndex]...) + m.LatestBlockHash = append(m.LatestBlockHash[:0], dAtA[iNdEx:postIndex]...) + if m.LatestBlockHash == nil { + m.LatestBlockHash = []byte{} + } iNdEx = postIndex hasFields[0] |= uint64(0x00000002) case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LatestBlockHeight", wireType) } - m.LatestBlockHeight = 0 + var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTest @@ -831,19 +713,20 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ - m.LatestBlockHeight |= (int64(b) & 0x7F) << shift + v |= (int64(b) & 0x7F) << shift if b < 0x80 { break } } + m.LatestBlockHeight = &v hasFields[0] |= uint64(0x00000004) case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LatestBlocktime", wireType) } - m.LatestBlocktime = 0 + var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTest @@ -851,17 +734,18 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ - m.LatestBlocktime |= (int64(b) & 0x7F) << shift + v |= (int64(b) & 0x7F) << shift if b < 0x80 { break } } + m.LatestBlocktime = &v hasFields[0] |= uint64(0x00000008) default: iNdEx = preIndex - skippy, err := skipTest(data[iNdEx:]) + skippy, err := skipTest(dAtA[iNdEx:]) if err != nil { return err } @@ -871,20 +755,21 @@ func (m *ResultStatus) Unmarshal(data []byte) error { if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("pubKey") + return proto.NewRequiredNotSetError("pubKey") } if hasFields[0]&uint64(0x00000002) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("latestBlockHash") + return proto.NewRequiredNotSetError("latestBlockHash") } if hasFields[0]&uint64(0x00000004) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("latestBlockHeight") + return proto.NewRequiredNotSetError("latestBlockHeight") } if hasFields[0]&uint64(0x00000008) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("latestBlocktime") + return proto.NewRequiredNotSetError("latestBlocktime") } if iNdEx > l { @@ -892,9 +777,9 @@ func (m *ResultStatus) Unmarshal(data []byte) error { } return nil } -func (m *NodeInfo) Unmarshal(data []byte) error { +func (m *NodeInfo) Unmarshal(dAtA []byte) error { var hasFields [1]uint64 - l := len(data) + l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx @@ -906,7 +791,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -924,7 +809,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -934,7 +819,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ msglen |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -948,10 +833,10 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PubKey == nil { - m.PubKey = &PubKey{} + if m.Id == nil { + m.Id = &ID{} } - if err := m.PubKey.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -968,7 +853,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -983,7 +868,8 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Moniker = string(data[iNdEx:postIndex]) + s := string(dAtA[iNdEx:postIndex]) + m.Moniker = &s iNdEx = postIndex hasFields[0] |= uint64(0x00000002) case 3: @@ -998,7 +884,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1013,7 +899,8 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Network = string(data[iNdEx:postIndex]) + s := string(dAtA[iNdEx:postIndex]) + m.Network = &s iNdEx = postIndex hasFields[0] |= uint64(0x00000004) case 4: @@ -1028,7 +915,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1043,7 +930,8 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RemoteAddr = string(data[iNdEx:postIndex]) + s := string(dAtA[iNdEx:postIndex]) + m.RemoteAddr = &s iNdEx = postIndex hasFields[0] |= uint64(0x00000008) case 5: @@ -1058,7 +946,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1073,7 +961,8 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ListenAddr = string(data[iNdEx:postIndex]) + s := string(dAtA[iNdEx:postIndex]) + m.ListenAddr = &s iNdEx = postIndex hasFields[0] |= uint64(0x00000010) case 6: @@ -1088,7 +977,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1103,7 +992,8 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Version = string(data[iNdEx:postIndex]) + s := string(dAtA[iNdEx:postIndex]) + m.Version = &s iNdEx = postIndex hasFields[0] |= uint64(0x00000020) case 7: @@ -1118,7 +1008,7 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1133,11 +1023,11 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Other = append(m.Other, string(data[iNdEx:postIndex])) + m.Other = append(m.Other, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipTest(data[iNdEx:]) + skippy, err := skipTest(dAtA[iNdEx:]) if err != nil { return err } @@ -1147,26 +1037,113 @@ func (m *NodeInfo) Unmarshal(data []byte) error { if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("pubKey") + return proto.NewRequiredNotSetError("id") } if hasFields[0]&uint64(0x00000002) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("moniker") + return proto.NewRequiredNotSetError("moniker") } if hasFields[0]&uint64(0x00000004) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("network") + return proto.NewRequiredNotSetError("network") } if hasFields[0]&uint64(0x00000008) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("remoteAddr") + return proto.NewRequiredNotSetError("remoteAddr") } if hasFields[0]&uint64(0x00000010) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("listenAddr") + return proto.NewRequiredNotSetError("listenAddr") } if hasFields[0]&uint64(0x00000020) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("version") + return proto.NewRequiredNotSetError("version") + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ID) Unmarshal(dAtA []byte) error { + var hasFields [1]uint64 + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTest + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTest + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + s := string(dAtA[iNdEx:postIndex]) + m.Id = &s + iNdEx = postIndex + hasFields[0] |= uint64(0x00000001) + default: + iNdEx = preIndex + skippy, err := skipTest(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTest + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + if hasFields[0]&uint64(0x00000001) == 0 { + return proto.NewRequiredNotSetError("id") } if iNdEx > l { @@ -1174,8 +1151,8 @@ func (m *NodeInfo) Unmarshal(data []byte) error { } return nil } -func (m *PubKey) Unmarshal(data []byte) error { - l := len(data) +func (m *PubKey) Unmarshal(dAtA []byte) error { + l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx @@ -1187,7 +1164,7 @@ func (m *PubKey) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1215,7 +1192,7 @@ func (m *PubKey) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ msglen |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -1232,13 +1209,13 @@ func (m *PubKey) Unmarshal(data []byte) error { if m.Ed25519 == nil { m.Ed25519 = &PubKeyEd25519{} } - if err := m.Ed25519.Unmarshal(data[iNdEx:postIndex]); err != nil { + if err := m.Ed25519.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipTest(data[iNdEx:]) + skippy, err := skipTest(dAtA[iNdEx:]) if err != nil { return err } @@ -1248,6 +1225,7 @@ func (m *PubKey) Unmarshal(data []byte) error { if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } @@ -1257,9 +1235,9 @@ func (m *PubKey) Unmarshal(data []byte) error { } return nil } -func (m *PubKeyEd25519) Unmarshal(data []byte) error { +func (m *PubKeyEd25519) Unmarshal(dAtA []byte) error { var hasFields [1]uint64 - l := len(data) + l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx @@ -1271,7 +1249,7 @@ func (m *PubKeyEd25519) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1299,7 +1277,7 @@ func (m *PubKeyEd25519) Unmarshal(data []byte) error { if iNdEx >= l { return io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ byteLen |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -1313,12 +1291,15 @@ func (m *PubKeyEd25519) Unmarshal(data []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Bytes = append([]byte{}, data[iNdEx:postIndex]...) + m.Bytes = append(m.Bytes[:0], dAtA[iNdEx:postIndex]...) + if m.Bytes == nil { + m.Bytes = []byte{} + } iNdEx = postIndex hasFields[0] |= uint64(0x00000001) default: iNdEx = preIndex - skippy, err := skipTest(data[iNdEx:]) + skippy, err := skipTest(dAtA[iNdEx:]) if err != nil { return err } @@ -1328,11 +1309,12 @@ func (m *PubKeyEd25519) Unmarshal(data []byte) error { if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("bytes") + return proto.NewRequiredNotSetError("bytes") } if iNdEx > l { @@ -1340,8 +1322,8 @@ func (m *PubKeyEd25519) Unmarshal(data []byte) error { } return nil } -func skipTest(data []byte) (n int, err error) { - l := len(data) +func skipTest(dAtA []byte) (n int, err error) { + l := len(dAtA) iNdEx := 0 for iNdEx < l { var wire uint64 @@ -1352,7 +1334,7 @@ func skipTest(data []byte) (n int, err error) { if iNdEx >= l { return 0, io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1370,7 +1352,7 @@ func skipTest(data []byte) (n int, err error) { return 0, io.ErrUnexpectedEOF } iNdEx++ - if data[iNdEx-1] < 0x80 { + if dAtA[iNdEx-1] < 0x80 { break } } @@ -1387,7 +1369,7 @@ func skipTest(data []byte) (n int, err error) { if iNdEx >= l { return 0, io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ length |= (int(b) & 0x7F) << shift if b < 0x80 { @@ -1410,7 +1392,7 @@ func skipTest(data []byte) (n int, err error) { if iNdEx >= l { return 0, io.ErrUnexpectedEOF } - b := data[iNdEx] + b := dAtA[iNdEx] iNdEx++ innerWire |= (uint64(b) & 0x7F) << shift if b < 0x80 { @@ -1421,7 +1403,7 @@ func skipTest(data []byte) (n int, err error) { if innerWireType == 4 { break } - next, err := skipTest(data[start:]) + next, err := skipTest(dAtA[start:]) if err != nil { return 0, err } @@ -1444,3 +1426,31 @@ var ( ErrInvalidLengthTest = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTest = fmt.Errorf("proto: integer overflow") ) + +func init() { proto.RegisterFile("test.proto", fileDescriptorTest) } + +var fileDescriptorTest = []byte{ + // 342 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0x41, 0x4b, 0xf3, 0x30, + 0x1c, 0xc6, 0x49, 0xfb, 0x6e, 0x5d, 0xff, 0xeb, 0x3b, 0x31, 0xee, 0x90, 0x53, 0x2d, 0x85, 0x41, + 0x0f, 0x52, 0xb0, 0xb0, 0x83, 0x47, 0xc7, 0x04, 0x87, 0x20, 0x23, 0x7e, 0x82, 0xcd, 0xfe, 0x75, + 0x65, 0x5d, 0x33, 0x92, 0x4c, 0xd9, 0xe7, 0xf3, 0xe2, 0xd1, 0xa3, 0x47, 0xd9, 0x27, 0x91, 0xa6, + 0xed, 0x9c, 0xf3, 0xf8, 0xfc, 0x7e, 0xe5, 0xc9, 0xd3, 0x04, 0x40, 0xa3, 0xd2, 0xf1, 0x5a, 0x0a, + 0x2d, 0xc2, 0x4f, 0x02, 0x1e, 0x47, 0xb5, 0xc9, 0xf5, 0x83, 0x9e, 0xe9, 0x8d, 0xa2, 0x03, 0xe8, + 0x14, 0x22, 0xc5, 0x49, 0xf1, 0x24, 0x18, 0x09, 0x48, 0xd4, 0x4d, 0xdc, 0xf8, 0xbe, 0x06, 0x7c, + 0xaf, 0xe8, 0x39, 0xb4, 0xd7, 0x9b, 0xf9, 0x1d, 0x6e, 0x99, 0x15, 0x58, 0x51, 0x37, 0x71, 0xe2, + 0xa9, 0x89, 0xbc, 0xc6, 0x34, 0x82, 0x93, 0x7c, 0x56, 0x1e, 0x34, 0xca, 0xc5, 0xe3, 0xf2, 0x76, + 0xa6, 0x16, 0xcc, 0x0e, 0xac, 0xc8, 0xe3, 0xc7, 0x98, 0x5e, 0xc0, 0xe9, 0x21, 0xc2, 0xec, 0x79, + 0xa1, 0xd9, 0xbf, 0xc0, 0x8a, 0x6c, 0xfe, 0x57, 0x1c, 0xf5, 0xea, 0x6c, 0x85, 0xac, 0x65, 0xbe, + 0x3d, 0xc6, 0xe1, 0x1b, 0x81, 0x4e, 0xb3, 0x9c, 0x9e, 0x81, 0x95, 0xa5, 0x8c, 0x98, 0xad, 0x76, + 0x3c, 0x19, 0x73, 0x2b, 0x4b, 0x29, 0x03, 0x67, 0x25, 0x8a, 0x6c, 0x89, 0xd2, 0xfc, 0x85, 0xcb, + 0x9b, 0x58, 0x9a, 0x02, 0xf5, 0xab, 0x90, 0x4b, 0xb3, 0xda, 0xe5, 0x4d, 0xa4, 0x3e, 0x80, 0xc4, + 0x95, 0xd0, 0x78, 0x9d, 0xa6, 0xd2, 0xcc, 0x74, 0xf9, 0x01, 0x29, 0x7d, 0x9e, 0x29, 0x8d, 0x85, + 0xf1, 0xad, 0xca, 0xff, 0x90, 0xb2, 0xf9, 0x05, 0xa5, 0xca, 0x44, 0xc1, 0xda, 0x55, 0x73, 0x1d, + 0x69, 0x1f, 0x5a, 0x42, 0x2f, 0x50, 0x32, 0x27, 0xb0, 0x23, 0x97, 0x57, 0x21, 0xec, 0x83, 0x35, + 0x19, 0xd3, 0xde, 0x7e, 0xbe, 0x5b, 0x2e, 0x0f, 0x13, 0x68, 0x4f, 0x9b, 0x7b, 0x76, 0x30, 0x4d, + 0x86, 0xc3, 0xcb, 0xab, 0xfa, 0xb9, 0x7a, 0xf5, 0x4b, 0xdc, 0x54, 0x94, 0x37, 0x3a, 0x1c, 0xc0, + 0xff, 0x5f, 0xa6, 0x3c, 0x70, 0xbe, 0xd5, 0xa8, 0x4c, 0xaf, 0xc7, 0xab, 0x30, 0xf2, 0xde, 0x77, + 0x3e, 0xf9, 0xd8, 0xf9, 0xe4, 0x6b, 0xe7, 0x93, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xee, + 0x6b, 0xdd, 0x2c, 0x02, 0x00, 0x00, +} diff --git a/benchmarks/proto/test.proto b/benchmarks/proto/test.proto index d1a1c94d7..6d770d98a 100644 --- a/benchmarks/proto/test.proto +++ b/benchmarks/proto/test.proto @@ -7,7 +7,7 @@ message ResultStatus { } message NodeInfo { - required PubKey pubKey = 1; + required ID id = 1; required string moniker = 2; required string network = 3; required string remoteAddr = 4; @@ -16,6 +16,10 @@ message NodeInfo { repeated string other = 7; } +message ID { + required string id = 1; +} + message PubKey { optional PubKeyEd25519 ed25519 = 1; } diff --git a/consensus/common_test.go b/consensus/common_test.go index 5e837ea47..4ddd6b8aa 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -395,7 +395,7 @@ func randConsensusNetWithPeers(nValidators, nPeers int, testName string, tickerF func getSwitchIndex(switches []*p2p.Switch, peer p2p.Peer) int { for i, s := range switches { - if bytes.Equal(peer.NodeInfo().PubKey.Address(), s.NodeInfo().PubKey.Address()) { + if peer.NodeInfo().ID == s.NodeInfo().ID { return i } } diff --git a/docs/how-to-read-logs.rst b/docs/how-to-read-logs.rst index c5a352d72..e0c3f1b4f 100644 --- a/docs/how-to-read-logs.rst +++ b/docs/how-to-read-logs.rst @@ -59,7 +59,7 @@ Next we replay all the messages from the WAL. :: I[10-04|13:54:30.391] Starting RPC HTTP server on tcp socket 0.0.0.0:46657 module=rpc-server - I[10-04|13:54:30.392] Started node module=main nodeInfo="NodeInfo{pk: PubKeyEd25519{DF22D7C92C91082324A1312F092AA1DA197FA598DBBFB6526E177003C4D6FD66}, moniker: anonymous, network: test-chain-3MNw2N [remote , listen 10.0.2.15:46656], version: 0.11.0-10f361fc ([wire_version=0.6.2 p2p_version=0.5.0 consensus_version=v1/0.2.2 rpc_version=0.7.0/3 tx_index=on rpc_addr=tcp://0.0.0.0:46657])}" + I[10-04|13:54:30.392] Started node module=main nodeInfo="NodeInfo{id: DF22D7C92C91082324A1312F092AA1DA197FA598DBBFB6526E, moniker: anonymous, network: test-chain-3MNw2N [remote , listen 10.0.2.15:46656], version: 0.11.0-10f361fc ([wire_version=0.6.2 p2p_version=0.5.0 consensus_version=v1/0.2.2 rpc_version=0.7.0/3 tx_index=on rpc_addr=tcp://0.0.0.0:46657])}" Next follows a standard block creation cycle, where we enter a new round, propose a block, receive more than 2/3 of prevotes, then precommits and finally diff --git a/docs/specification/new-spec/p2p/peer.md b/docs/specification/new-spec/p2p/peer.md index 68615c498..6aa36af79 100644 --- a/docs/specification/new-spec/p2p/peer.md +++ b/docs/specification/new-spec/p2p/peer.md @@ -83,7 +83,7 @@ The Tendermint Version Handshake allows the peers to exchange their NodeInfo: ```golang type NodeInfo struct { - PubKey crypto.PubKey + ID p2p.ID Moniker string Network string RemoteAddr string @@ -95,7 +95,7 @@ type NodeInfo struct { ``` The connection is disconnected if: -- `peer.NodeInfo.PubKey != peer.PubKey` +- `peer.NodeInfo.ID` is not equal `peerConn.ID` - `peer.NodeInfo.Version` is not formatted as `X.X.X` where X are integers known as Major, Minor, and Revision - `peer.NodeInfo.Version` Major is not the same as ours - `peer.NodeInfo.Version` Minor is not the same as ours diff --git a/node/node.go b/node/node.go index 83d27cb48..976066964 100644 --- a/node/node.go +++ b/node/node.go @@ -405,7 +405,7 @@ func (n *Node) OnStart() error { } n.Logger.Info("P2P Node ID", "ID", nodeKey.ID(), "file", n.config.NodeKeyFile()) - nodeInfo := n.makeNodeInfo(nodeKey.PubKey()) + nodeInfo := n.makeNodeInfo(nodeKey.ID()) n.sw.SetNodeInfo(nodeInfo) n.sw.SetNodeKey(nodeKey) @@ -579,13 +579,13 @@ func (n *Node) ProxyApp() proxy.AppConns { return n.proxyApp } -func (n *Node) makeNodeInfo(pubKey crypto.PubKey) p2p.NodeInfo { +func (n *Node) makeNodeInfo(nodeID p2p.ID) p2p.NodeInfo { txIndexerStatus := "on" if _, ok := n.txIndexer.(*null.TxIndex); ok { txIndexerStatus = "off" } nodeInfo := p2p.NodeInfo{ - PubKey: pubKey, + ID: nodeID, Network: n.genesisDoc.ChainID, Version: version.Version, Channels: []byte{ diff --git a/p2p/node_info.go b/p2p/node_info.go index 346de37d3..930f9bfea 100644 --- a/p2p/node_info.go +++ b/p2p/node_info.go @@ -3,8 +3,6 @@ package p2p import ( "fmt" "strings" - - crypto "github.com/tendermint/go-crypto" ) const ( @@ -20,8 +18,8 @@ func MaxNodeInfoSize() int { // between two peers during the Tendermint P2P handshake. type NodeInfo struct { // Authenticate - PubKey crypto.PubKey `json:"pub_key"` // authenticated pubkey - ListenAddr string `json:"listen_addr"` // accepting incoming + ID ID `json:"id"` // authenticated identifier + ListenAddr string `json:"listen_addr"` // accepting incoming // Check compatibility Network string `json:"network"` // network/chain ID @@ -107,19 +105,12 @@ OUTER_LOOP: return nil } -// ID returns node's ID. -func (info NodeInfo) ID() ID { - return PubKeyToID(info.PubKey) -} - // NetAddress returns a NetAddress derived from the NodeInfo - // it includes the authenticated peer ID and the self-reported // ListenAddr. Note that the ListenAddr is not authenticated and // may not match that address actually dialed if its an outbound peer. func (info NodeInfo) NetAddress() *NetAddress { - id := PubKeyToID(info.PubKey) - addr := info.ListenAddr - netAddr, err := NewNetAddressString(IDAddressString(id, addr)) + netAddr, err := NewNetAddressString(IDAddressString(info.ID, info.ListenAddr)) if err != nil { panic(err) // everything should be well formed by now } @@ -127,7 +118,8 @@ func (info NodeInfo) NetAddress() *NetAddress { } func (info NodeInfo) String() string { - return fmt.Sprintf("NodeInfo{pk: %v, moniker: %v, network: %v [listen %v], version: %v (%v)}", info.PubKey, info.Moniker, info.Network, info.ListenAddr, info.Version, info.Other) + return fmt.Sprintf("NodeInfo{id: %v, moniker: %v, network: %v [listen %v], version: %v (%v)}", + info.ID, info.Moniker, info.Network, info.ListenAddr, info.Version, info.Other) } func splitVersion(version string) (string, string, string, error) { diff --git a/p2p/peer.go b/p2p/peer.go index f31a77615..9f3ccbabc 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -202,7 +202,7 @@ func (p *peer) OnStop() { // ID returns the peer's ID - the hex encoded hash of its pubkey. func (p *peer) ID() ID { - return p.nodeInfo.ID() + return p.nodeInfo.ID } // IsOutbound returns true if the connection is outbound, false otherwise. diff --git a/p2p/peer_set_test.go b/p2p/peer_set_test.go index 3041fbe6e..872758355 100644 --- a/p2p/peer_set_test.go +++ b/p2p/peer_set_test.go @@ -13,11 +13,11 @@ import ( // Returns an empty kvstore peer func randPeer() *peer { - pubKey := crypto.GenPrivKeyEd25519().PubKey() + nodeKey := NodeKey{PrivKey: crypto.GenPrivKeyEd25519()} return &peer{ nodeInfo: NodeInfo{ + ID: nodeKey.ID(), ListenAddr: cmn.Fmt("%v.%v.%v.%v:46656", rand.Int()%256, rand.Int()%256, rand.Int()%256, rand.Int()%256), - PubKey: pubKey, }, } } diff --git a/p2p/peer_test.go b/p2p/peer_test.go index ebec00101..24d750a9f 100644 --- a/p2p/peer_test.go +++ b/p2p/peer_test.go @@ -95,7 +95,7 @@ func createOutboundPeerAndPerformHandshake(addr *NetAddress, config *PeerConfig) return nil, err } nodeInfo, err := pc.HandshakeTimeout(NodeInfo{ - PubKey: pk.PubKey(), + ID: addr.ID, Moniker: "host_peer", Network: "testing", Version: "123.123.123", @@ -152,7 +152,7 @@ func (p *remotePeer) accept(l net.Listener) { golog.Fatalf("Failed to create a peer: %+v", err) } _, err = pc.HandshakeTimeout(NodeInfo{ - PubKey: p.PrivKey.PubKey(), + ID: p.Addr().ID, Moniker: "remote_peer", Network: "testing", Version: "123.123.123", diff --git a/p2p/pex/pex_reactor_test.go b/p2p/pex/pex_reactor_test.go index b3f29c5bd..f7297a343 100644 --- a/p2p/pex/pex_reactor_test.go +++ b/p2p/pex/pex_reactor_test.go @@ -289,7 +289,7 @@ func TestPEXReactorCrawlStatus(t *testing.T) { func TestPEXReactorDoesNotAddPrivatePeersToAddrBook(t *testing.T) { peer := p2p.CreateRandomPeer(false) - pexR, book := createReactor(&PEXReactorConfig{PrivatePeerIDs: []string{string(peer.NodeInfo().ID())}}) + pexR, book := createReactor(&PEXReactorConfig{PrivatePeerIDs: []string{string(peer.NodeInfo().ID)}}) defer teardownReactor(book) // we have to send a request to receive responses @@ -356,12 +356,12 @@ func newMockPeer() mockPeer { return mp } -func (mp mockPeer) ID() p2p.ID { return p2p.PubKeyToID(mp.pubKey) } +func (mp mockPeer) ID() p2p.ID { return mp.addr.ID } func (mp mockPeer) IsOutbound() bool { return mp.outbound } func (mp mockPeer) IsPersistent() bool { return mp.persistent } func (mp mockPeer) NodeInfo() p2p.NodeInfo { return p2p.NodeInfo{ - PubKey: mp.pubKey, + ID: mp.addr.ID, ListenAddr: mp.addr.DialString(), } } diff --git a/p2p/switch.go b/p2p/switch.go index 207a4204b..7d7be2fe8 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -515,7 +515,7 @@ func (sw *Switch) addPeer(pc peerConn) error { return err } - peerID := peerNodeInfo.ID() + peerID := peerNodeInfo.ID // ensure connection key matches self reported key if pc.config.AuthEnc { diff --git a/p2p/switch_test.go b/p2p/switch_test.go index c44060c8d..b170ccdc8 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -221,14 +221,14 @@ func TestConnIDFilter(t *testing.T) { c1, c2 := conn.NetPipe() s1.SetIDFilter(func(id ID) error { - if id == PubKeyToID(s2.nodeInfo.PubKey) { + if id == s2.nodeInfo.ID { return fmt.Errorf("Error: pipe is blacklisted") } return nil }) s2.SetIDFilter(func(id ID) error { - if id == PubKeyToID(s1.nodeInfo.PubKey) { + if id == s1.nodeInfo.ID { return fmt.Errorf("Error: pipe is blacklisted") } return nil diff --git a/p2p/test_util.go b/p2p/test_util.go index b5083dced..9b8300a67 100644 --- a/p2p/test_util.go +++ b/p2p/test_util.go @@ -23,8 +23,8 @@ func CreateRandomPeer(outbound bool) *peer { outbound: outbound, }, nodeInfo: NodeInfo{ + ID: netAddr.ID, ListenAddr: netAddr.DialString(), - PubKey: crypto.GenPrivKeyEd25519().PubKey(), }, mconn: &conn.MConnection{}, } @@ -137,7 +137,7 @@ func MakeSwitch(cfg *cfg.P2PConfig, i int, network, version string, initSwitch f sw.SetLogger(log.TestingLogger()) sw = initSwitch(i, sw) ni := NodeInfo{ - PubKey: nodeKey.PubKey(), + ID: nodeKey.ID(), Moniker: cmn.Fmt("switch%d", i), Network: network, Version: version, diff --git a/rpc/core/net.go b/rpc/core/net.go index 1918abf11..9b04926ab 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -43,7 +43,6 @@ func NetInfo() (*ctypes.ResultNetInfo, error) { for _, peer := range p2pSwitch.Peers().List() { peers = append(peers, ctypes.Peer{ NodeInfo: peer.NodeInfo(), - ID: peer.ID(), IsOutbound: peer.IsOutbound(), ConnectionStatus: peer.Status(), }) diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 7a31ec5d8..729f64c06 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -98,7 +98,6 @@ type ResultDialPeers struct { type Peer struct { p2p.NodeInfo `json:"node_info"` - p2p.ID `json:"node_id"` IsOutbound bool `json:"is_outbound"` ConnectionStatus p2p.ConnectionStatus `json:"connection_status"` }