diff --git a/blockchain/msgs.go b/blockchain/msgs.go index cd722bc19..35868830b 100644 --- a/blockchain/msgs.go +++ b/blockchain/msgs.go @@ -102,15 +102,7 @@ func ValidateMsg(pb proto.Message) error { return fmt.Errorf("base %v cannot be greater than height %v", msg.Base, msg.Height) } case *bcproto.StatusRequest: - if msg.Base < 0 { - return errors.New("negative Base") - } - if msg.Height < 0 { - return errors.New("negative Height") - } - if msg.Base > msg.Height { - return fmt.Errorf("base %v cannot be greater than height %v", msg.Base, msg.Height) - } + return nil default: return fmt.Errorf("unknown message type %T", msg) } diff --git a/blockchain/msgs_test.go b/blockchain/msgs_test.go index f3ea63f32..c8c8a77c9 100644 --- a/blockchain/msgs_test.go +++ b/blockchain/msgs_test.go @@ -52,23 +52,8 @@ func TestBcNoBlockResponseMessageValidateBasic(t *testing.T) { } func TestBcStatusRequestMessageValidateBasic(t *testing.T) { - testCases := []struct { - testName string - requestHeight int64 - expectErr bool - }{ - {"Valid Request Message", 0, false}, - {"Valid Request Message", 1, false}, - {"Invalid Request Message", -1, true}, - } - - for _, tc := range testCases { - tc := tc - t.Run(tc.testName, func(t *testing.T) { - request := bcproto.StatusRequest{Height: tc.requestHeight} - assert.Equal(t, tc.expectErr, ValidateMsg(&request) != nil, "Validate Basic had an unexpected result") - }) - } + request := bcproto.StatusRequest{} + assert.NoError(t, ValidateMsg(&request)) } func TestBcStatusResponseMessageValidateBasic(t *testing.T) { @@ -124,12 +109,8 @@ func TestBlockchainMessageVectors(t *testing.T) { NoBlockResponse: &bcproto.NoBlockResponse{Height: math.MaxInt64}}}, []byte{0x12, 0xa, 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}}, {"StatusRequestMessage", &bcproto.Message{Sum: &bcproto.Message_StatusRequest{ - StatusRequest: &bcproto.StatusRequest{Height: 1, Base: 2}}}, - []byte{0x22, 0x4, 0x8, 0x1, 0x10, 0x2}}, - {"StatusRequestMessage", &bcproto.Message{Sum: &bcproto.Message_StatusRequest{ - StatusRequest: &bcproto.StatusRequest{Height: math.MaxInt64, Base: math.MaxInt64}}}, - []byte{0x22, 0x14, 0x8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}}, + StatusRequest: &bcproto.StatusRequest{}}}, + []byte{0x22, 0x0}}, {"StatusResponseMessage", &bcproto.Message{Sum: &bcproto.Message_StatusResponse{ StatusResponse: &bcproto.StatusResponse{Height: 1, Base: 2}}}, []byte{0x2a, 0x4, 0x8, 0x1, 0x10, 0x2}}, diff --git a/blockchain/v0/reactor.go b/blockchain/v0/reactor.go index dd753f1f2..047c5f72a 100644 --- a/blockchain/v0/reactor.go +++ b/blockchain/v0/reactor.go @@ -410,10 +410,7 @@ FOR_LOOP: // BroadcastStatusRequest broadcasts `BlockStore` base and height. func (bcR *BlockchainReactor) BroadcastStatusRequest() error { - bm, err := bc.EncodeMsg(&bcproto.StatusRequest{ - Base: bcR.store.Base(), - Height: bcR.store.Height(), - }) + bm, err := bc.EncodeMsg(&bcproto.StatusRequest{}) if err != nil { bcR.Logger.Error("could not convert msg to proto", "err", err) return fmt.Errorf("could not convert msg to proto: %w", err) diff --git a/blockchain/v1/reactor.go b/blockchain/v1/reactor.go index a63974962..e527993d5 100644 --- a/blockchain/v1/reactor.go +++ b/blockchain/v1/reactor.go @@ -480,10 +480,7 @@ func (bcR *BlockchainReactor) processBlock() error { // Implements bcRNotifier // sendStatusRequest broadcasts `BlockStore` height. func (bcR *BlockchainReactor) sendStatusRequest() { - msgBytes, err := bc.EncodeMsg(&bcproto.StatusRequest{ - Base: bcR.store.Base(), - Height: bcR.store.Height(), - }) + msgBytes, err := bc.EncodeMsg(&bcproto.StatusRequest{}) if err != nil { panic(err) } diff --git a/blockchain/v2/io.go b/blockchain/v2/io.go index 78919af04..4951573ce 100644 --- a/blockchain/v2/io.go +++ b/blockchain/v2/io.go @@ -14,9 +14,9 @@ type iIO interface { sendBlockRequest(peerID p2p.ID, height int64) error sendBlockToPeer(block *types.Block, peerID p2p.ID) error sendBlockNotFound(height int64, peerID p2p.ID) error - sendStatusResponse(base int64, height int64, peerID p2p.ID) error + sendStatusResponse(base, height int64, peerID p2p.ID) error - broadcastStatusRequest(base int64, height int64) error + broadcastStatusRequest() error trySwitchToConsensus(state state.State, skipWAL bool) bool } @@ -127,12 +127,8 @@ func (sio *switchIO) trySwitchToConsensus(state state.State, skipWAL bool) bool return ok } -func (sio *switchIO) broadcastStatusRequest(base, height int64) error { - if height == 0 && base > 0 { - base = 0 - } - - msgBytes, err := bc.EncodeMsg(&bcproto.StatusRequest{Base: base, Height: height}) +func (sio *switchIO) broadcastStatusRequest() error { + msgBytes, err := bc.EncodeMsg(&bcproto.StatusRequest{}) if err != nil { return err } diff --git a/blockchain/v2/reactor.go b/blockchain/v2/reactor.go index f3f0bee4c..f5da4e5ff 100644 --- a/blockchain/v2/reactor.go +++ b/blockchain/v2/reactor.go @@ -314,7 +314,7 @@ func (r *BlockchainReactor) demux(events <-chan Event) { case <-doProcessBlockCh: r.processor.send(rProcessBlock{}) case <-doStatusCh: - r.io.broadcastStatusRequest(r.store.Base(), r.SyncHeight()) + r.io.broadcastStatusRequest() // Events from peers. Closing the channel signals event loop termination. case event, ok := <-events: diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index dbc15aa8e..03691ac37 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -98,7 +98,7 @@ func (sio *mockSwitchIo) sendBlockRequest(peerID p2p.ID, height int64) error { return nil } -func (sio *mockSwitchIo) sendStatusResponse(base int64, height int64, peerID p2p.ID) error { +func (sio *mockSwitchIo) sendStatusResponse(base, height int64, peerID p2p.ID) error { sio.mtx.Lock() defer sio.mtx.Unlock() sio.numStatusResponse++ @@ -126,7 +126,7 @@ func (sio *mockSwitchIo) trySwitchToConsensus(state sm.State, skipWAL bool) bool return true } -func (sio *mockSwitchIo) broadcastStatusRequest(base int64, height int64) error { +func (sio *mockSwitchIo) broadcastStatusRequest() error { return nil } diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index c415a0ff6..4920ac0f2 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -669,7 +669,7 @@ func (c *MConnection) stopPongTimer() { func (c *MConnection) maxPacketMsgSize() int { bz, err := proto.Marshal(mustWrapPacket(&tmp2p.PacketMsg{ ChannelID: 0x01, - EOF: 1, + EOF: true, Data: make([]byte, c.config.MaxPacketMsgPayloadSize), })) if err != nil { @@ -826,11 +826,11 @@ func (ch *Channel) nextPacketMsg() tmp2p.PacketMsg { maxSize := ch.maxPacketMsgPayloadSize packet.Data = ch.sending[:tmmath.MinInt(maxSize, len(ch.sending))] if len(ch.sending) <= maxSize { - packet.EOF = 0x01 + packet.EOF = true ch.sending = nil atomic.AddInt32(&ch.sendQueueSize, -1) // decrement sendQueueSize } else { - packet.EOF = 0x00 + packet.EOF = false ch.sending = ch.sending[tmmath.MinInt(maxSize, len(ch.sending)):] } return packet @@ -855,7 +855,7 @@ func (ch *Channel) recvPacketMsg(packet tmp2p.PacketMsg) ([]byte, error) { return nil, fmt.Errorf("received message exceeds available capacity: %v < %v", recvCap, recvReceived) } ch.recving = append(ch.recving, packet.Data...) - if packet.EOF == 0x01 { + if packet.EOF { msgBytes := ch.recving // clear the slice without re-allocating. diff --git a/p2p/conn/connection_test.go b/p2p/conn/connection_test.go index 78b73441d..6f771a2be 100644 --- a/p2p/conn/connection_test.go +++ b/p2p/conn/connection_test.go @@ -483,7 +483,7 @@ func TestMConnectionReadErrorLongMessage(t *testing.T) { // send msg thats just right var packet = tmp2p.PacketMsg{ ChannelID: 0x01, - EOF: 1, + EOF: true, Data: make([]byte, mconnClient.config.MaxPacketMsgPayloadSize), } @@ -494,7 +494,7 @@ func TestMConnectionReadErrorLongMessage(t *testing.T) { // send msg thats too long packet = tmp2p.PacketMsg{ ChannelID: 0x01, - EOF: 1, + EOF: true, Data: make([]byte, mconnClient.config.MaxPacketMsgPayloadSize+100), } diff --git a/proto/tendermint/blockchain/types.pb.go b/proto/tendermint/blockchain/types.pb.go index d00c06a17..cc6481a5e 100644 --- a/proto/tendermint/blockchain/types.pb.go +++ b/proto/tendermint/blockchain/types.pb.go @@ -158,10 +158,8 @@ func (m *BlockResponse) GetBlock() *types.Block { return nil } -// StatusRequest requests the status of a node (Height & Base) +// StatusRequest requests the status of a peer. type StatusRequest struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Base int64 `protobuf:"varint,2,opt,name=base,proto3" json:"base,omitempty"` } func (m *StatusRequest) Reset() { *m = StatusRequest{} } @@ -197,21 +195,7 @@ func (m *StatusRequest) XXX_DiscardUnknown() { var xxx_messageInfo_StatusRequest proto.InternalMessageInfo -func (m *StatusRequest) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *StatusRequest) GetBase() int64 { - if m != nil { - return m.Base - } - return 0 -} - -// StatusResponse is a peer response to inform their status +// StatusResponse is a peer response to inform their status. type StatusResponse struct { Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Base int64 `protobuf:"varint,2,opt,name=base,proto3" json:"base,omitempty"` @@ -400,31 +384,31 @@ func init() { func init() { proto.RegisterFile("tendermint/blockchain/types.proto", fileDescriptor_2927480384e78499) } var fileDescriptor_2927480384e78499 = []byte{ - // 373 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0xca, 0xc9, 0x4f, 0xce, 0x4e, 0xce, 0x48, 0xcc, - 0xcc, 0xd3, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x45, - 0x28, 0xd1, 0x43, 0x28, 0x91, 0x92, 0x41, 0xd2, 0x09, 0x56, 0x0e, 0xd1, 0x0f, 0xd1, 0xa4, 0xa4, - 0xc6, 0xc5, 0xe3, 0x04, 0xe2, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x89, 0x71, 0xb1, - 0x65, 0xa4, 0x66, 0xa6, 0x67, 0x94, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x41, 0x79, 0x4a, - 0x9a, 0x5c, 0xfc, 0x7e, 0xf9, 0x50, 0x95, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x38, 0x95, 0xda, - 0x71, 0xf1, 0xa2, 0x2a, 0xd4, 0xe5, 0x62, 0x05, 0x5b, 0x09, 0x56, 0xc7, 0x6d, 0x24, 0xae, 0x87, - 0xe4, 0x50, 0x88, 0x07, 0x20, 0xea, 0x21, 0xaa, 0x94, 0xac, 0xb9, 0x78, 0x83, 0x4b, 0x12, 0x4b, - 0x4a, 0x8b, 0x09, 0xb8, 0x49, 0x48, 0x88, 0x8b, 0x25, 0x29, 0xb1, 0x38, 0x55, 0x82, 0x09, 0x2c, - 0x0a, 0x66, 0x2b, 0xd9, 0x70, 0xf1, 0xc1, 0x34, 0xe3, 0x77, 0x26, 0x56, 0xdd, 0x8b, 0x98, 0xb9, - 0xd8, 0x7d, 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x85, 0xbc, 0xb8, 0x78, 0xc1, 0xee, 0x89, 0x2f, - 0x82, 0x38, 0x03, 0xea, 0x7a, 0x65, 0x3d, 0xac, 0xc1, 0xac, 0x87, 0x1c, 0x8a, 0x1e, 0x0c, 0x41, - 0x3c, 0x49, 0xc8, 0xa1, 0x1a, 0xc2, 0x25, 0x98, 0x97, 0x1f, 0x0f, 0x33, 0x0e, 0xe2, 0x30, 0xb0, - 0xc5, 0xdc, 0x46, 0x6a, 0x38, 0xcc, 0x43, 0x0b, 0x6d, 0x0f, 0x86, 0x20, 0xfe, 0x3c, 0xb4, 0x08, - 0xf0, 0xe5, 0xe2, 0x43, 0x33, 0x92, 0x19, 0x6c, 0xa4, 0x0a, 0x7e, 0x27, 0xc2, 0x0d, 0xe4, 0x4d, - 0x42, 0x37, 0xae, 0x18, 0x1c, 0x74, 0x70, 0x1f, 0xb3, 0xe0, 0x35, 0x0e, 0x25, 0x92, 0x40, 0xc6, - 0x15, 0xa3, 0xc4, 0x5a, 0x00, 0x17, 0x3f, 0xdc, 0x38, 0xa8, 0xf3, 0x58, 0xc1, 0xe6, 0xa9, 0x12, - 0x30, 0x0f, 0xee, 0x3e, 0xbe, 0x62, 0x14, 0x11, 0x27, 0x56, 0x2e, 0xe6, 0xe2, 0xd2, 0x5c, 0xa7, - 0xb0, 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, 0x88, 0xb2, 0x49, 0xcf, 0x2c, 0xc9, - 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x47, 0x4e, 0xf5, 0x08, 0x26, 0x38, 0xd1, 0xeb, 0x63, - 0xcd, 0x4b, 0x49, 0x6c, 0x60, 0x49, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x51, 0x4d, 0xe0, - 0x91, 0x6b, 0x03, 0x00, 0x00, + // 370 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x4e, 0xfa, 0x40, + 0x10, 0xc6, 0xdb, 0x7f, 0x81, 0x7f, 0x32, 0x50, 0x1a, 0x9b, 0xa8, 0xc4, 0x98, 0x46, 0xab, 0x12, + 0x3d, 0xd8, 0x26, 0x78, 0x25, 0x1e, 0x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f4, 0x27, 0x02, 0x9d, 0x3a, + 0x3a, 0x71, 0x36, 0x46, 0xe7, 0xc8, 0xc9, 0x74, 0x15, 0xaf, 0x16, 0xc8, 0x49, 0x3d, 0xc0, 0x4e, + 0x4c, 0xfb, 0x4b, 0x9c, 0x30, 0x86, 0x83, 0xab, 0xad, 0xe6, 0x16, 0x5e, 0x2e, 0xc1, 0xae, 0xe2, + 0x19, 0x71, 0x2e, 0xd4, 0x1e, 0xd4, 0x73, 0x48, 0x0d, 0x91, 0xa7, 0xc5, 0x16, 0x33, 0xa0, 0x1e, + 0xe4, 0x71, 0x0c, 0xa3, 0xcb, 0x5e, 0x5c, 0x2a, 0xc4, 0xad, 0x05, 0xbf, 0xc0, 0x31, 0xb9, 0x60, + 0xde, 0x81, 0x91, 0xe1, 0x52, 0x7b, 0x65, 0xe4, 0x9d, 0xfd, 0xc1, 0xcb, 0xfc, 0xd5, 0xd9, 0x5a, + 0xa5, 0x53, 0x06, 0x8d, 0x25, 0xa3, 0xce, 0xe3, 0xd7, 0xcc, 0x52, 0xa7, 0x33, 0x4b, 0xfd, 0x99, + 0x59, 0xea, 0xc7, 0xdc, 0x52, 0xa6, 0x73, 0x4b, 0xf9, 0x9e, 0x5b, 0xca, 0x53, 0x7b, 0x18, 0xf1, + 0x30, 0x09, 0x9c, 0x01, 0x1d, 0xb9, 0xf2, 0x26, 0xaf, 0x8e, 0xb8, 0xc8, 0xee, 0xc6, 0xff, 0x23, + 0xa8, 0xe0, 0xc7, 0xab, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x59, 0x07, 0xbd, 0x3f, 0x03, + 0x00, 0x00, } func (m *BlockRequest) Marshal() (dAtA []byte, err error) { @@ -538,16 +522,6 @@ func (m *StatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Base != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Base)) - i-- - dAtA[i] = 0x10 - } - if m.Height != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } @@ -775,12 +749,6 @@ func (m *StatusRequest) Size() (n int) { } var l int _ = l - if m.Height != 0 { - n += 1 + sovTypes(uint64(m.Height)) - } - if m.Base != 0 { - n += 1 + sovTypes(uint64(m.Base)) - } return n } @@ -1140,44 +1108,6 @@ func (m *StatusRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Base", wireType) - } - m.Base = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Base |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/tendermint/blockchain/types.proto b/proto/tendermint/blockchain/types.proto index 9b0e98d36..f5c143cf5 100644 --- a/proto/tendermint/blockchain/types.proto +++ b/proto/tendermint/blockchain/types.proto @@ -20,13 +20,11 @@ message BlockResponse { tendermint.types.Block block = 1; } -// StatusRequest requests the status of a node (Height & Base) +// StatusRequest requests the status of a peer. message StatusRequest { - int64 height = 1; - int64 base = 2; } -// StatusResponse is a peer response to inform their status +// StatusResponse is a peer response to inform their status. message StatusResponse { int64 height = 1; int64 base = 2; diff --git a/proto/tendermint/p2p/conn.pb.go b/proto/tendermint/p2p/conn.pb.go index a04436761..7c26d3fcd 100644 --- a/proto/tendermint/p2p/conn.pb.go +++ b/proto/tendermint/p2p/conn.pb.go @@ -98,7 +98,7 @@ var xxx_messageInfo_PacketPong proto.InternalMessageInfo type PacketMsg struct { ChannelID int32 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - EOF int32 `protobuf:"varint,2,opt,name=eof,proto3" json:"eof,omitempty"` + EOF bool `protobuf:"varint,2,opt,name=eof,proto3" json:"eof,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` } @@ -142,11 +142,11 @@ func (m *PacketMsg) GetChannelID() int32 { return 0 } -func (m *PacketMsg) GetEOF() int32 { +func (m *PacketMsg) GetEOF() bool { if m != nil { return m.EOF } - return 0 + return false } func (m *PacketMsg) GetData() []byte { @@ -317,32 +317,32 @@ func init() { func init() { proto.RegisterFile("tendermint/p2p/conn.proto", fileDescriptor_22474b5527c8fa9f) } var fileDescriptor_22474b5527c8fa9f = []byte{ - // 391 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x3d, 0x8b, 0xdb, 0x40, - 0x10, 0x95, 0xa2, 0x3b, 0x1f, 0x1a, 0x3b, 0x47, 0x58, 0x52, 0xd8, 0xe6, 0x90, 0x0f, 0x55, 0x57, - 0x04, 0x09, 0x14, 0xd2, 0x24, 0xa4, 0x88, 0xf2, 0x41, 0x0e, 0x63, 0x6c, 0x94, 0x2e, 0x8d, 0xd0, - 0xc7, 0x66, 0xb5, 0xd8, 0xda, 0x5d, 0xbc, 0xab, 0x42, 0xff, 0x22, 0x3f, 0xcb, 0xe9, 0x5c, 0xa6, - 0x32, 0x41, 0xfe, 0x23, 0x41, 0x2b, 0x27, 0x96, 0x21, 0xe9, 0xde, 0x9b, 0x99, 0x37, 0x1f, 0xcc, - 0x83, 0x89, 0xc2, 0x2c, 0xc7, 0xdb, 0x92, 0x32, 0xe5, 0x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, 0x4b, 0x56, 0xa5, 0x1b, 0xc3, 0xed, 0xbb, 0x4a, 0x15, 0x5f, 0x28, 0x59, 0x60, 0x29, 0x13, - 0x82, 0xd1, 0x1b, 0xb8, 0x11, 0x55, 0x1a, 0xaf, 0x71, 0x7d, 0x3a, 0xe7, 0xae, 0xdf, 0xb1, 0xfb, - 0x89, 0xb7, 0xaa, 0xd2, 0x0d, 0xcd, 0xe6, 0xb8, 0x0e, 0xaf, 0x76, 0x87, 0x99, 0x11, 0x0d, 0x44, - 0x95, 0xce, 0x71, 0x8d, 0x9e, 0x81, 0x25, 0x69, 0x77, 0xc8, 0x28, 0x6a, 0x61, 0xb8, 0xdc, 0x35, - 0x8e, 0xb9, 0x6f, 0x1c, 0xf3, 0x57, 0xe3, 0x98, 0xdf, 0x8f, 0x8e, 0xb1, 0x3f, 0x3a, 0xc6, 0xcf, - 0xa3, 0x63, 0x7c, 0x7d, 0x45, 0xa8, 0x2a, 0xaa, 0xd4, 0xcb, 0x78, 0xe9, 0xf7, 0xbe, 0xde, 0x77, - 0x90, 0x76, 0xc7, 0xa5, 0xa5, 0xd2, 0x81, 0x8e, 0xbe, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x2a, - 0x08, 0x6f, 0x5b, 0x6b, 0x02, 0x00, 0x00, + // 395 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x3d, 0x8f, 0xd3, 0x40, + 0x10, 0xf5, 0xe2, 0xbb, 0x1c, 0x99, 0x84, 0x13, 0x5a, 0x51, 0x24, 0xd1, 0xc9, 0x89, 0x5c, 0xa5, + 0x40, 0xb6, 0x64, 0x44, 0x03, 0xa2, 0xc0, 0x7c, 0x88, 0xd3, 0x29, 0xba, 0xc8, 0x74, 0x34, 0x96, + 0x3f, 0x96, 0xf5, 0x2a, 0xe7, 0xdd, 0x55, 0x76, 0x5d, 0xf8, 0x5f, 0xf0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, 0xfa, 0x72, 0xc1, 0xa9, 0x59, 0xe0, 0x71, 0xb9, 0x38, 0x91, 0x0b, 0x4e, 0xf1, 0x1b, + 0x38, 0xb0, 0xb8, 0x54, 0xd4, 0xac, 0x38, 0x0a, 0xa6, 0xff, 0x57, 0xaf, 0x54, 0x2b, 0x1e, 0xca, + 0xbf, 0x24, 0x3c, 0x07, 0x5b, 0x55, 0xa5, 0x1b, 0xc3, 0xe5, 0xfb, 0x4a, 0x17, 0x5f, 0x19, 0x5d, + 0x11, 0xa5, 0x12, 0x4a, 0xf0, 0x5b, 0xb8, 0x90, 0x55, 0x1a, 0x6f, 0x48, 0x7d, 0x38, 0xe7, 0xaa, + 0xdf, 0xb1, 0xfb, 0x89, 0xb7, 0xae, 0xd2, 0x3b, 0x96, 0xdd, 0x90, 0x3a, 0x3c, 0xbb, 0xdf, 0xcd, + 0xad, 0x68, 0x20, 0xab, 0xf4, 0x86, 0xd4, 0xf8, 0x39, 0xd8, 0x8a, 0x75, 0x87, 0x8c, 0xa3, 0x16, + 0x86, 0xb7, 0xf7, 0x8d, 0x83, 0x1e, 0x1a, 0x07, 0xfd, 0x6e, 0x1c, 0xf4, 0x63, 0xef, 0x58, 0x0f, + 0x7b, 0xc7, 0xfa, 0xb5, 0x77, 0xac, 0x6f, 0xaf, 0x29, 0xd3, 0x45, 0x95, 0x7a, 0x99, 0x28, 0xfd, + 0xde, 0xd7, 0xfb, 0x0e, 0x32, 0xee, 0x38, 0xb5, 0x54, 0x3a, 0x30, 0xd1, 0x57, 0x7f, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x30, 0xfd, 0xb2, 0x8d, 0x6b, 0x02, 0x00, 0x00, } func (m *PacketPing) Marshal() (dAtA []byte, err error) { @@ -418,8 +418,13 @@ func (m *PacketMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.EOF != 0 { - i = encodeVarintConn(dAtA, i, uint64(m.EOF)) + if m.EOF { + i-- + if m.EOF { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } i-- dAtA[i] = 0x10 } @@ -604,8 +609,8 @@ func (m *PacketMsg) Size() (n int) { if m.ChannelID != 0 { n += 1 + sovConn(uint64(m.ChannelID)) } - if m.EOF != 0 { - n += 1 + sovConn(uint64(m.EOF)) + if m.EOF { + n += 2 } l = len(m.Data) if l > 0 { @@ -841,7 +846,7 @@ func (m *PacketMsg) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EOF", wireType) } - m.EOF = 0 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConn @@ -851,11 +856,12 @@ func (m *PacketMsg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EOF |= int32(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } + m.EOF = bool(v != 0) case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) diff --git a/proto/tendermint/p2p/conn.proto b/proto/tendermint/p2p/conn.proto index a9112df2e..b12de6c82 100644 --- a/proto/tendermint/p2p/conn.proto +++ b/proto/tendermint/p2p/conn.proto @@ -12,7 +12,7 @@ message PacketPong {} message PacketMsg { int32 channel_id = 1 [(gogoproto.customname) = "ChannelID"]; - int32 eof = 2 [(gogoproto.customname) = "EOF"]; + bool eof = 2 [(gogoproto.customname) = "EOF"]; bytes data = 3; }