consensus: remove log payload

This commit is contained in:
Sergey Cherepanov 2023-07-05 18:50:14 +02:00
parent 0c1d752acf
commit cd3c6c736a
No known key found for this signature in database
GPG Key ID: 87F8EDE8FBDF637C
4 changed files with 61 additions and 114 deletions

View File

@ -36,9 +36,9 @@ type Watcher interface {
type Service interface { type Service interface {
// AddLog adds new log to consensus servers // AddLog adds new log to consensus servers
AddLog(ctx context.Context, clog *consensusproto.Log) (err error) AddLog(ctx context.Context, rec *consensusproto.RawRecordWithId) (err error)
// AddRecord adds new record to consensus servers // AddRecord adds new record to consensus servers
AddRecord(ctx context.Context, logId string, clog *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error) AddRecord(ctx context.Context, logId string, rec *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error)
// Watch starts watching to given logId and calls watcher when any relative event received // Watch starts watching to given logId and calls watcher when any relative event received
Watch(logId string, w Watcher) (err error) Watch(logId string, w Watcher) (err error)
// UnWatch stops watching given logId and removes watcher // UnWatch stops watching given logId and removes watcher
@ -86,10 +86,10 @@ func (s *service) doClient(ctx context.Context, fn func(cl consensusproto.DRPCCo
return fn(consensusproto.NewDRPCConsensusClient(dc)) return fn(consensusproto.NewDRPCConsensusClient(dc))
} }
func (s *service) AddLog(ctx context.Context, clog *consensusproto.Log) (err error) { func (s *service) AddLog(ctx context.Context, rec *consensusproto.RawRecordWithId) (err error) {
return s.doClient(ctx, func(cl consensusproto.DRPCConsensusClient) error { return s.doClient(ctx, func(cl consensusproto.DRPCConsensusClient) error {
if _, err = cl.LogAdd(ctx, &consensusproto.LogAddRequest{ if _, err = cl.LogAdd(ctx, &consensusproto.LogAddRequest{
Log: clog, Record: rec,
}); err != nil { }); err != nil {
return rpcerr.Unwrap(err) return rpcerr.Unwrap(err)
} }
@ -97,11 +97,11 @@ func (s *service) AddLog(ctx context.Context, clog *consensusproto.Log) (err err
}) })
} }
func (s *service) AddRecord(ctx context.Context, logId string, clog *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error) { func (s *service) AddRecord(ctx context.Context, logId string, rec *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error) {
err = s.doClient(ctx, func(cl consensusproto.DRPCConsensusClient) error { err = s.doClient(ctx, func(cl consensusproto.DRPCConsensusClient) error {
if record, err = cl.RecordAdd(ctx, &consensusproto.RecordAddRequest{ if record, err = cl.RecordAdd(ctx, &consensusproto.RecordAddRequest{
LogId: logId, LogId: logId,
Record: clog, Record: rec,
}); err != nil { }); err != nil {
return rpcerr.Unwrap(err) return rpcerr.Unwrap(err)
} }

View File

@ -113,7 +113,7 @@ func TestService_Init(t *testing.T) {
func TestService_AddLog(t *testing.T) { func TestService_AddLog(t *testing.T) {
fx := newFixture(t).run(t) fx := newFixture(t).run(t)
defer fx.Finish() defer fx.Finish()
assert.NoError(t, fx.AddLog(ctx, &consensusproto.Log{})) assert.NoError(t, fx.AddLog(ctx, &consensusproto.RawRecordWithId{}))
} }
func TestService_AddRecord(t *testing.T) { func TestService_AddRecord(t *testing.T) {

View File

@ -61,7 +61,6 @@ func (ErrCodes) EnumDescriptor() ([]byte, []int) {
type Log struct { type Log struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
Records []*RawRecordWithId `protobuf:"bytes,3,rep,name=records,proto3" json:"records,omitempty"` Records []*RawRecordWithId `protobuf:"bytes,3,rep,name=records,proto3" json:"records,omitempty"`
} }
@ -105,13 +104,6 @@ func (m *Log) GetId() string {
return "" return ""
} }
func (m *Log) GetPayload() []byte {
if m != nil {
return m.Payload
}
return nil
}
func (m *Log) GetRecords() []*RawRecordWithId { func (m *Log) GetRecords() []*RawRecordWithId {
if m != nil { if m != nil {
return m.Records return m.Records
@ -347,7 +339,8 @@ func (m *Ok) XXX_DiscardUnknown() {
var xxx_messageInfo_Ok proto.InternalMessageInfo var xxx_messageInfo_Ok proto.InternalMessageInfo
type LogAddRequest struct { type LogAddRequest struct {
Log *Log `protobuf:"bytes,1,opt,name=log,proto3" json:"log,omitempty"` // first record in the log, consensus node not sign it
Record *RawRecordWithId `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
} }
func (m *LogAddRequest) Reset() { *m = LogAddRequest{} } func (m *LogAddRequest) Reset() { *m = LogAddRequest{} }
@ -383,9 +376,9 @@ func (m *LogAddRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_LogAddRequest proto.InternalMessageInfo var xxx_messageInfo_LogAddRequest proto.InternalMessageInfo
func (m *LogAddRequest) GetLog() *Log { func (m *LogAddRequest) GetRecord() *RawRecordWithId {
if m != nil { if m != nil {
return m.Log return m.Record
} }
return nil return nil
} }
@ -617,47 +610,46 @@ func init() {
} }
var fileDescriptor_b8d7f1c16b400059 = []byte{ var fileDescriptor_b8d7f1c16b400059 = []byte{
// 626 bytes of a gzipped FileDescriptorProto // 612 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcb, 0x6e, 0xd3, 0x4c,
0x10, 0xce, 0xda, 0x69, 0x1a, 0x4f, 0x68, 0x6a, 0x06, 0x84, 0x4c, 0x44, 0xdd, 0xc8, 0x12, 0x52, 0x14, 0xce, 0xd8, 0x69, 0x1a, 0x9f, 0xfc, 0x4d, 0xfd, 0x1f, 0x10, 0x32, 0x11, 0x75, 0x23, 0xaf,
0xa8, 0x50, 0x0a, 0x41, 0x20, 0xa1, 0x9e, 0xa0, 0x4a, 0xa5, 0x48, 0xa1, 0x45, 0x46, 0xa8, 0x12, 0x42, 0x85, 0x52, 0x08, 0x42, 0x08, 0x75, 0x05, 0x55, 0x2a, 0x22, 0x85, 0xb6,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4, 0x79, 0x3c, 0xb3, 0xb8, 0x5b, 0xd3, 0x7f, 0x4f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x62, 0x07, 0x7c, 0x8d,
0xa8, 0xa8, 0xbf, 0x67, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x21, 0x21, 0x57, 0x7a, 0x41, 0x05, 0x39, 0x05, 0x00, 0x00,
0x00, 0x00,
} }
func (m *Log) Marshal() (dAtA []byte, err error) { func (m *Log) Marshal() (dAtA []byte, err error) {
@ -694,13 +686,6 @@ func (m *Log) MarshalToSizedBuffer(dAtA []byte) (int, error) {
dAtA[i] = 0x1a dAtA[i] = 0x1a
} }
} }
if len(m.Payload) > 0 {
i -= len(m.Payload)
copy(dAtA[i:], m.Payload)
i = encodeVarintConsensus(dAtA, i, uint64(len(m.Payload)))
i--
dAtA[i] = 0x12
}
if len(m.Id) > 0 { if len(m.Id) > 0 {
i -= len(m.Id) i -= len(m.Id)
copy(dAtA[i:], m.Id) copy(dAtA[i:], m.Id)
@ -891,9 +876,9 @@ func (m *LogAddRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if m.Log != nil { if m.Record != nil {
{ {
size, err := m.Log.MarshalToSizedBuffer(dAtA[:i]) size, err := m.Record.MarshalToSizedBuffer(dAtA[:i])
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -1094,10 +1079,6 @@ func (m *Log) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovConsensus(uint64(l)) n += 1 + l + sovConsensus(uint64(l))
} }
l = len(m.Payload)
if l > 0 {
n += 1 + l + sovConsensus(uint64(l))
}
if len(m.Records) > 0 { if len(m.Records) > 0 {
for _, e := range m.Records { for _, e := range m.Records {
l = e.Size() l = e.Size()
@ -1188,8 +1169,8 @@ func (m *LogAddRequest) Size() (n int) {
} }
var l int var l int
_ = l _ = l
if m.Log != nil { if m.Record != nil {
l = m.Log.Size() l = m.Record.Size()
n += 1 + l + sovConsensus(uint64(l)) n += 1 + l + sovConsensus(uint64(l))
} }
return n return n
@ -1335,40 +1316,6 @@ func (m *Log) Unmarshal(dAtA []byte) error {
} }
m.Id = string(dAtA[iNdEx:postIndex]) m.Id = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...)
if m.Payload == nil {
m.Payload = []byte{}
}
iNdEx = postIndex
case 3: case 3:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType)
@ -1976,7 +1923,7 @@ func (m *LogAddRequest) Unmarshal(dAtA []byte) error {
switch fieldNum { switch fieldNum {
case 1: case 1:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Record", wireType)
} }
var msglen int var msglen int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -2003,10 +1950,10 @@ func (m *LogAddRequest) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.Log == nil { if m.Record == nil {
m.Log = &Log{} m.Record = &RawRecordWithId{}
} }
if err := m.Log.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { if err := m.Record.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err return err
} }
iNdEx = postIndex iNdEx = postIndex

View File

@ -15,7 +15,6 @@ enum ErrCodes {
message Log { message Log {
string id = 1; string id = 1;
bytes payload = 2;
repeated RawRecordWithId records = 3; repeated RawRecordWithId records = 3;
} }
@ -54,7 +53,8 @@ service Consensus {
message Ok {} message Ok {}
message LogAddRequest { message LogAddRequest {
Log log = 1; // first record in the log, consensus node not sign it
RawRecordWithId record = 1;
} }
message RecordAddRequest { message RecordAddRequest {