mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-03-14 11:10:05 +08:00
comments for PeerRecord proto message
also removes the seq field from PeerMessage proto, since it was moved to the SignedEnvelope
This commit is contained in:
parent
4b29ab4bbf
commit
1ff557877c
@ -22,9 +22,18 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// PeerRecord messages contain information that is useful to share with other peers.
|
||||
// Currently, a PeerRecord contains the public listen addresses for a peer, but this
|
||||
// is expected to expand to include other information in the future.
|
||||
//
|
||||
// PeerRecords are designed to be serialized to bytes and placed inside of
|
||||
// SignedEnvelopes before sharing with other peers.
|
||||
// See https://github.com/libp2p/go-libp2p-core/record/pb/envelope.proto for
|
||||
// the SignedEnvelope definition.
|
||||
type PeerRecord struct {
|
||||
PeerId []byte `protobuf:"bytes,1,opt,name=peerId,proto3" json:"peerId,omitempty"`
|
||||
Seq uint64 `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"`
|
||||
// peerId contains a libp2p peer id in its binary representation.
|
||||
PeerId []byte `protobuf:"bytes,1,opt,name=peerId,proto3" json:"peerId,omitempty"`
|
||||
// addresses is a list of public listen addresses for the peer.
|
||||
Addresses []*PeerRecord_AddressInfo `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty"`
|
||||
}
|
||||
|
||||
@ -68,13 +77,6 @@ func (m *PeerRecord) GetPeerId() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PeerRecord) GetSeq() uint64 {
|
||||
if m != nil {
|
||||
return m.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PeerRecord) GetAddresses() []*PeerRecord_AddressInfo {
|
||||
if m != nil {
|
||||
return m.Addresses
|
||||
@ -82,6 +84,8 @@ func (m *PeerRecord) GetAddresses() []*PeerRecord_AddressInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddressInfo is a wrapper around a binary multiaddr. It is defined as a
|
||||
// separate message to allow us to add per-address metadata in the future.
|
||||
type PeerRecord_AddressInfo struct {
|
||||
Multiaddr []byte `protobuf:"bytes,1,opt,name=multiaddr,proto3" json:"multiaddr,omitempty"`
|
||||
}
|
||||
@ -134,19 +138,18 @@ func init() {
|
||||
func init() { proto.RegisterFile("peer_record.proto", fileDescriptor_dc0d8059ab0ad14d) }
|
||||
|
||||
var fileDescriptor_dc0d8059ab0ad14d = []byte{
|
||||
// 186 bytes of a gzipped FileDescriptorProto
|
||||
// 170 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x48, 0x4d, 0x2d,
|
||||
0x8a, 0x2f, 0x4a, 0x4d, 0xce, 0x2f, 0x4a, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x07,
|
||||
0x09, 0xe9, 0x15, 0x24, 0x29, 0x2d, 0x62, 0xe4, 0xe2, 0x0a, 0x48, 0x4d, 0x2d, 0x0a, 0x02, 0xcb,
|
||||
0x09, 0xe9, 0x15, 0x24, 0x29, 0x4d, 0x60, 0xe4, 0xe2, 0x0a, 0x48, 0x4d, 0x2d, 0x0a, 0x02, 0xcb,
|
||||
0x0a, 0x89, 0x71, 0xb1, 0x81, 0x64, 0x3c, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0xa0,
|
||||
0x3c, 0x21, 0x01, 0x2e, 0xe6, 0xe2, 0xd4, 0x42, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x96, 0x20, 0x10,
|
||||
0x53, 0xc8, 0x96, 0x8b, 0x33, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x38, 0xb5, 0x58, 0x82, 0x59,
|
||||
0x81, 0x59, 0x83, 0xdb, 0x48, 0x5e, 0x0f, 0x6a, 0xaa, 0x1e, 0xc2, 0x44, 0x3d, 0x47, 0x88, 0x22,
|
||||
0xcf, 0xbc, 0xb4, 0xfc, 0x20, 0x84, 0x0e, 0x29, 0x6d, 0x2e, 0x6e, 0x24, 0x19, 0x21, 0x19, 0x2e,
|
||||
0xce, 0xdc, 0xd2, 0x9c, 0x92, 0x4c, 0x90, 0x02, 0xa8, 0xd5, 0x08, 0x01, 0x27, 0x89, 0x13, 0x8f,
|
||||
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b,
|
||||
0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x48, 0x62, 0x03, 0x7b, 0xc7, 0x18, 0x10, 0x00, 0x00,
|
||||
0xff, 0xff, 0x85, 0x84, 0x12, 0xd0, 0xe3, 0x00, 0x00, 0x00,
|
||||
0x3c, 0x21, 0x5b, 0x2e, 0xce, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0xe2, 0xd4, 0x62, 0x09, 0x66,
|
||||
0x05, 0x66, 0x0d, 0x6e, 0x23, 0x79, 0x3d, 0xa8, 0x19, 0x7a, 0x08, 0xfd, 0x7a, 0x8e, 0x10, 0x45,
|
||||
0x9e, 0x79, 0x69, 0xf9, 0x41, 0x08, 0x1d, 0x52, 0xda, 0x5c, 0xdc, 0x48, 0x32, 0x42, 0x32, 0x5c,
|
||||
0x9c, 0xb9, 0xa5, 0x39, 0x25, 0x99, 0x20, 0x05, 0x50, 0x8b, 0x10, 0x02, 0x4e, 0x12, 0x27, 0x1e,
|
||||
0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17,
|
||||
0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x90, 0xc4, 0x06, 0x76, 0xbc, 0x31, 0x20, 0x00, 0x00,
|
||||
0xff, 0xff, 0x2a, 0x8e, 0x23, 0x44, 0xd1, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *PeerRecord) Marshal() (dAtA []byte, err error) {
|
||||
@ -183,11 +186,6 @@ func (m *PeerRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
}
|
||||
if m.Seq != 0 {
|
||||
i = encodeVarintPeerRecord(dAtA, i, uint64(m.Seq))
|
||||
i--
|
||||
dAtA[i] = 0x10
|
||||
}
|
||||
if len(m.PeerId) > 0 {
|
||||
i -= len(m.PeerId)
|
||||
copy(dAtA[i:], m.PeerId)
|
||||
@ -249,9 +247,6 @@ func (m *PeerRecord) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovPeerRecord(uint64(l))
|
||||
}
|
||||
if m.Seq != 0 {
|
||||
n += 1 + sovPeerRecord(uint64(m.Seq))
|
||||
}
|
||||
if len(m.Addresses) > 0 {
|
||||
for _, e := range m.Addresses {
|
||||
l = e.Size()
|
||||
@ -343,25 +338,6 @@ func (m *PeerRecord) Unmarshal(dAtA []byte) error {
|
||||
m.PeerId = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Seq", wireType)
|
||||
}
|
||||
m.Seq = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowPeerRecord
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Seq |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType)
|
||||
|
@ -1,12 +1,25 @@
|
||||
syntax = "proto3";
|
||||
package peer.pb;
|
||||
|
||||
// PeerRecord messages contain information that is useful to share with other peers.
|
||||
// Currently, a PeerRecord contains the public listen addresses for a peer, but this
|
||||
// is expected to expand to include other information in the future.
|
||||
//
|
||||
// PeerRecords are designed to be serialized to bytes and placed inside of
|
||||
// SignedEnvelopes before sharing with other peers.
|
||||
// See https://github.com/libp2p/go-libp2p-core/record/pb/envelope.proto for
|
||||
// the SignedEnvelope definition.
|
||||
message PeerRecord {
|
||||
|
||||
// AddressInfo is a wrapper around a binary multiaddr. It is defined as a
|
||||
// separate message to allow us to add per-address metadata in the future.
|
||||
message AddressInfo {
|
||||
bytes multiaddr = 1;
|
||||
}
|
||||
|
||||
// peerId contains a libp2p peer id in its binary representation.
|
||||
bytes peerId = 1;
|
||||
uint64 seq = 2;
|
||||
|
||||
// addresses is a list of public listen addresses for the peer.
|
||||
repeated AddressInfo addresses = 3;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user