@cryptotaxi247 / kubo / commits / 5ae130dee

update protobuf files in go-ipfs

Also: * Switch to gogo for filestore for consistency. * Use the "faster" codegen for fewer allocations. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Aug 8, 2018 at 20:14 UTC 5ae130dee2040f658e51a28b38dfe0a032e820da
10 files changed +709 -69
Makefile
+1 -1
@@ -2,7 +2,7 @@
2
3 SHELL=PATH='$(PATH)' /bin/sh
4
5 -PROTOC = protoc --gogo_out=. --proto_path=.:/usr/local/opt/protobuf/include:$(dir $@) $<
5 +PROTOC = protoc --gogofaster_out=. --proto_path=.:$(GOPATH)/src:$(dir $@) $<
6
7 # enable second expansion
8 .SECONDEXPANSION:
Rules.mk
+3
@@ -50,6 +50,9 @@ endif
50 dir := pin/internal/pb
51 include $(dir)/Rules.mk
52
53 +dir := filestore/pb
54 +include $(dir)/Rules.mk
55 +
56
57 # -------------------- #
58 # universal rules #
filestore/fsrefstore.go
+5 -5
@@ -17,8 +17,8 @@ import (
17 dsq "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/query"
18 blockstore "gx/ipfs/QmYBEfMSquSGnuxBthUoBJNs3F6p4VAPPvAgxq6XXGvTPh/go-ipfs-blockstore"
19 cid "gx/ipfs/QmYjnkEL7i731PirfVH1sis89evN7jt4otSHw5D2xXXwUV/go-cid"
20 - proto "gx/ipfs/QmZHU2gx42NPTYXzw6pJkuX6xCE7bKECp6e8QcPdoLx8sx/protobuf/proto"
20 posinfo "gx/ipfs/QmdBpJ5VTfL79VwKDU93z7fyZJ3mm4UaBHrE73CWRw2Bjd/go-ipfs-posinfo"
21 + proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto"
22 )
23
24 // FilestorePrefix identifies the key prefix for FileManager blocks.
@@ -276,7 +276,7 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
276 if !f.AllowUrls {
277 return ErrUrlstoreNotEnabled
278 }
279 - dobj.FilePath = proto.String(b.PosInfo.FullPath)
279 + dobj.FilePath = b.PosInfo.FullPath
280 } else {
281 if !f.AllowFiles {
282 return ErrFilestoreNotEnabled
@@ -290,10 +290,10 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
290 return err
291 }
292
293 - dobj.FilePath = proto.String(filepath.ToSlash(p))
293 + dobj.FilePath = filepath.ToSlash(p)
294 }
295 - dobj.Offset = proto.Uint64(b.PosInfo.Offset)
296 - dobj.Size_ = proto.Uint64(uint64(len(b.RawData())))
295 + dobj.Offset = b.PosInfo.Offset
296 + dobj.Size_ = uint64(len(b.RawData()))
297
298 data, err := proto.Marshal(&dobj)
299 if err != nil {
filestore/pb/Makefile deleted
-10
@@ -1,10 +0,0 @@
1 -PB = $(wildcard *.proto)
2 -GO = $(PB:.proto=.pb.go)
3 -
4 -all: $(GO)
5 -
6 -%.pb.go: %.proto
7 - protoc --gogo_out=. $<
8 -
9 -clean:
10 - rm *.pb.go
filestore/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk
filestore/pb/dataobj.pb.go
+347 -22
@@ -1,55 +1,83 @@
1 -// Code generated by protoc-gen-gogo.
2 -// source: dataobj.proto
3 -// DO NOT EDIT!
1 +// Code generated by protoc-gen-gogo. DO NOT EDIT.
2 +// source: filestore/pb/dataobj.proto
3
5 -/*
6 -Package datastore_pb is a generated protocol buffer package.
7 -
8 -It is generated from these files:
9 - dataobj.proto
10 -
11 -It has these top-level messages:
12 - DataObj
13 -*/
4 package datastore_pb
5
6 import proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto"
7 import fmt "fmt"
8 import math "math"
9
10 +import io "io"
11 +
12 // Reference imports to suppress errors if they are not otherwise used.
13 var _ = proto.Marshal
14 var _ = fmt.Errorf
15 var _ = math.Inf
16
17 +// This is a compile-time assertion to ensure that this generated file
18 +// is compatible with the proto package it is being compiled against.
19 +// A compilation error at this line likely means your copy of the
20 +// proto package needs to be updated.
21 +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
22 +
23 type DataObj struct {
26 - FilePath *string `protobuf:"bytes,1,opt,name=FilePath" json:"FilePath,omitempty"`
27 - Offset *uint64 `protobuf:"varint,2,opt,name=Offset" json:"Offset,omitempty"`
28 - Size_ *uint64 `protobuf:"varint,3,opt,name=Size" json:"Size,omitempty"`
29 - XXX_unrecognized []byte `json:"-"`
24 + FilePath string `protobuf:"bytes,1,opt,name=FilePath" json:"FilePath"`
25 + Offset uint64 `protobuf:"varint,2,opt,name=Offset" json:"Offset"`
26 + Size_ uint64 `protobuf:"varint,3,opt,name=Size" json:"Size"`
27 + XXX_NoUnkeyedLiteral struct{} `json:"-"`
28 + XXX_sizecache int32 `json:"-"`
29 }
30
31 func (m *DataObj) Reset() { *m = DataObj{} }
32 func (m *DataObj) String() string { return proto.CompactTextString(m) }
33 func (*DataObj) ProtoMessage() {}
34 +func (*DataObj) Descriptor() ([]byte, []int) {
35 + return fileDescriptor_dataobj_216c555249812eeb, []int{0}
36 +}
37 +func (m *DataObj) XXX_Unmarshal(b []byte) error {
38 + return m.Unmarshal(b)
39 +}
40 +func (m *DataObj) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
41 + if deterministic {
42 + return xxx_messageInfo_DataObj.Marshal(b, m, deterministic)
43 + } else {
44 + b = b[:cap(b)]
45 + n, err := m.MarshalTo(b)
46 + if err != nil {
47 + return nil, err
48 + }
49 + return b[:n], nil
50 + }
51 +}
52 +func (dst *DataObj) XXX_Merge(src proto.Message) {
53 + xxx_messageInfo_DataObj.Merge(dst, src)
54 +}
55 +func (m *DataObj) XXX_Size() int {
56 + return m.Size()
57 +}
58 +func (m *DataObj) XXX_DiscardUnknown() {
59 + xxx_messageInfo_DataObj.DiscardUnknown(m)
60 +}
61 +
62 +var xxx_messageInfo_DataObj proto.InternalMessageInfo
63
64 func (m *DataObj) GetFilePath() string {
37 - if m != nil && m.FilePath != nil {
38 - return *m.FilePath
65 + if m != nil {
66 + return m.FilePath
67 }
68 return ""
69 }
70
71 func (m *DataObj) GetOffset() uint64 {
44 - if m != nil && m.Offset != nil {
45 - return *m.Offset
72 + if m != nil {
73 + return m.Offset
74 }
75 return 0
76 }
77
78 func (m *DataObj) GetSize_() uint64 {
51 - if m != nil && m.Size_ != nil {
52 - return *m.Size_
79 + if m != nil {
80 + return m.Size_
81 }
82 return 0
83 }
@@ -57,3 +85,300 @@ func (m *DataObj) GetSize_() uint64 {
85 func init() {
86 proto.RegisterType((*DataObj)(nil), "datastore.pb.DataObj")
87 }
88 +func (m *DataObj) Marshal() (dAtA []byte, err error) {
89 + size := m.Size()
90 + dAtA = make([]byte, size)
91 + n, err := m.MarshalTo(dAtA)
92 + if err != nil {
93 + return nil, err
94 + }
95 + return dAtA[:n], nil
96 +}
97 +
98 +func (m *DataObj) MarshalTo(dAtA []byte) (int, error) {
99 + var i int
100 + _ = i
101 + var l int
102 + _ = l
103 + dAtA[i] = 0xa
104 + i++
105 + i = encodeVarintDataobj(dAtA, i, uint64(len(m.FilePath)))
106 + i += copy(dAtA[i:], m.FilePath)
107 + dAtA[i] = 0x10
108 + i++
109 + i = encodeVarintDataobj(dAtA, i, uint64(m.Offset))
110 + dAtA[i] = 0x18
111 + i++
112 + i = encodeVarintDataobj(dAtA, i, uint64(m.Size_))
113 + return i, nil
114 +}
115 +
116 +func encodeVarintDataobj(dAtA []byte, offset int, v uint64) int {
117 + for v >= 1<<7 {
118 + dAtA[offset] = uint8(v&0x7f | 0x80)
119 + v >>= 7
120 + offset++
121 + }
122 + dAtA[offset] = uint8(v)
123 + return offset + 1
124 +}
125 +func (m *DataObj) Size() (n int) {
126 + var l int
127 + _ = l
128 + l = len(m.FilePath)
129 + n += 1 + l + sovDataobj(uint64(l))
130 + n += 1 + sovDataobj(uint64(m.Offset))
131 + n += 1 + sovDataobj(uint64(m.Size_))
132 + return n
133 +}
134 +
135 +func sovDataobj(x uint64) (n int) {
136 + for {
137 + n++
138 + x >>= 7
139 + if x == 0 {
140 + break
141 + }
142 + }
143 + return n
144 +}
145 +func sozDataobj(x uint64) (n int) {
146 + return sovDataobj(uint64((x << 1) ^ uint64((int64(x) >> 63))))
147 +}
148 +func (m *DataObj) Unmarshal(dAtA []byte) error {
149 + l := len(dAtA)
150 + iNdEx := 0
151 + for iNdEx < l {
152 + preIndex := iNdEx
153 + var wire uint64
154 + for shift := uint(0); ; shift += 7 {
155 + if shift >= 64 {
156 + return ErrIntOverflowDataobj
157 + }
158 + if iNdEx >= l {
159 + return io.ErrUnexpectedEOF
160 + }
161 + b := dAtA[iNdEx]
162 + iNdEx++
163 + wire |= (uint64(b) & 0x7F) << shift
164 + if b < 0x80 {
165 + break
166 + }
167 + }
168 + fieldNum := int32(wire >> 3)
169 + wireType := int(wire & 0x7)
170 + if wireType == 4 {
171 + return fmt.Errorf("proto: DataObj: wiretype end group for non-group")
172 + }
173 + if fieldNum <= 0 {
174 + return fmt.Errorf("proto: DataObj: illegal tag %d (wire type %d)", fieldNum, wire)
175 + }
176 + switch fieldNum {
177 + case 1:
178 + if wireType != 2 {
179 + return fmt.Errorf("proto: wrong wireType = %d for field FilePath", wireType)
180 + }
181 + var stringLen uint64
182 + for shift := uint(0); ; shift += 7 {
183 + if shift >= 64 {
184 + return ErrIntOverflowDataobj
185 + }
186 + if iNdEx >= l {
187 + return io.ErrUnexpectedEOF
188 + }
189 + b := dAtA[iNdEx]
190 + iNdEx++
191 + stringLen |= (uint64(b) & 0x7F) << shift
192 + if b < 0x80 {
193 + break
194 + }
195 + }
196 + intStringLen := int(stringLen)
197 + if intStringLen < 0 {
198 + return ErrInvalidLengthDataobj
199 + }
200 + postIndex := iNdEx + intStringLen
201 + if postIndex > l {
202 + return io.ErrUnexpectedEOF
203 + }
204 + m.FilePath = string(dAtA[iNdEx:postIndex])
205 + iNdEx = postIndex
206 + case 2:
207 + if wireType != 0 {
208 + return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType)
209 + }
210 + m.Offset = 0
211 + for shift := uint(0); ; shift += 7 {
212 + if shift >= 64 {
213 + return ErrIntOverflowDataobj
214 + }
215 + if iNdEx >= l {
216 + return io.ErrUnexpectedEOF
217 + }
218 + b := dAtA[iNdEx]
219 + iNdEx++
220 + m.Offset |= (uint64(b) & 0x7F) << shift
221 + if b < 0x80 {
222 + break
223 + }
224 + }
225 + case 3:
226 + if wireType != 0 {
227 + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType)
228 + }
229 + m.Size_ = 0
230 + for shift := uint(0); ; shift += 7 {
231 + if shift >= 64 {
232 + return ErrIntOverflowDataobj
233 + }
234 + if iNdEx >= l {
235 + return io.ErrUnexpectedEOF
236 + }
237 + b := dAtA[iNdEx]
238 + iNdEx++
239 + m.Size_ |= (uint64(b) & 0x7F) << shift
240 + if b < 0x80 {
241 + break
242 + }
243 + }
244 + default:
245 + iNdEx = preIndex
246 + skippy, err := skipDataobj(dAtA[iNdEx:])
247 + if err != nil {
248 + return err
249 + }
250 + if skippy < 0 {
251 + return ErrInvalidLengthDataobj
252 + }
253 + if (iNdEx + skippy) > l {
254 + return io.ErrUnexpectedEOF
255 + }
256 + iNdEx += skippy
257 + }
258 + }
259 +
260 + if iNdEx > l {
261 + return io.ErrUnexpectedEOF
262 + }
263 + return nil
264 +}
265 +func skipDataobj(dAtA []byte) (n int, err error) {
266 + l := len(dAtA)
267 + iNdEx := 0
268 + for iNdEx < l {
269 + var wire uint64
270 + for shift := uint(0); ; shift += 7 {
271 + if shift >= 64 {
272 + return 0, ErrIntOverflowDataobj
273 + }
274 + if iNdEx >= l {
275 + return 0, io.ErrUnexpectedEOF
276 + }
277 + b := dAtA[iNdEx]
278 + iNdEx++
279 + wire |= (uint64(b) & 0x7F) << shift
280 + if b < 0x80 {
281 + break
282 + }
283 + }
284 + wireType := int(wire & 0x7)
285 + switch wireType {
286 + case 0:
287 + for shift := uint(0); ; shift += 7 {
288 + if shift >= 64 {
289 + return 0, ErrIntOverflowDataobj
290 + }
291 + if iNdEx >= l {
292 + return 0, io.ErrUnexpectedEOF
293 + }
294 + iNdEx++
295 + if dAtA[iNdEx-1] < 0x80 {
296 + break
297 + }
298 + }
299 + return iNdEx, nil
300 + case 1:
301 + iNdEx += 8
302 + return iNdEx, nil
303 + case 2:
304 + var length int
305 + for shift := uint(0); ; shift += 7 {
306 + if shift >= 64 {
307 + return 0, ErrIntOverflowDataobj
308 + }
309 + if iNdEx >= l {
310 + return 0, io.ErrUnexpectedEOF
311 + }
312 + b := dAtA[iNdEx]
313 + iNdEx++
314 + length |= (int(b) & 0x7F) << shift
315 + if b < 0x80 {
316 + break
317 + }
318 + }
319 + iNdEx += length
320 + if length < 0 {
321 + return 0, ErrInvalidLengthDataobj
322 + }
323 + return iNdEx, nil
324 + case 3:
325 + for {
326 + var innerWire uint64
327 + var start int = iNdEx
328 + for shift := uint(0); ; shift += 7 {
329 + if shift >= 64 {
330 + return 0, ErrIntOverflowDataobj
331 + }
332 + if iNdEx >= l {
333 + return 0, io.ErrUnexpectedEOF
334 + }
335 + b := dAtA[iNdEx]
336 + iNdEx++
337 + innerWire |= (uint64(b) & 0x7F) << shift
338 + if b < 0x80 {
339 + break
340 + }
341 + }
342 + innerWireType := int(innerWire & 0x7)
343 + if innerWireType == 4 {
344 + break
345 + }
346 + next, err := skipDataobj(dAtA[start:])
347 + if err != nil {
348 + return 0, err
349 + }
350 + iNdEx = start + next
351 + }
352 + return iNdEx, nil
353 + case 4:
354 + return iNdEx, nil
355 + case 5:
356 + iNdEx += 4
357 + return iNdEx, nil
358 + default:
359 + return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
360 + }
361 + }
362 + panic("unreachable")
363 +}
364 +
365 +var (
366 + ErrInvalidLengthDataobj = fmt.Errorf("proto: negative length found during unmarshaling")
367 + ErrIntOverflowDataobj = fmt.Errorf("proto: integer overflow")
368 +)
369 +
370 +func init() { proto.RegisterFile("filestore/pb/dataobj.proto", fileDescriptor_dataobj_216c555249812eeb) }
371 +
372 +var fileDescriptor_dataobj_216c555249812eeb = []byte{
373 + // 151 bytes of a gzipped FileDescriptorProto
374 + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xcb, 0xcc, 0x49,
375 + 0x2d, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2f, 0x48, 0xd2, 0x4f, 0x49, 0x2c, 0x49, 0xcc, 0x4f, 0xca,
376 + 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x71, 0xc1, 0x72, 0x7a, 0x05, 0x49, 0x4a,
377 + 0xc9, 0x5c, 0xec, 0x2e, 0x89, 0x25, 0x89, 0xfe, 0x49, 0x59, 0x42, 0x0a, 0x5c, 0x1c, 0x6e, 0x99,
378 + 0x39, 0xa9, 0x01, 0x89, 0x25, 0x19, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x2c, 0x27, 0xee,
379 + 0xc9, 0x33, 0x04, 0xc1, 0x45, 0x85, 0x64, 0xb8, 0xd8, 0xfc, 0xd3, 0xd2, 0x8a, 0x53, 0x4b, 0x24,
380 + 0x98, 0x14, 0x18, 0x35, 0x58, 0xa0, 0xf2, 0x50, 0x31, 0x21, 0x09, 0x2e, 0x96, 0xe0, 0xcc, 0xaa,
381 + 0x54, 0x09, 0x66, 0x24, 0x39, 0xb0, 0x88, 0x93, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9,
382 + 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0x03, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8c,
383 + 0xe7, 0x83, 0xa2, 0xa1, 0x00, 0x00, 0x00,
384 +}
filestore/pb/dataobj.proto
+2
@@ -1,3 +1,5 @@
1 +syntax = "proto2";
2 +
3 package datastore.pb;
4
5 message DataObj {
filestore/util.go
+6 -6
@@ -212,9 +212,9 @@ func listAllFileOrder(fs *Filestore, verify bool) (func() *ListRes, error) {
212 }
213 // now reconstruct the DataObj
214 dobj := pb.DataObj{
215 - FilePath: &v.filePath,
216 - Offset: &v.offset,
217 - Size_: &v.size,
215 + FilePath: v.filePath,
216 + Offset: v.offset,
217 + Size_: v.size,
218 }
219 // now if we could not convert the datastore key return that
220 // error
@@ -277,8 +277,8 @@ func mkListRes(c *cid.Cid, d *pb.DataObj, err error) *ListRes {
277 Status: status,
278 ErrorMsg: errorMsg,
279 Key: c,
280 - FilePath: *d.FilePath,
281 - Size: *d.Size_,
282 - Offset: *d.Offset,
280 + FilePath: d.FilePath,
281 + Size: d.Size_,
282 + Offset: d.Offset,
283 }
284 }
pin/internal/pb/header.pb.go
+334 -22
@@ -1,59 +1,371 @@
1 -// Code generated by protoc-gen-gogo.
2 -// source: header.proto
3 -// DO NOT EDIT!
1 +// Code generated by protoc-gen-gogo. DO NOT EDIT.
2 +// source: pin/internal/pb/header.proto
3
5 -/*
6 -Package pb is a generated protocol buffer package.
7 -
8 -It is generated from these files:
9 - header.proto
10 -
11 -It has these top-level messages:
12 - Set
13 -*/
4 package pb
5
6 import proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto"
7 +import fmt "fmt"
8 import math "math"
9
10 +import encoding_binary "encoding/binary"
11 +
12 +import io "io"
13 +
14 // Reference imports to suppress errors if they are not otherwise used.
15 var _ = proto.Marshal
16 +var _ = fmt.Errorf
17 var _ = math.Inf
18
19 +// This is a compile-time assertion to ensure that this generated file
20 +// is compatible with the proto package it is being compiled against.
21 +// A compilation error at this line likely means your copy of the
22 +// proto package needs to be updated.
23 +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
24 +
25 type Set struct {
26 // 1 for now, library will refuse to handle entries with an unrecognized version.
25 - Version *uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
27 + Version uint32 `protobuf:"varint,1,opt,name=version" json:"version"`
28 // how many of the links are subtrees
27 - Fanout *uint32 `protobuf:"varint,2,opt,name=fanout" json:"fanout,omitempty"`
29 + Fanout uint32 `protobuf:"varint,2,opt,name=fanout" json:"fanout"`
30 // hash seed for subtree selection, a random number
29 - Seed *uint32 `protobuf:"fixed32,3,opt,name=seed" json:"seed,omitempty"`
30 - XXX_unrecognized []byte `json:"-"`
31 + Seed uint32 `protobuf:"fixed32,3,opt,name=seed" json:"seed"`
32 + XXX_NoUnkeyedLiteral struct{} `json:"-"`
33 + XXX_sizecache int32 `json:"-"`
34 }
35
36 func (m *Set) Reset() { *m = Set{} }
37 func (m *Set) String() string { return proto.CompactTextString(m) }
38 func (*Set) ProtoMessage() {}
39 +func (*Set) Descriptor() ([]byte, []int) {
40 + return fileDescriptor_header_778100e52d428560, []int{0}
41 +}
42 +func (m *Set) XXX_Unmarshal(b []byte) error {
43 + return m.Unmarshal(b)
44 +}
45 +func (m *Set) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
46 + if deterministic {
47 + return xxx_messageInfo_Set.Marshal(b, m, deterministic)
48 + } else {
49 + b = b[:cap(b)]
50 + n, err := m.MarshalTo(b)
51 + if err != nil {
52 + return nil, err
53 + }
54 + return b[:n], nil
55 + }
56 +}
57 +func (dst *Set) XXX_Merge(src proto.Message) {
58 + xxx_messageInfo_Set.Merge(dst, src)
59 +}
60 +func (m *Set) XXX_Size() int {
61 + return m.Size()
62 +}
63 +func (m *Set) XXX_DiscardUnknown() {
64 + xxx_messageInfo_Set.DiscardUnknown(m)
65 +}
66 +
67 +var xxx_messageInfo_Set proto.InternalMessageInfo
68
69 func (m *Set) GetVersion() uint32 {
38 - if m != nil && m.Version != nil {
39 - return *m.Version
70 + if m != nil {
71 + return m.Version
72 }
73 return 0
74 }
75
76 func (m *Set) GetFanout() uint32 {
45 - if m != nil && m.Fanout != nil {
46 - return *m.Fanout
77 + if m != nil {
78 + return m.Fanout
79 }
80 return 0
81 }
82
83 func (m *Set) GetSeed() uint32 {
52 - if m != nil && m.Seed != nil {
53 - return *m.Seed
84 + if m != nil {
85 + return m.Seed
86 }
87 return 0
88 }
89
90 func init() {
91 + proto.RegisterType((*Set)(nil), "ipfs.pin.Set")
92 +}
93 +func (m *Set) Marshal() (dAtA []byte, err error) {
94 + size := m.Size()
95 + dAtA = make([]byte, size)
96 + n, err := m.MarshalTo(dAtA)
97 + if err != nil {
98 + return nil, err
99 + }
100 + return dAtA[:n], nil
101 +}
102 +
103 +func (m *Set) MarshalTo(dAtA []byte) (int, error) {
104 + var i int
105 + _ = i
106 + var l int
107 + _ = l
108 + dAtA[i] = 0x8
109 + i++
110 + i = encodeVarintHeader(dAtA, i, uint64(m.Version))
111 + dAtA[i] = 0x10
112 + i++
113 + i = encodeVarintHeader(dAtA, i, uint64(m.Fanout))
114 + dAtA[i] = 0x1d
115 + i++
116 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Seed))
117 + i += 4
118 + return i, nil
119 +}
120 +
121 +func encodeVarintHeader(dAtA []byte, offset int, v uint64) int {
122 + for v >= 1<<7 {
123 + dAtA[offset] = uint8(v&0x7f | 0x80)
124 + v >>= 7
125 + offset++
126 + }
127 + dAtA[offset] = uint8(v)
128 + return offset + 1
129 +}
130 +func (m *Set) Size() (n int) {
131 + var l int
132 + _ = l
133 + n += 1 + sovHeader(uint64(m.Version))
134 + n += 1 + sovHeader(uint64(m.Fanout))
135 + n += 5
136 + return n
137 +}
138 +
139 +func sovHeader(x uint64) (n int) {
140 + for {
141 + n++
142 + x >>= 7
143 + if x == 0 {
144 + break
145 + }
146 + }
147 + return n
148 +}
149 +func sozHeader(x uint64) (n int) {
150 + return sovHeader(uint64((x << 1) ^ uint64((int64(x) >> 63))))
151 +}
152 +func (m *Set) Unmarshal(dAtA []byte) error {
153 + l := len(dAtA)
154 + iNdEx := 0
155 + for iNdEx < l {
156 + preIndex := iNdEx
157 + var wire uint64
158 + for shift := uint(0); ; shift += 7 {
159 + if shift >= 64 {
160 + return ErrIntOverflowHeader
161 + }
162 + if iNdEx >= l {
163 + return io.ErrUnexpectedEOF
164 + }
165 + b := dAtA[iNdEx]
166 + iNdEx++
167 + wire |= (uint64(b) & 0x7F) << shift
168 + if b < 0x80 {
169 + break
170 + }
171 + }
172 + fieldNum := int32(wire >> 3)
173 + wireType := int(wire & 0x7)
174 + if wireType == 4 {
175 + return fmt.Errorf("proto: Set: wiretype end group for non-group")
176 + }
177 + if fieldNum <= 0 {
178 + return fmt.Errorf("proto: Set: illegal tag %d (wire type %d)", fieldNum, wire)
179 + }
180 + switch fieldNum {
181 + case 1:
182 + if wireType != 0 {
183 + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
184 + }
185 + m.Version = 0
186 + for shift := uint(0); ; shift += 7 {
187 + if shift >= 64 {
188 + return ErrIntOverflowHeader
189 + }
190 + if iNdEx >= l {
191 + return io.ErrUnexpectedEOF
192 + }
193 + b := dAtA[iNdEx]
194 + iNdEx++
195 + m.Version |= (uint32(b) & 0x7F) << shift
196 + if b < 0x80 {
197 + break
198 + }
199 + }
200 + case 2:
201 + if wireType != 0 {
202 + return fmt.Errorf("proto: wrong wireType = %d for field Fanout", wireType)
203 + }
204 + m.Fanout = 0
205 + for shift := uint(0); ; shift += 7 {
206 + if shift >= 64 {
207 + return ErrIntOverflowHeader
208 + }
209 + if iNdEx >= l {
210 + return io.ErrUnexpectedEOF
211 + }
212 + b := dAtA[iNdEx]
213 + iNdEx++
214 + m.Fanout |= (uint32(b) & 0x7F) << shift
215 + if b < 0x80 {
216 + break
217 + }
218 + }
219 + case 3:
220 + if wireType != 5 {
221 + return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType)
222 + }
223 + m.Seed = 0
224 + if (iNdEx + 4) > l {
225 + return io.ErrUnexpectedEOF
226 + }
227 + m.Seed = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:]))
228 + iNdEx += 4
229 + default:
230 + iNdEx = preIndex
231 + skippy, err := skipHeader(dAtA[iNdEx:])
232 + if err != nil {
233 + return err
234 + }
235 + if skippy < 0 {
236 + return ErrInvalidLengthHeader
237 + }
238 + if (iNdEx + skippy) > l {
239 + return io.ErrUnexpectedEOF
240 + }
241 + iNdEx += skippy
242 + }
243 + }
244 +
245 + if iNdEx > l {
246 + return io.ErrUnexpectedEOF
247 + }
248 + return nil
249 +}
250 +func skipHeader(dAtA []byte) (n int, err error) {
251 + l := len(dAtA)
252 + iNdEx := 0
253 + for iNdEx < l {
254 + var wire uint64
255 + for shift := uint(0); ; shift += 7 {
256 + if shift >= 64 {
257 + return 0, ErrIntOverflowHeader
258 + }
259 + if iNdEx >= l {
260 + return 0, io.ErrUnexpectedEOF
261 + }
262 + b := dAtA[iNdEx]
263 + iNdEx++
264 + wire |= (uint64(b) & 0x7F) << shift
265 + if b < 0x80 {
266 + break
267 + }
268 + }
269 + wireType := int(wire & 0x7)
270 + switch wireType {
271 + case 0:
272 + for shift := uint(0); ; shift += 7 {
273 + if shift >= 64 {
274 + return 0, ErrIntOverflowHeader
275 + }
276 + if iNdEx >= l {
277 + return 0, io.ErrUnexpectedEOF
278 + }
279 + iNdEx++
280 + if dAtA[iNdEx-1] < 0x80 {
281 + break
282 + }
283 + }
284 + return iNdEx, nil
285 + case 1:
286 + iNdEx += 8
287 + return iNdEx, nil
288 + case 2:
289 + var length int
290 + for shift := uint(0); ; shift += 7 {
291 + if shift >= 64 {
292 + return 0, ErrIntOverflowHeader
293 + }
294 + if iNdEx >= l {
295 + return 0, io.ErrUnexpectedEOF
296 + }
297 + b := dAtA[iNdEx]
298 + iNdEx++
299 + length |= (int(b) & 0x7F) << shift
300 + if b < 0x80 {
301 + break
302 + }
303 + }
304 + iNdEx += length
305 + if length < 0 {
306 + return 0, ErrInvalidLengthHeader
307 + }
308 + return iNdEx, nil
309 + case 3:
310 + for {
311 + var innerWire uint64
312 + var start int = iNdEx
313 + for shift := uint(0); ; shift += 7 {
314 + if shift >= 64 {
315 + return 0, ErrIntOverflowHeader
316 + }
317 + if iNdEx >= l {
318 + return 0, io.ErrUnexpectedEOF
319 + }
320 + b := dAtA[iNdEx]
321 + iNdEx++
322 + innerWire |= (uint64(b) & 0x7F) << shift
323 + if b < 0x80 {
324 + break
325 + }
326 + }
327 + innerWireType := int(innerWire & 0x7)
328 + if innerWireType == 4 {
329 + break
330 + }
331 + next, err := skipHeader(dAtA[start:])
332 + if err != nil {
333 + return 0, err
334 + }
335 + iNdEx = start + next
336 + }
337 + return iNdEx, nil
338 + case 4:
339 + return iNdEx, nil
340 + case 5:
341 + iNdEx += 4
342 + return iNdEx, nil
343 + default:
344 + return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
345 + }
346 + }
347 + panic("unreachable")
348 +}
349 +
350 +var (
351 + ErrInvalidLengthHeader = fmt.Errorf("proto: negative length found during unmarshaling")
352 + ErrIntOverflowHeader = fmt.Errorf("proto: integer overflow")
353 +)
354 +
355 +func init() {
356 + proto.RegisterFile("pin/internal/pb/header.proto", fileDescriptor_header_778100e52d428560)
357 +}
358 +
359 +var fileDescriptor_header_778100e52d428560 = []byte{
360 + // 154 bytes of a gzipped FileDescriptorProto
361 + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xc8, 0xcc, 0xd3,
362 + 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0xd1, 0x2f, 0x48, 0xd2, 0xcf, 0x48, 0x4d, 0x4c,
363 + 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc8, 0x2c, 0x48, 0x2b, 0xd6, 0x2b,
364 + 0xc8, 0xcc, 0x53, 0x8a, 0xe5, 0x62, 0x0e, 0x4e, 0x2d, 0x11, 0x92, 0xe3, 0x62, 0x2f, 0x4b, 0x2d,
365 + 0x2a, 0xce, 0xcc, 0xcf, 0x93, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x75, 0x62, 0x39, 0x71, 0x4f, 0x9e,
366 + 0x21, 0x08, 0x26, 0x28, 0x24, 0xc3, 0xc5, 0x96, 0x96, 0x98, 0x97, 0x5f, 0x5a, 0x22, 0xc1, 0x84,
367 + 0x24, 0x0d, 0x15, 0x13, 0x92, 0xe0, 0x62, 0x29, 0x4e, 0x4d, 0x4d, 0x91, 0x60, 0x56, 0x60, 0xd4,
368 + 0x60, 0x87, 0xca, 0x81, 0x45, 0x9c, 0x44, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1,
369 + 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0xa2, 0x98, 0x0a, 0x92, 0x00, 0x01, 0x00, 0x00,
370 + 0xff, 0xff, 0xc3, 0xf9, 0x7f, 0x24, 0x9d, 0x00, 0x00, 0x00,
371 }
pin/set.go
+3 -3
@@ -67,9 +67,9 @@ func storeItems(ctx context.Context, dag ipld.DAGService, estimatedLen uint64, d
67 internalKeys(emptyKey)
68
69 hdr := &pb.Set{
70 - Version: proto.Uint32(1),
71 - Fanout: proto.Uint32(defaultFanout),
72 - Seed: proto.Uint32(depth),
70 + Version: 1,
71 + Fanout: defaultFanout,
72 + Seed: depth,
73 }
74 if err := writeHdr(n, hdr); err != nil {
75 return nil, err