diff --git a/Makefile b/Makefile index 9f5e509d60c..4bd63ac03a1 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL=PATH='$(PATH)' /bin/sh -PROTOC = protoc --gogo_out=. --proto_path=.:/usr/local/opt/protobuf/include:$(dir $@) $< +PROTOC = protoc --gogofaster_out=. --proto_path=.:$(GOPATH)/src:$(dir $@) $< # enable second expansion .SECONDEXPANSION: diff --git a/Rules.mk b/Rules.mk index 8178dd96a57..8cb3a623f4d 100644 --- a/Rules.mk +++ b/Rules.mk @@ -50,6 +50,9 @@ endif dir := pin/internal/pb include $(dir)/Rules.mk +dir := filestore/pb +include $(dir)/Rules.mk + # -------------------- # # universal rules # diff --git a/filestore/fsrefstore.go b/filestore/fsrefstore.go index eb9c7d7e169..81b68753799 100644 --- a/filestore/fsrefstore.go +++ b/filestore/fsrefstore.go @@ -17,8 +17,8 @@ import ( dsq "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/query" blockstore "gx/ipfs/QmYBEfMSquSGnuxBthUoBJNs3F6p4VAPPvAgxq6XXGvTPh/go-ipfs-blockstore" cid "gx/ipfs/QmYjnkEL7i731PirfVH1sis89evN7jt4otSHw5D2xXXwUV/go-cid" - proto "gx/ipfs/QmZHU2gx42NPTYXzw6pJkuX6xCE7bKECp6e8QcPdoLx8sx/protobuf/proto" posinfo "gx/ipfs/QmdBpJ5VTfL79VwKDU93z7fyZJ3mm4UaBHrE73CWRw2Bjd/go-ipfs-posinfo" + proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto" ) // FilestorePrefix identifies the key prefix for FileManager blocks. @@ -276,7 +276,7 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error { if !f.AllowUrls { return ErrUrlstoreNotEnabled } - dobj.FilePath = proto.String(b.PosInfo.FullPath) + dobj.FilePath = b.PosInfo.FullPath } else { if !f.AllowFiles { return ErrFilestoreNotEnabled @@ -290,10 +290,10 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error { return err } - dobj.FilePath = proto.String(filepath.ToSlash(p)) + dobj.FilePath = filepath.ToSlash(p) } - dobj.Offset = proto.Uint64(b.PosInfo.Offset) - dobj.Size_ = proto.Uint64(uint64(len(b.RawData()))) + dobj.Offset = b.PosInfo.Offset + dobj.Size_ = uint64(len(b.RawData())) data, err := proto.Marshal(&dobj) if err != nil { diff --git a/filestore/pb/Makefile b/filestore/pb/Makefile deleted file mode 100644 index 5101a482d20..00000000000 --- a/filestore/pb/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -PB = $(wildcard *.proto) -GO = $(PB:.proto=.pb.go) - -all: $(GO) - -%.pb.go: %.proto - protoc --gogo_out=. $< - -clean: - rm *.pb.go diff --git a/filestore/pb/Rules.mk b/filestore/pb/Rules.mk new file mode 100644 index 00000000000..505f70e7541 --- /dev/null +++ b/filestore/pb/Rules.mk @@ -0,0 +1,8 @@ +include mk/header.mk + +PB_$(d) = $(wildcard $(d)/*.proto) +TGTS_$(d) = $(PB_$(d):.proto=.pb.go) + +#DEPS_GO += $(TGTS_$(d)) + +include mk/footer.mk diff --git a/filestore/pb/dataobj.pb.go b/filestore/pb/dataobj.pb.go index 3ddf730810f..6046acbd624 100644 --- a/filestore/pb/dataobj.pb.go +++ b/filestore/pb/dataobj.pb.go @@ -1,55 +1,83 @@ -// Code generated by protoc-gen-gogo. -// source: dataobj.proto -// DO NOT EDIT! +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: filestore/pb/dataobj.proto -/* -Package datastore_pb is a generated protocol buffer package. - -It is generated from these files: - dataobj.proto - -It has these top-level messages: - DataObj -*/ package datastore_pb import proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto" import fmt "fmt" import math "math" +import io "io" + // Reference imports to suppress errors if they are not otherwise used. 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 DataObj struct { - FilePath *string `protobuf:"bytes,1,opt,name=FilePath" json:"FilePath,omitempty"` - Offset *uint64 `protobuf:"varint,2,opt,name=Offset" json:"Offset,omitempty"` - Size_ *uint64 `protobuf:"varint,3,opt,name=Size" json:"Size,omitempty"` - XXX_unrecognized []byte `json:"-"` + FilePath string `protobuf:"bytes,1,opt,name=FilePath" json:"FilePath"` + Offset uint64 `protobuf:"varint,2,opt,name=Offset" json:"Offset"` + Size_ uint64 `protobuf:"varint,3,opt,name=Size" json:"Size"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *DataObj) Reset() { *m = DataObj{} } func (m *DataObj) String() string { return proto.CompactTextString(m) } func (*DataObj) ProtoMessage() {} +func (*DataObj) Descriptor() ([]byte, []int) { + return fileDescriptor_dataobj_216c555249812eeb, []int{0} +} +func (m *DataObj) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DataObj) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DataObj.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *DataObj) XXX_Merge(src proto.Message) { + xxx_messageInfo_DataObj.Merge(dst, src) +} +func (m *DataObj) XXX_Size() int { + return m.Size() +} +func (m *DataObj) XXX_DiscardUnknown() { + xxx_messageInfo_DataObj.DiscardUnknown(m) +} + +var xxx_messageInfo_DataObj proto.InternalMessageInfo func (m *DataObj) GetFilePath() string { - if m != nil && m.FilePath != nil { - return *m.FilePath + if m != nil { + return m.FilePath } return "" } func (m *DataObj) GetOffset() uint64 { - if m != nil && m.Offset != nil { - return *m.Offset + if m != nil { + return m.Offset } return 0 } func (m *DataObj) GetSize_() uint64 { - if m != nil && m.Size_ != nil { - return *m.Size_ + if m != nil { + return m.Size_ } return 0 } @@ -57,3 +85,300 @@ func (m *DataObj) GetSize_() uint64 { func init() { proto.RegisterType((*DataObj)(nil), "datastore.pb.DataObj") } +func (m *DataObj) 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 *DataObj) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintDataobj(dAtA, i, uint64(len(m.FilePath))) + i += copy(dAtA[i:], m.FilePath) + dAtA[i] = 0x10 + i++ + i = encodeVarintDataobj(dAtA, i, uint64(m.Offset)) + dAtA[i] = 0x18 + i++ + i = encodeVarintDataobj(dAtA, i, uint64(m.Size_)) + return i, nil +} + +func encodeVarintDataobj(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *DataObj) Size() (n int) { + var l int + _ = l + l = len(m.FilePath) + n += 1 + l + sovDataobj(uint64(l)) + n += 1 + sovDataobj(uint64(m.Offset)) + n += 1 + sovDataobj(uint64(m.Size_)) + return n +} + +func sovDataobj(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozDataobj(x uint64) (n int) { + return sovDataobj(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DataObj) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataobj + } + 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: DataObj: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DataObj: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FilePath", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataobj + } + 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 ErrInvalidLengthDataobj + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FilePath = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) + } + m.Offset = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataobj + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Offset |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDataobj + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipDataobj(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDataobj + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDataobj(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataobj + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataobj + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataobj + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthDataobj + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDataobj + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipDataobj(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthDataobj = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDataobj = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("filestore/pb/dataobj.proto", fileDescriptor_dataobj_216c555249812eeb) } + +var fileDescriptor_dataobj_216c555249812eeb = []byte{ + // 151 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xcb, 0xcc, 0x49, + 0x2d, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2f, 0x48, 0xd2, 0x4f, 0x49, 0x2c, 0x49, 0xcc, 0x4f, 0xca, + 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x71, 0xc1, 0x72, 0x7a, 0x05, 0x49, 0x4a, + 0xc9, 0x5c, 0xec, 0x2e, 0x89, 0x25, 0x89, 0xfe, 0x49, 0x59, 0x42, 0x0a, 0x5c, 0x1c, 0x6e, 0x99, + 0x39, 0xa9, 0x01, 0x89, 0x25, 0x19, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x2c, 0x27, 0xee, + 0xc9, 0x33, 0x04, 0xc1, 0x45, 0x85, 0x64, 0xb8, 0xd8, 0xfc, 0xd3, 0xd2, 0x8a, 0x53, 0x4b, 0x24, + 0x98, 0x14, 0x18, 0x35, 0x58, 0xa0, 0xf2, 0x50, 0x31, 0x21, 0x09, 0x2e, 0x96, 0xe0, 0xcc, 0xaa, + 0x54, 0x09, 0x66, 0x24, 0x39, 0xb0, 0x88, 0x93, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, + 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0x03, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8c, + 0xe7, 0x83, 0xa2, 0xa1, 0x00, 0x00, 0x00, +} diff --git a/filestore/pb/dataobj.proto b/filestore/pb/dataobj.proto index c7d7f0eea8f..909d22b77f9 100644 --- a/filestore/pb/dataobj.proto +++ b/filestore/pb/dataobj.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + package datastore.pb; message DataObj { diff --git a/filestore/util.go b/filestore/util.go index 0cdbad8de85..d0e25c8d449 100644 --- a/filestore/util.go +++ b/filestore/util.go @@ -212,9 +212,9 @@ func listAllFileOrder(fs *Filestore, verify bool) (func() *ListRes, error) { } // now reconstruct the DataObj dobj := pb.DataObj{ - FilePath: &v.filePath, - Offset: &v.offset, - Size_: &v.size, + FilePath: v.filePath, + Offset: v.offset, + Size_: v.size, } // now if we could not convert the datastore key return that // error @@ -277,8 +277,8 @@ func mkListRes(c *cid.Cid, d *pb.DataObj, err error) *ListRes { Status: status, ErrorMsg: errorMsg, Key: c, - FilePath: *d.FilePath, - Size: *d.Size_, - Offset: *d.Offset, + FilePath: d.FilePath, + Size: d.Size_, + Offset: d.Offset, } } diff --git a/package.json b/package.json index 2c88ea00e18..d96d5267235 100644 --- a/package.json +++ b/package.json @@ -80,12 +80,6 @@ "name": "go-humanize", "version": "0.0.0" }, - { - "author": "facebookgo", - "hash": "QmdYwCmx8pZRkzdcd8MhmLJqYVoVTC1aGsy5Q4reMGLNLg", - "name": "atomicfile", - "version": "0.0.0" - }, { "author": "syndtr", "hash": "QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g", @@ -240,18 +234,6 @@ "name": "fuse", "version": "0.2.3" }, - { - "author": "whyrusleeping", - "hash": "QmfJHywXQu98UeZtGJBQrPAR6AtmDjjbe3qjTo9piXHPnx", - "name": "murmur3", - "version": "0.0.0" - }, - { - "author": "whyrusleeping", - "hash": "QmVkii6Urke4akPoToq96XsFB8AuY81MzHKYE8DfJvDJq9", - "name": "go-libp2p-netutil", - "version": "0.4.5" - }, { "hash": "Qmb78zos2Et876AhvCemEkZQmmAmsDrNF62Ljh2mUpShAR", "name": "go-libp2p-kbucket", @@ -305,12 +287,6 @@ "name": "multiaddr-filter", "version": "1.0.2" }, - { - "author": "whyrusleeping", - "hash": "QmZHU2gx42NPTYXzw6pJkuX6xCE7bKECp6e8QcPdoLx8sx", - "name": "protobuf", - "version": "3.6.0" - }, { "author": "whyrusleeping", "hash": "QmQ1hwb95uSSZR8jSPJysnfHxBDQAykSXsmz5TwTzxjq2Z", @@ -438,24 +414,6 @@ "name": "go-detect-race", "version": "1.0.1" }, - { - "author": "hsanjuan", - "hash": "QmRJVNatYJwTAHgdSM1Xef9QVQ1Ch3XHdmcrykjP5Y4soL", - "name": "go-ipfs-delay", - "version": "0.0.1" - }, - { - "author": "hsanjuan", - "hash": "QmRMGdC6HKdLsPDABL9aXPDidrpmEHzJqFWSvshkbn9Hj8", - "name": "go-ipfs-flags", - "version": "0.0.1" - }, - { - "author": "hsanjuan", - "hash": "QmZUbTDJ39JpvtFCSubiWeUTQRvMA1tVE5RZCJrY4oeAsC", - "name": "go-ipfs-pq", - "version": "0.0.1" - }, { "author": "hsanjuan", "hash": "QmSLS8mMWsm54vdQuwgde9wBgLg5usVQY4i9r8kXhfje8g", @@ -474,12 +432,6 @@ "name": "go-ipfs-blockstore", "version": "0.0.17" }, - { - "author": "why", - "hash": "QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2", - "name": "pubsub", - "version": "1.0.0" - }, { "author": "whyrusleeping", "hash": "QmQine7gvHncNevKtG9QXxf3nXcwSj6aDDmMm52mHofEEp", @@ -504,24 +456,12 @@ "name": "go-ipfs-exchange-interface", "version": "0.0.5" }, - { - "author": "hsanjuan", - "hash": "QmULGpFvsz5K8PtpdHt88vRwQAQhSdEAUoKYQP6ntpyvTG", - "name": "go-ipfs-blocksutil", - "version": "0.0.5" - }, { "author": "hsanjuan", "hash": "QmVozMmsgK2PYyaHQsrcWLBYigb1m6mW8YhCBG2Cb4Uxq9", "name": "go-ipfs-exchange-offline", "version": "0.0.15" }, - { - "author": "Stebalien", - "hash": "QmTbBs3Y3u5F69XNJzdnnc6SP5GKgcXxCDzx6w8m6piVRT", - "name": "go-bitfield", - "version": "0.1.1" - }, { "author": "stebalien", "hash": "QmRXZNuxRue83mzP3tFafw1xa6sT9no5o3oN6WbwrKNFHe", diff --git a/pin/internal/pb/header.pb.go b/pin/internal/pb/header.pb.go index 6a620c9e729..ca4173c3ead 100644 --- a/pin/internal/pb/header.pb.go +++ b/pin/internal/pb/header.pb.go @@ -1,59 +1,371 @@ -// Code generated by protoc-gen-gogo. -// source: header.proto -// DO NOT EDIT! +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pin/internal/pb/header.proto -/* -Package pb is a generated protocol buffer package. - -It is generated from these files: - header.proto - -It has these top-level messages: - Set -*/ package pb import proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto" +import fmt "fmt" import math "math" +import encoding_binary "encoding/binary" + +import io "io" + // Reference imports to suppress errors if they are not otherwise used. 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 Set struct { // 1 for now, library will refuse to handle entries with an unrecognized version. - Version *uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` + Version uint32 `protobuf:"varint,1,opt,name=version" json:"version"` // how many of the links are subtrees - Fanout *uint32 `protobuf:"varint,2,opt,name=fanout" json:"fanout,omitempty"` + Fanout uint32 `protobuf:"varint,2,opt,name=fanout" json:"fanout"` // hash seed for subtree selection, a random number - Seed *uint32 `protobuf:"fixed32,3,opt,name=seed" json:"seed,omitempty"` - XXX_unrecognized []byte `json:"-"` + Seed uint32 `protobuf:"fixed32,3,opt,name=seed" json:"seed"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Set) Reset() { *m = Set{} } func (m *Set) String() string { return proto.CompactTextString(m) } func (*Set) ProtoMessage() {} +func (*Set) Descriptor() ([]byte, []int) { + return fileDescriptor_header_778100e52d428560, []int{0} +} +func (m *Set) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Set) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Set.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *Set) XXX_Merge(src proto.Message) { + xxx_messageInfo_Set.Merge(dst, src) +} +func (m *Set) XXX_Size() int { + return m.Size() +} +func (m *Set) XXX_DiscardUnknown() { + xxx_messageInfo_Set.DiscardUnknown(m) +} + +var xxx_messageInfo_Set proto.InternalMessageInfo func (m *Set) GetVersion() uint32 { - if m != nil && m.Version != nil { - return *m.Version + if m != nil { + return m.Version } return 0 } func (m *Set) GetFanout() uint32 { - if m != nil && m.Fanout != nil { - return *m.Fanout + if m != nil { + return m.Fanout } return 0 } func (m *Set) GetSeed() uint32 { - if m != nil && m.Seed != nil { - return *m.Seed + if m != nil { + return m.Seed } return 0 } func init() { + proto.RegisterType((*Set)(nil), "ipfs.pin.Set") +} +func (m *Set) 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 *Set) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0x8 + i++ + i = encodeVarintHeader(dAtA, i, uint64(m.Version)) + dAtA[i] = 0x10 + i++ + i = encodeVarintHeader(dAtA, i, uint64(m.Fanout)) + dAtA[i] = 0x1d + i++ + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Seed)) + i += 4 + return i, nil +} + +func encodeVarintHeader(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *Set) Size() (n int) { + var l int + _ = l + n += 1 + sovHeader(uint64(m.Version)) + n += 1 + sovHeader(uint64(m.Fanout)) + n += 5 + return n +} + +func sovHeader(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozHeader(x uint64) (n int) { + return sovHeader(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Set) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeader + } + 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: Set: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Set: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Fanout", wireType) + } + m.Fanout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHeader + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Fanout |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType) + } + m.Seed = 0 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + m.Seed = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + default: + iNdEx = preIndex + skippy, err := skipHeader(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthHeader + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipHeader(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthHeader + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHeader + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipHeader(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthHeader = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowHeader = fmt.Errorf("proto: integer overflow") +) + +func init() { + proto.RegisterFile("pin/internal/pb/header.proto", fileDescriptor_header_778100e52d428560) +} + +var fileDescriptor_header_778100e52d428560 = []byte{ + // 154 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xc8, 0xcc, 0xd3, + 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0xd1, 0x2f, 0x48, 0xd2, 0xcf, 0x48, 0x4d, 0x4c, + 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc8, 0x2c, 0x48, 0x2b, 0xd6, 0x2b, + 0xc8, 0xcc, 0x53, 0x8a, 0xe5, 0x62, 0x0e, 0x4e, 0x2d, 0x11, 0x92, 0xe3, 0x62, 0x2f, 0x4b, 0x2d, + 0x2a, 0xce, 0xcc, 0xcf, 0x93, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x75, 0x62, 0x39, 0x71, 0x4f, 0x9e, + 0x21, 0x08, 0x26, 0x28, 0x24, 0xc3, 0xc5, 0x96, 0x96, 0x98, 0x97, 0x5f, 0x5a, 0x22, 0xc1, 0x84, + 0x24, 0x0d, 0x15, 0x13, 0x92, 0xe0, 0x62, 0x29, 0x4e, 0x4d, 0x4d, 0x91, 0x60, 0x56, 0x60, 0xd4, + 0x60, 0x87, 0xca, 0x81, 0x45, 0x9c, 0x44, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, + 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0xa2, 0x98, 0x0a, 0x92, 0x00, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xc3, 0xf9, 0x7f, 0x24, 0x9d, 0x00, 0x00, 0x00, } diff --git a/pin/set.go b/pin/set.go index 19accabe626..a95978f98fc 100644 --- a/pin/set.go +++ b/pin/set.go @@ -67,9 +67,9 @@ func storeItems(ctx context.Context, dag ipld.DAGService, estimatedLen uint64, d internalKeys(emptyKey) hdr := &pb.Set{ - Version: proto.Uint32(1), - Fanout: proto.Uint32(defaultFanout), - Seed: proto.Uint32(depth), + Version: 1, + Fanout: defaultFanout, + Seed: depth, } if err := writeHdr(n, hdr); err != nil { return nil, err