diff --git a/CHANGELOG.md b/CHANGELOG.md index 64de89251..d3d0046cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The following emojis are used to highlight certain changes: ### Changed - upgrade to `go-libp2p` [v0.39.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.39.0) +- upgrade to `go-libp2p-kad-dht` [v0.29.0](github.com/libp2p/go-libp2p-kad-dht v0.29.0) ### Removed diff --git a/bitswap/message/message.go b/bitswap/message/message.go index f673848dc..f0063d8f6 100644 --- a/bitswap/message/message.go +++ b/bitswap/message/message.go @@ -13,6 +13,7 @@ import ( pool "github.com/libp2p/go-buffer-pool" "github.com/libp2p/go-libp2p/core/network" msgio "github.com/libp2p/go-msgio" + "google.golang.org/protobuf/proto" ) // BitSwapMessage is the basic interface for interacting building, encoding, @@ -107,14 +108,13 @@ type Entry struct { // Get the size of the entry on the wire func (e *Entry) Size() int { - epb := e.ToPB() - return epb.Size() + return proto.Size(e.ToPB()) } // Get the entry in protobuf form -func (e *Entry) ToPB() pb.Message_Wantlist_Entry { - return pb.Message_Wantlist_Entry{ - Block: pb.Cid{Cid: e.Cid}, +func (e *Entry) ToPB() *pb.Message_Wantlist_Entry { + return &pb.Message_Wantlist_Entry{ + Block: e.Cid.Bytes(), Priority: e.Priority, Cancel: e.Cancel, WantType: e.WantType, @@ -192,10 +192,14 @@ var errCidMissing = errors.New("missing cid") func newMessageFromProto(pbm pb.Message) (BitSwapMessage, error) { m := newMsg(pbm.Wantlist.Full) for _, e := range pbm.Wantlist.Entries { - if !e.Block.Cid.Defined() { + if len(e.Block) == 0 { return nil, errCidMissing } - m.addEntry(e.Block.Cid, e.Priority, e.Cancel, e.WantType, e.SendDontHave) + c, err := cid.Cast(e.Block) + if err != nil { + return nil, err + } + m.addEntry(c, e.Priority, e.Cancel, e.WantType, e.SendDontHave) } // deprecated @@ -226,10 +230,17 @@ func newMessageFromProto(pbm pb.Message) (BitSwapMessage, error) { } for _, bi := range pbm.GetBlockPresences() { - if !bi.Cid.Cid.Defined() { + if len(bi.Cid) == 0 { + return nil, errCidMissing + } + c, err := cid.Cast(bi.Cid) + if err != nil { + return nil, err + } + if !c.Defined() { return nil, errCidMissing } - m.AddBlockPresence(bi.Cid.Cid, bi.Type) + m.AddBlockPresence(c, bi.Type) } m.pendingBytes = pbm.PendingBytes @@ -398,10 +409,10 @@ func (m *impl) Size() int { } func BlockPresenceSize(c cid.Cid) int { - return (&pb.Message_BlockPresence{ - Cid: pb.Cid{Cid: c}, + return proto.Size(&pb.Message_BlockPresence{ + Cid: c.Bytes(), Type: pb.Message_Have, - }).Size() + }) } // FromNet generates a new BitswapMessage from incoming data on an io.Reader. @@ -410,7 +421,7 @@ func FromNet(r io.Reader) (BitSwapMessage, error) { return FromMsgReader(reader) } -// FromPBReader generates a new Bitswap message from a gogo-protobuf reader +// FromPBReader generates a new Bitswap message from a protobuf reader. func FromMsgReader(r msgio.Reader) (BitSwapMessage, error) { msg, err := r.ReadMsg() if err != nil { @@ -418,7 +429,7 @@ func FromMsgReader(r msgio.Reader) (BitSwapMessage, error) { } var pb pb.Message - err = pb.Unmarshal(msg) + err = proto.Unmarshal(msg, &pb) r.ReleaseMsg(msg) if err != nil { return nil, err @@ -428,8 +439,12 @@ func FromMsgReader(r msgio.Reader) (BitSwapMessage, error) { } func (m *impl) ToProtoV0() *pb.Message { - pbm := new(pb.Message) - pbm.Wantlist.Entries = make([]pb.Message_Wantlist_Entry, 0, len(m.wantlist)) + pbm := &pb.Message{ + Wantlist: &pb.Message_Wantlist{ + Entries: make([]*pb.Message_Wantlist_Entry, 0, len(m.wantlist)), + }, + } + for _, e := range m.wantlist { pbm.Wantlist.Entries = append(pbm.Wantlist.Entries, e.ToPB()) } @@ -444,26 +459,30 @@ func (m *impl) ToProtoV0() *pb.Message { } func (m *impl) ToProtoV1() *pb.Message { - pbm := new(pb.Message) - pbm.Wantlist.Entries = make([]pb.Message_Wantlist_Entry, 0, len(m.wantlist)) + pbm := &pb.Message{ + Wantlist: &pb.Message_Wantlist{ + Entries: make([]*pb.Message_Wantlist_Entry, 0, len(m.wantlist)), + }, + } + for _, e := range m.wantlist { pbm.Wantlist.Entries = append(pbm.Wantlist.Entries, e.ToPB()) } pbm.Wantlist.Full = m.full blocks := m.Blocks() - pbm.Payload = make([]pb.Message_Block, 0, len(blocks)) + pbm.Payload = make([]*pb.Message_Block, 0, len(blocks)) for _, b := range blocks { - pbm.Payload = append(pbm.Payload, pb.Message_Block{ + pbm.Payload = append(pbm.Payload, &pb.Message_Block{ Data: b.RawData(), Prefix: b.Cid().Prefix().Bytes(), }) } - pbm.BlockPresences = make([]pb.Message_BlockPresence, 0, len(m.blockPresences)) + pbm.BlockPresences = make([]*pb.Message_BlockPresence, 0, len(m.blockPresences)) for c, t := range m.blockPresences { - pbm.BlockPresences = append(pbm.BlockPresences, pb.Message_BlockPresence{ - Cid: pb.Cid{Cid: c}, + pbm.BlockPresences = append(pbm.BlockPresences, &pb.Message_BlockPresence{ + Cid: c.Bytes(), Type: t, }) } @@ -482,18 +501,19 @@ func (m *impl) ToNetV1(w io.Writer) error { } func write(w io.Writer, m *pb.Message) error { - size := m.Size() + size := proto.Size(m) buf := pool.Get(size + binary.MaxVarintLen64) defer pool.Put(buf) n := binary.PutUvarint(buf, uint64(size)) - written, err := m.MarshalTo(buf[n:]) + opts := proto.MarshalOptions{} + written, err := opts.MarshalAppend(buf[:n], m) if err != nil { return err } - n += written + n += len(written) _, err = w.Write(buf[:n]) return err diff --git a/bitswap/message/message_test.go b/bitswap/message/message_test.go index 11f686a39..9253778bf 100644 --- a/bitswap/message/message_test.go +++ b/bitswap/message/message_test.go @@ -10,6 +10,7 @@ import ( blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" "github.com/ipfs/go-test/random" + "google.golang.org/protobuf/proto" ) func mkFakeCid(s string) cid.Cid { @@ -21,18 +22,23 @@ func TestAppendWanted(t *testing.T) { m := New(true) m.AddEntry(str, 1, pb.Message_Wantlist_Block, true) - if !wantlistContains(&m.ToProtoV0().Wantlist, str) { + if !wantlistContains(m.ToProtoV0().Wantlist, str) { t.Fail() } } func TestNewMessageFromProto(t *testing.T) { str := mkFakeCid("a_key") - protoMessage := new(pb.Message) - protoMessage.Wantlist.Entries = []pb.Message_Wantlist_Entry{ - {Block: pb.Cid{Cid: str}}, + + protoMessage := &pb.Message{ + Wantlist: &pb.Message_Wantlist{ + Entries: []*pb.Message_Wantlist_Entry{ + {Block: str.Bytes()}, + }, + }, } - if !wantlistContains(&protoMessage.Wantlist, str) { + + if !wantlistContains(protoMessage.Wantlist, str) { t.Fail() } m, err := newMessageFromProto(*protoMessage) @@ -40,7 +46,7 @@ func TestNewMessageFromProto(t *testing.T) { t.Fatal(err) } - if !wantlistContains(&m.ToProtoV0().Wantlist, str) { + if !wantlistContains(m.ToProtoV0().Wantlist, str) { t.Fail() } } @@ -92,7 +98,7 @@ func TestCopyProtoByValue(t *testing.T) { m := New(true) protoBeforeAppend := m.ToProtoV0() m.AddEntry(str, 1, pb.Message_Wantlist_Block, true) - if wantlistContains(&protoBeforeAppend.Wantlist, str) { + if wantlistContains(protoBeforeAppend.Wantlist, str) { t.Fail() } } @@ -162,7 +168,8 @@ func TestToAndFromNetMessage(t *testing.T) { func wantlistContains(wantlist *pb.Message_Wantlist, c cid.Cid) bool { for _, e := range wantlist.GetEntries() { - if e.Block.Cid.Defined() && c.Equals(e.Block.Cid) { + blkCid, err := cid.Cast(e.Block) + if err == nil && blkCid.Defined() && c.Equals(blkCid) { return true } } @@ -291,7 +298,7 @@ func TestEntrySize(t *testing.T) { Cancel: false, } epb := e.ToPB() - if e.Size() != epb.Size() { - t.Fatal("entry size calculation incorrect", e.Size(), epb.Size()) + if e.Size() != proto.Size(epb) { + t.Fatal("entry size calculation incorrect", e.Size(), proto.Size(epb)) } } diff --git a/bitswap/message/pb/Makefile b/bitswap/message/pb/Makefile deleted file mode 100644 index df34e54b0..000000000 --- a/bitswap/message/pb/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -PB = $(wildcard *.proto) -GO = $(PB:.proto=.pb.go) - -all: $(GO) - -%.pb.go: %.proto - protoc --proto_path=$(GOPATH)/src:. --gogofaster_out=. $< - -clean: - rm -f *.pb.go - rm -f *.go diff --git a/bitswap/message/pb/cid.go b/bitswap/message/pb/cid.go deleted file mode 100644 index 46ab0d507..000000000 --- a/bitswap/message/pb/cid.go +++ /dev/null @@ -1,44 +0,0 @@ -package bitswap_message_pb - -import ( - "github.com/ipfs/go-cid" -) - -// NOTE: Don't "embed" the cid, wrap it like we're doing here. Otherwise, gogo -// will try to use the Bytes() function. - -// Cid is a custom type for CIDs in protobufs, that allows us to avoid -// reallocating. -type Cid struct { - Cid cid.Cid -} - -func (c Cid) Marshal() ([]byte, error) { - return c.Cid.Bytes(), nil -} - -func (c *Cid) MarshalTo(data []byte) (int, error) { - // intentionally using KeyString here to avoid allocating. - return copy(data[:c.Size()], c.Cid.KeyString()), nil -} - -func (c *Cid) Unmarshal(data []byte) (err error) { - c.Cid, err = cid.Cast(data) - return err -} - -func (c *Cid) Size() int { - return len(c.Cid.KeyString()) -} - -func (c Cid) MarshalJSON() ([]byte, error) { - return c.Cid.MarshalJSON() -} - -func (c *Cid) UnmarshalJSON(data []byte) error { - return c.Cid.UnmarshalJSON(data) -} - -func (c Cid) Equal(other Cid) bool { - return c.Cid.Equals(other.Cid) -} diff --git a/bitswap/message/pb/cid_test.go b/bitswap/message/pb/cid_test.go index 7e53d9060..0c82d41e0 100644 --- a/bitswap/message/pb/cid_test.go +++ b/bitswap/message/pb/cid_test.go @@ -1,12 +1,12 @@ -package bitswap_message_pb_test +package pb import ( "bytes" "testing" - pb "github.com/ipfs/boxo/bitswap/message/pb" u "github.com/ipfs/boxo/util" "github.com/ipfs/go-cid" + "google.golang.org/protobuf/proto" ) func TestCID(t *testing.T) { @@ -20,8 +20,8 @@ func TestCID(t *testing.T) { } c := cid.NewCidV0(u.Hash([]byte("foobar"))) - msg := pb.Message_BlockPresence{Cid: pb.Cid{Cid: c}} - actual, err := msg.Marshal() + msg := Message_BlockPresence{Cid: c.Bytes()} + actual, err := proto.Marshal(&msg) if err != nil { t.Fatal(err) } diff --git a/bitswap/message/pb/gen.go b/bitswap/message/pb/gen.go new file mode 100644 index 000000000..0fe89bf80 --- /dev/null +++ b/bitswap/message/pb/gen.go @@ -0,0 +1,20 @@ +// These commands work around namespace conflicts that occur when multiple +// repositories depend on .proto files with generic filenames. Due to the way +// protobuf registers files (e.g., foo.proto or pb/foo.proto), naming +// collisions can occur when the same filename is used across different +// packages. +// +// The only way to generate a *.pb.go file that includes the full package path +// (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a +// directory structure that mirrors its package path. +// +// References: +// - https://protobuf.dev/reference/go/faq#namespace-conflict +// - https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265 +// +//go:generate mkdir -p github.com/ipfs/boxo/bitswap/message/pb +//go:generate ln -f message.proto github.com/ipfs/boxo/bitswap/message/pb +//go:generate protoc --go_out=. github.com/ipfs/boxo/bitswap/message//pb/message.proto +//go:generate mv -f github.com/ipfs/boxo/bitswap/message//pb/message.pb.go . +//go:generate rm -rf github.com +package pb diff --git a/bitswap/message/pb/message.pb.go b/bitswap/message/pb/message.pb.go index cf22ce525..82b9daf8a 100644 --- a/bitswap/message/pb/message.pb.go +++ b/bitswap/message/pb/message.pb.go @@ -1,31 +1,25 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: message.proto +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc v5.29.3 +// source: github.com/ipfs/boxo/bitswap/message/pb/message.proto -package bitswap_message_pb +package pb import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// 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.GoGoProtoPackageIsVersion3 // please upgrade the proto package - type Message_BlockPresenceType int32 const ( @@ -33,22 +27,43 @@ const ( Message_DontHave Message_BlockPresenceType = 1 ) -var Message_BlockPresenceType_name = map[int32]string{ - 0: "Have", - 1: "DontHave", -} +// Enum value maps for Message_BlockPresenceType. +var ( + Message_BlockPresenceType_name = map[int32]string{ + 0: "Have", + 1: "DontHave", + } + Message_BlockPresenceType_value = map[string]int32{ + "Have": 0, + "DontHave": 1, + } +) -var Message_BlockPresenceType_value = map[string]int32{ - "Have": 0, - "DontHave": 1, +func (x Message_BlockPresenceType) Enum() *Message_BlockPresenceType { + p := new(Message_BlockPresenceType) + *p = x + return p } func (x Message_BlockPresenceType) String() string { - return proto.EnumName(Message_BlockPresenceType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Message_BlockPresenceType) Descriptor() protoreflect.EnumDescriptor { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_enumTypes[0].Descriptor() +} + +func (Message_BlockPresenceType) Type() protoreflect.EnumType { + return &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_enumTypes[0] +} + +func (x Message_BlockPresenceType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } +// Deprecated: Use Message_BlockPresenceType.Descriptor instead. func (Message_BlockPresenceType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 0} + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0, 0} } type Message_Wantlist_WantType int32 @@ -58,1547 +73,484 @@ const ( Message_Wantlist_Have Message_Wantlist_WantType = 1 ) -var Message_Wantlist_WantType_name = map[int32]string{ - 0: "Block", - 1: "Have", -} +// Enum value maps for Message_Wantlist_WantType. +var ( + Message_Wantlist_WantType_name = map[int32]string{ + 0: "Block", + 1: "Have", + } + Message_Wantlist_WantType_value = map[string]int32{ + "Block": 0, + "Have": 1, + } +) -var Message_Wantlist_WantType_value = map[string]int32{ - "Block": 0, - "Have": 1, +func (x Message_Wantlist_WantType) Enum() *Message_Wantlist_WantType { + p := new(Message_Wantlist_WantType) + *p = x + return p } func (x Message_Wantlist_WantType) String() string { - return proto.EnumName(Message_Wantlist_WantType_name, int32(x)) -} - -func (Message_Wantlist_WantType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 0, 0} + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -type Message struct { - Wantlist Message_Wantlist `protobuf:"bytes,1,opt,name=wantlist,proto3" json:"wantlist"` - Blocks [][]byte `protobuf:"bytes,2,rep,name=blocks,proto3" json:"blocks,omitempty"` - Payload []Message_Block `protobuf:"bytes,3,rep,name=payload,proto3" json:"payload"` - BlockPresences []Message_BlockPresence `protobuf:"bytes,4,rep,name=blockPresences,proto3" json:"blockPresences"` - PendingBytes int32 `protobuf:"varint,5,opt,name=pendingBytes,proto3" json:"pendingBytes,omitempty"` +func (Message_Wantlist_WantType) Descriptor() protoreflect.EnumDescriptor { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_enumTypes[1].Descriptor() } -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0} +func (Message_Wantlist_WantType) Type() protoreflect.EnumType { + return &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_enumTypes[1] } -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (x Message_Wantlist_WantType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } +// Deprecated: Use Message_Wantlist_WantType.Descriptor instead. +func (Message_Wantlist_WantType) EnumDescriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0, 0, 0} } -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) +type Message struct { + state protoimpl.MessageState `protogen:"open.v1"` + Wantlist *Message_Wantlist `protobuf:"bytes,1,opt,name=wantlist,proto3" json:"wantlist,omitempty"` + Blocks [][]byte `protobuf:"bytes,2,rep,name=blocks,proto3" json:"blocks,omitempty"` // used to send Blocks in bitswap 1.0.0 + Payload []*Message_Block `protobuf:"bytes,3,rep,name=payload,proto3" json:"payload,omitempty"` // used to send Blocks in bitswap 1.1.0 + BlockPresences []*Message_BlockPresence `protobuf:"bytes,4,rep,name=blockPresences,proto3" json:"blockPresences,omitempty"` + PendingBytes int32 `protobuf:"varint,5,opt,name=pendingBytes,proto3" json:"pendingBytes,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *Message) XXX_Size() int { - return m.Size() +func (x *Message) Reset() { + *x = Message{} + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Message proto.InternalMessageInfo +func (*Message) ProtoMessage() {} -func (m *Message) GetWantlist() Message_Wantlist { - if m != nil { - return m.Wantlist +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return Message_Wantlist{} + return mi.MessageOf(x) } -func (m *Message) GetBlocks() [][]byte { - if m != nil { - return m.Blocks - } - return nil +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0} } -func (m *Message) GetPayload() []Message_Block { - if m != nil { - return m.Payload +func (x *Message) GetWantlist() *Message_Wantlist { + if x != nil { + return x.Wantlist } return nil } -func (m *Message) GetBlockPresences() []Message_BlockPresence { - if m != nil { - return m.BlockPresences +func (x *Message) GetBlocks() [][]byte { + if x != nil { + return x.Blocks } return nil } -func (m *Message) GetPendingBytes() int32 { - if m != nil { - return m.PendingBytes - } - return 0 -} - -type Message_Wantlist struct { - Entries []Message_Wantlist_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries"` - Full bool `protobuf:"varint,2,opt,name=full,proto3" json:"full,omitempty"` -} - -func (m *Message_Wantlist) Reset() { *m = Message_Wantlist{} } -func (m *Message_Wantlist) String() string { return proto.CompactTextString(m) } -func (*Message_Wantlist) ProtoMessage() {} -func (*Message_Wantlist) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 0} -} - -func (m *Message_Wantlist) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Message_Wantlist) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Wantlist.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Message_Wantlist) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Wantlist.Merge(m, src) -} - -func (m *Message_Wantlist) XXX_Size() int { - return m.Size() -} - -func (m *Message_Wantlist) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Wantlist.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_Wantlist proto.InternalMessageInfo - -func (m *Message_Wantlist) GetEntries() []Message_Wantlist_Entry { - if m != nil { - return m.Entries +func (x *Message) GetPayload() []*Message_Block { + if x != nil { + return x.Payload } return nil } -func (m *Message_Wantlist) GetFull() bool { - if m != nil { - return m.Full +func (x *Message) GetBlockPresences() []*Message_BlockPresence { + if x != nil { + return x.BlockPresences } - return false -} - -type Message_Wantlist_Entry struct { - Block Cid `protobuf:"bytes,1,opt,name=block,proto3,customtype=Cid" json:"block"` - Priority int32 `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"` - Cancel bool `protobuf:"varint,3,opt,name=cancel,proto3" json:"cancel,omitempty"` - WantType Message_Wantlist_WantType `protobuf:"varint,4,opt,name=wantType,proto3,enum=bitswap.message.v1.pb.Message_Wantlist_WantType" json:"wantType,omitempty"` - SendDontHave bool `protobuf:"varint,5,opt,name=sendDontHave,proto3" json:"sendDontHave,omitempty"` -} - -func (m *Message_Wantlist_Entry) Reset() { *m = Message_Wantlist_Entry{} } -func (m *Message_Wantlist_Entry) String() string { return proto.CompactTextString(m) } -func (*Message_Wantlist_Entry) ProtoMessage() {} -func (*Message_Wantlist_Entry) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 0, 0} -} - -func (m *Message_Wantlist_Entry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + return nil } -func (m *Message_Wantlist_Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Wantlist_Entry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (x *Message) GetPendingBytes() int32 { + if x != nil { + return x.PendingBytes } + return 0 } -func (m *Message_Wantlist_Entry) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Wantlist_Entry.Merge(m, src) +type Message_Wantlist struct { + state protoimpl.MessageState `protogen:"open.v1"` + Entries []*Message_Wantlist_Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` // a list of wantlist entries + Full bool `protobuf:"varint,2,opt,name=full,proto3" json:"full,omitempty"` // whether this is the full wantlist. default to false + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *Message_Wantlist_Entry) XXX_Size() int { - return m.Size() +func (x *Message_Wantlist) Reset() { + *x = Message_Wantlist{} + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *Message_Wantlist_Entry) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Wantlist_Entry.DiscardUnknown(m) +func (x *Message_Wantlist) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Message_Wantlist_Entry proto.InternalMessageInfo +func (*Message_Wantlist) ProtoMessage() {} -func (m *Message_Wantlist_Entry) GetPriority() int32 { - if m != nil { - return m.Priority +func (x *Message_Wantlist) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) } -func (m *Message_Wantlist_Entry) GetCancel() bool { - if m != nil { - return m.Cancel - } - return false +// Deprecated: Use Message_Wantlist.ProtoReflect.Descriptor instead. +func (*Message_Wantlist) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0, 0} } -func (m *Message_Wantlist_Entry) GetWantType() Message_Wantlist_WantType { - if m != nil { - return m.WantType +func (x *Message_Wantlist) GetEntries() []*Message_Wantlist_Entry { + if x != nil { + return x.Entries } - return Message_Wantlist_Block + return nil } -func (m *Message_Wantlist_Entry) GetSendDontHave() bool { - if m != nil { - return m.SendDontHave +func (x *Message_Wantlist) GetFull() bool { + if x != nil { + return x.Full } return false } type Message_Block struct { - Prefix []byte `protobuf:"bytes,1,opt,name=prefix,proto3" json:"prefix,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Prefix []byte `protobuf:"bytes,1,opt,name=prefix,proto3" json:"prefix,omitempty"` // CID prefix (cid version, multicodec and multihash prefix (type + length) + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *Message_Block) Reset() { *m = Message_Block{} } -func (m *Message_Block) String() string { return proto.CompactTextString(m) } -func (*Message_Block) ProtoMessage() {} -func (*Message_Block) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 1} +func (x *Message_Block) Reset() { + *x = Message_Block{} + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *Message_Block) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (x *Message_Block) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message_Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Block.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err +func (*Message_Block) ProtoMessage() {} + +func (x *Message_Block) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } + return mi.MessageOf(x) } -func (m *Message_Block) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Block.Merge(m, src) -} - -func (m *Message_Block) XXX_Size() int { - return m.Size() -} - -func (m *Message_Block) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Block.DiscardUnknown(m) +// Deprecated: Use Message_Block.ProtoReflect.Descriptor instead. +func (*Message_Block) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0, 1} } -var xxx_messageInfo_Message_Block proto.InternalMessageInfo - -func (m *Message_Block) GetPrefix() []byte { - if m != nil { - return m.Prefix +func (x *Message_Block) GetPrefix() []byte { + if x != nil { + return x.Prefix } return nil } -func (m *Message_Block) GetData() []byte { - if m != nil { - return m.Data +func (x *Message_Block) GetData() []byte { + if x != nil { + return x.Data } return nil } type Message_BlockPresence struct { - Cid Cid `protobuf:"bytes,1,opt,name=cid,proto3,customtype=Cid" json:"cid"` - Type Message_BlockPresenceType `protobuf:"varint,2,opt,name=type,proto3,enum=bitswap.message.v1.pb.Message_BlockPresenceType" json:"type,omitempty"` -} - -func (m *Message_BlockPresence) Reset() { *m = Message_BlockPresence{} } -func (m *Message_BlockPresence) String() string { return proto.CompactTextString(m) } -func (*Message_BlockPresence) ProtoMessage() {} -func (*Message_BlockPresence) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 2} -} - -func (m *Message_BlockPresence) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} - -func (m *Message_BlockPresence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_BlockPresence.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} - -func (m *Message_BlockPresence) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_BlockPresence.Merge(m, src) -} - -func (m *Message_BlockPresence) XXX_Size() int { - return m.Size() -} - -func (m *Message_BlockPresence) XXX_DiscardUnknown() { - xxx_messageInfo_Message_BlockPresence.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_BlockPresence proto.InternalMessageInfo - -func (m *Message_BlockPresence) GetType() Message_BlockPresenceType { - if m != nil { - return m.Type - } - return Message_Have -} - -func init() { - proto.RegisterEnum("bitswap.message.v1.pb.Message_BlockPresenceType", Message_BlockPresenceType_name, Message_BlockPresenceType_value) - proto.RegisterEnum("bitswap.message.v1.pb.Message_Wantlist_WantType", Message_Wantlist_WantType_name, Message_Wantlist_WantType_value) - proto.RegisterType((*Message)(nil), "bitswap.message.v1.pb.Message") - proto.RegisterType((*Message_Wantlist)(nil), "bitswap.message.v1.pb.Message.Wantlist") - proto.RegisterType((*Message_Wantlist_Entry)(nil), "bitswap.message.v1.pb.Message.Wantlist.Entry") - proto.RegisterType((*Message_Block)(nil), "bitswap.message.v1.pb.Message.Block") - proto.RegisterType((*Message_BlockPresence)(nil), "bitswap.message.v1.pb.Message.BlockPresence") -} - -func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) } - -var fileDescriptor_33c57e4bae7b9afd = []byte{ - // 496 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xdf, 0x8a, 0xd3, 0x40, - 0x14, 0xc6, 0x33, 0x4d, 0xd2, 0xc6, 0xd3, 0xec, 0x52, 0x07, 0x95, 0x10, 0x30, 0x8d, 0x45, 0x30, - 0xe0, 0x1a, 0xb5, 0xfb, 0x06, 0xb1, 0x82, 0x82, 0x0b, 0x32, 0x08, 0x0b, 0x7b, 0xb3, 0xe4, 0xcf, - 0x6c, 0x09, 0xc6, 0x24, 0x64, 0xc6, 0x5d, 0xf3, 0x16, 0x3e, 0xd6, 0x5e, 0xf6, 0x52, 0xbc, 0x58, - 0xb4, 0xbd, 0xf7, 0x19, 0x64, 0x26, 0x93, 0x42, 0x75, 0x61, 0x7b, 0x37, 0xe7, 0xcc, 0xf9, 0x7e, - 0x73, 0xbe, 0x73, 0x18, 0x38, 0xf8, 0x42, 0x19, 0x8b, 0x97, 0x34, 0xac, 0x9b, 0x8a, 0x57, 0xf8, - 0x61, 0x92, 0x73, 0x76, 0x15, 0xd7, 0x61, 0x9f, 0xbe, 0x7c, 0x1d, 0xd6, 0x89, 0xfb, 0x60, 0x59, - 0x2d, 0x2b, 0x59, 0xf1, 0x52, 0x9c, 0xba, 0xe2, 0xd9, 0x9f, 0x21, 0x8c, 0x4e, 0xba, 0x3a, 0xfc, - 0x1e, 0xac, 0xab, 0xb8, 0xe4, 0x45, 0xce, 0xb8, 0x83, 0x7c, 0x14, 0x8c, 0xe7, 0xcf, 0xc2, 0x5b, - 0x59, 0xa1, 0x52, 0x84, 0xa7, 0xaa, 0x3c, 0x32, 0xae, 0x6f, 0xa6, 0x1a, 0xd9, 0xca, 0xf1, 0x23, - 0x18, 0x26, 0x45, 0x95, 0x7e, 0x66, 0xce, 0xc0, 0xd7, 0x03, 0x9b, 0xa8, 0x08, 0x2f, 0x60, 0x54, - 0xc7, 0x6d, 0x51, 0xc5, 0x99, 0xa3, 0xfb, 0x7a, 0x30, 0x9e, 0x3f, 0xbd, 0xe3, 0x85, 0x48, 0xe8, - 0x14, 0xbe, 0x97, 0xe2, 0x33, 0x38, 0x94, 0xbc, 0x8f, 0x0d, 0x65, 0xb4, 0x4c, 0x29, 0x73, 0x0c, - 0x09, 0x3b, 0xda, 0x07, 0xd6, 0x8b, 0x14, 0xf4, 0x1f, 0x12, 0x9e, 0x81, 0x5d, 0xd3, 0x32, 0xcb, - 0xcb, 0x65, 0xd4, 0x72, 0xca, 0x1c, 0xd3, 0x47, 0x81, 0x49, 0x76, 0x72, 0xee, 0xef, 0x01, 0x58, - 0xbd, 0x75, 0x7c, 0x02, 0x23, 0x5a, 0xf2, 0x26, 0xa7, 0xcc, 0x41, 0xb2, 0x8b, 0x17, 0x7b, 0x0e, - 0x2d, 0x7c, 0x5b, 0xf2, 0xa6, 0xed, 0xbd, 0x29, 0x06, 0xc6, 0x60, 0x5c, 0x7c, 0x2d, 0x0a, 0x67, - 0xe0, 0xa3, 0xc0, 0x22, 0xf2, 0xec, 0xae, 0x10, 0x98, 0xb2, 0x18, 0x3f, 0x01, 0x53, 0xf6, 0x2b, - 0xf7, 0x63, 0x47, 0x63, 0xa1, 0xfd, 0x79, 0x33, 0xd5, 0xdf, 0xe4, 0x19, 0xe9, 0x6e, 0xb0, 0x0b, - 0x56, 0xdd, 0xe4, 0x55, 0x93, 0xf3, 0x56, 0x42, 0x4c, 0xb2, 0x8d, 0xc5, 0x5a, 0xd2, 0xb8, 0x4c, - 0x69, 0xe1, 0xe8, 0x12, 0xaf, 0x22, 0xfc, 0xa1, 0xdb, 0xfc, 0xa7, 0xb6, 0xa6, 0x8e, 0xe1, 0xa3, - 0xe0, 0x70, 0xfe, 0x6a, 0x5f, 0x13, 0xa7, 0x4a, 0x47, 0xb6, 0x04, 0x31, 0x42, 0x46, 0xcb, 0x6c, - 0x51, 0x95, 0xfc, 0x5d, 0x7c, 0x49, 0xe5, 0x08, 0x2d, 0xb2, 0x93, 0x9b, 0x4d, 0xbb, 0x09, 0xca, - 0xfa, 0x7b, 0x60, 0xca, 0xcd, 0x4c, 0x34, 0x6c, 0x81, 0x21, 0xae, 0x27, 0xc8, 0x3d, 0x56, 0x49, - 0xd1, 0x73, 0xdd, 0xd0, 0x8b, 0xfc, 0x5b, 0xe7, 0x99, 0xa8, 0x48, 0x0c, 0x2a, 0x8b, 0x79, 0x2c, - 0x3d, 0xda, 0x44, 0x9e, 0x5d, 0x0e, 0x07, 0x3b, 0x3b, 0xc6, 0x8f, 0x41, 0x4f, 0xf3, 0xec, 0xb6, - 0x69, 0x89, 0x3c, 0x5e, 0x80, 0xc1, 0x85, 0xe7, 0xc1, 0x5e, 0x9e, 0x77, 0xd0, 0xd2, 0xb3, 0x54, - 0xcf, 0x9e, 0xc3, 0xfd, 0xff, 0xae, 0xb6, 0x4e, 0x34, 0x6c, 0x83, 0xd5, 0xdb, 0x9e, 0xa0, 0xe8, - 0xe8, 0x7a, 0xed, 0xa1, 0xd5, 0xda, 0x43, 0xbf, 0xd6, 0x1e, 0xfa, 0xbe, 0xf1, 0xb4, 0xd5, 0xc6, - 0xd3, 0x7e, 0x6c, 0x3c, 0xed, 0x0c, 0xab, 0xd7, 0xcf, 0xd5, 0xeb, 0xe7, 0x75, 0x92, 0x0c, 0xe5, - 0x2f, 0x3d, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x44, 0xa6, 0x21, 0xa7, 0xe3, 0x03, 0x00, 0x00, -} - -func (m *Message) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PendingBytes != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.PendingBytes)) - i-- - dAtA[i] = 0x28 - } - if len(m.BlockPresences) > 0 { - for iNdEx := len(m.BlockPresences) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BlockPresences[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.Payload) > 0 { - for iNdEx := len(m.Payload) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Payload[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Blocks) > 0 { - for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Blocks[iNdEx]) - copy(dAtA[i:], m.Blocks[iNdEx]) - i = encodeVarintMessage(dAtA, i, uint64(len(m.Blocks[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Wantlist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + state protoimpl.MessageState `protogen:"open.v1"` + Cid []byte `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` + Type Message_BlockPresenceType `protobuf:"varint,2,opt,name=type,proto3,enum=github.com.boxo.bitswap.message.v1.pb.Message_BlockPresenceType" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *Message_Wantlist) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil +func (x *Message_BlockPresence) Reset() { + *x = Message_BlockPresence{} + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *Message_Wantlist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_BlockPresence) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message_Wantlist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Full { - i-- - if m.Full { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Entries) > 0 { - for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Message_Wantlist_Entry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} +func (*Message_BlockPresence) ProtoMessage() {} -func (m *Message_Wantlist_Entry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_Wantlist_Entry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SendDontHave { - i-- - if m.SendDontHave { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if m.WantType != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.WantType)) - i-- - dAtA[i] = 0x20 - } - if m.Cancel { - i-- - if m.Cancel { - dAtA[i] = 1 - } else { - dAtA[i] = 0 +func (x *Message_BlockPresence) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - i-- - dAtA[i] = 0x18 + return ms } - if m.Priority != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.Priority)) - i-- - dAtA[i] = 0x10 - } - { - size := m.Block.Size() - i -= size - if _, err := m.Block.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil + return mi.MessageOf(x) } -func (m *Message_Block) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_Block) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// Deprecated: Use Message_BlockPresence.ProtoReflect.Descriptor instead. +func (*Message_BlockPresence) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0, 2} } -func (m *Message_Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintMessage(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 +func (x *Message_BlockPresence) GetCid() []byte { + if x != nil { + return x.Cid } - if len(m.Prefix) > 0 { - i -= len(m.Prefix) - copy(dAtA[i:], m.Prefix) - i = encodeVarintMessage(dAtA, i, uint64(len(m.Prefix))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil + return nil } -func (m *Message_BlockPresence) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (x *Message_BlockPresence) GetType() Message_BlockPresenceType { + if x != nil { + return x.Type } - return dAtA[:n], nil + return Message_Have } -func (m *Message_BlockPresence) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +type Message_Wantlist_Entry struct { + state protoimpl.MessageState `protogen:"open.v1"` + Block []byte `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0) + Priority int32 `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"` // the priority (normalized). default to 1 + Cancel bool `protobuf:"varint,3,opt,name=cancel,proto3" json:"cancel,omitempty"` // whether this revokes an entry + WantType Message_Wantlist_WantType `protobuf:"varint,4,opt,name=wantType,proto3,enum=github.com.boxo.bitswap.message.v1.pb.Message_Wantlist_WantType" json:"wantType,omitempty"` // Note: defaults to enum 0, ie Block + SendDontHave bool `protobuf:"varint,5,opt,name=sendDontHave,proto3" json:"sendDontHave,omitempty"` // Note: defaults to false + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *Message_BlockPresence) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Type != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x10 - } - { - size := m.Cid.Size() - i -= size - if _, err := m.Cid.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil +func (x *Message_Wantlist_Entry) Reset() { + *x = Message_Wantlist_Entry{} + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func encodeVarintMessage(dAtA []byte, offset int, v uint64) int { - offset -= sovMessage(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base +func (x *Message_Wantlist_Entry) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Wantlist.Size() - n += 1 + l + sovMessage(uint64(l)) - if len(m.Blocks) > 0 { - for _, b := range m.Blocks { - l = len(b) - n += 1 + l + sovMessage(uint64(l)) - } - } - if len(m.Payload) > 0 { - for _, e := range m.Payload { - l = e.Size() - n += 1 + l + sovMessage(uint64(l)) - } - } - if len(m.BlockPresences) > 0 { - for _, e := range m.BlockPresences { - l = e.Size() - n += 1 + l + sovMessage(uint64(l)) - } - } - if m.PendingBytes != 0 { - n += 1 + sovMessage(uint64(m.PendingBytes)) - } - return n -} +func (*Message_Wantlist_Entry) ProtoMessage() {} -func (m *Message_Wantlist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovMessage(uint64(l)) +func (x *Message_Wantlist_Entry) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } + return ms } - if m.Full { - n += 2 - } - return n -} - -func (m *Message_Wantlist_Entry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Block.Size() - n += 1 + l + sovMessage(uint64(l)) - if m.Priority != 0 { - n += 1 + sovMessage(uint64(m.Priority)) - } - if m.Cancel { - n += 2 - } - if m.WantType != 0 { - n += 1 + sovMessage(uint64(m.WantType)) - } - if m.SendDontHave { - n += 2 - } - return n + return mi.MessageOf(x) } -func (m *Message_Block) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Prefix) - if l > 0 { - n += 1 + l + sovMessage(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovMessage(uint64(l)) - } - return n +// Deprecated: Use Message_Wantlist_Entry.ProtoReflect.Descriptor instead. +func (*Message_Wantlist_Entry) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP(), []int{0, 0, 0} } -func (m *Message_BlockPresence) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Cid.Size() - n += 1 + l + sovMessage(uint64(l)) - if m.Type != 0 { - n += 1 + sovMessage(uint64(m.Type)) - } - return n -} - -func sovMessage(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} - -func sozMessage(x uint64) (n int) { - return sovMessage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} - -func (m *Message) 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 ErrIntOverflowMessage - } - 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: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Wantlist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Wantlist.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Blocks = append(m.Blocks, make([]byte, postIndex-iNdEx)) - copy(m.Blocks[len(m.Blocks)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload, Message_Block{}) - if err := m.Payload[len(m.Payload)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockPresences", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BlockPresences = append(m.BlockPresences, Message_BlockPresence{}) - if err := m.BlockPresences[len(m.BlockPresences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PendingBytes", wireType) - } - m.PendingBytes = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PendingBytes |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Wantlist_Entry) GetBlock() []byte { + if x != nil { + return x.Block } return nil } -func (m *Message_Wantlist) 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 ErrIntOverflowMessage - } - 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: Wantlist: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Wantlist: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Entries = append(m.Entries, Message_Wantlist_Entry{}) - if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Full", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Full = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Wantlist_Entry) GetPriority() int32 { + if x != nil { + return x.Priority } - return nil + return 0 } -func (m *Message_Wantlist_Entry) 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 ErrIntOverflowMessage - } - 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: Entry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Entry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Priority", wireType) - } - m.Priority = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Priority |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Cancel", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Cancel = bool(v != 0) - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field WantType", wireType) - } - m.WantType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.WantType |= Message_Wantlist_WantType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SendDontHave", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.SendDontHave = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Wantlist_Entry) GetCancel() bool { + if x != nil { + return x.Cancel } - return nil + return false } -func (m *Message_Block) 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 ErrIntOverflowMessage - } - 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: Block: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Block: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Prefix = append(m.Prefix[:0], dAtA[iNdEx:postIndex]...) - if m.Prefix == nil { - m.Prefix = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Wantlist_Entry) GetWantType() Message_Wantlist_WantType { + if x != nil { + return x.WantType } - return nil + return Message_Wantlist_Block } -func (m *Message_BlockPresence) 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 ErrIntOverflowMessage - } - 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: BlockPresence: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockPresence: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMessage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMessage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Cid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= Message_BlockPresenceType(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Wantlist_Entry) GetSendDontHave() bool { + if x != nil { + return x.SendDontHave } - return nil + return false } -func skipMessage(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMessage - } - 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, ErrIntOverflowMessage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMessage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthMessage - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMessage - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMessage - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF +var File_github_com_ipfs_boxo_bitswap_message_pb_message_proto protoreflect.FileDescriptor + +var file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDesc = []byte{ + 0x0a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, + 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x62, 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, 0x2f, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, + 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x62, 0x22, 0x9c, + 0x07, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x53, 0x0a, 0x08, 0x77, 0x61, + 0x6e, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x62, + 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x57, 0x61, 0x6e, + 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x08, 0x77, 0x61, 0x6e, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, + 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x4e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x77, + 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x62, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x64, 0x0a, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x3c, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, + 0x6f, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0e, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x22, 0x0a, + 0x0c, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0c, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, + 0x73, 0x1a, 0xee, 0x02, 0x0a, 0x08, 0x57, 0x61, 0x6e, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x57, + 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x3d, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, + 0x6f, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x57, 0x61, 0x6e, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, + 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x75, 0x6c, 0x6c, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x66, 0x75, 0x6c, 0x6c, 0x1a, 0xd3, 0x01, 0x0a, 0x05, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x12, + 0x5c, 0x0a, 0x08, 0x77, 0x61, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x40, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, + 0x6f, 0x78, 0x6f, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x57, 0x61, 0x6e, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x57, 0x61, 0x6e, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x08, 0x77, 0x61, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, + 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x44, 0x6f, 0x6e, 0x74, 0x48, 0x61, 0x76, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x44, 0x6f, 0x6e, 0x74, 0x48, 0x61, 0x76, + 0x65, 0x22, 0x1f, 0x0a, 0x08, 0x57, 0x61, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, + 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x61, 0x76, 0x65, + 0x10, 0x01, 0x1a, 0x33, 0x0a, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x70, + 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x72, 0x65, + 0x66, 0x69, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x77, 0x0a, 0x0d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x54, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x40, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x77, + 0x61, 0x70, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x62, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, + 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x22, 0x2b, 0x0a, 0x11, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x61, 0x76, 0x65, 0x10, 0x00, 0x12, + 0x0c, 0x0a, 0x08, 0x44, 0x6f, 0x6e, 0x74, 0x48, 0x61, 0x76, 0x65, 0x10, 0x01, 0x42, 0x29, 0x5a, + 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, 0x73, + 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x62, 0x69, 0x74, 0x73, 0x77, 0x61, 0x70, 0x2f, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - ErrInvalidLengthMessage = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMessage = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMessage = fmt.Errorf("proto: unexpected end of group") + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescOnce sync.Once + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescData = file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDesc ) + +func file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescGZIP() []byte { + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescOnce.Do(func() { + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescData) + }) + return file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDescData +} + +var file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_goTypes = []any{ + (Message_BlockPresenceType)(0), // 0: github.com.boxo.bitswap.message.v1.pb.Message.BlockPresenceType + (Message_Wantlist_WantType)(0), // 1: github.com.boxo.bitswap.message.v1.pb.Message.Wantlist.WantType + (*Message)(nil), // 2: github.com.boxo.bitswap.message.v1.pb.Message + (*Message_Wantlist)(nil), // 3: github.com.boxo.bitswap.message.v1.pb.Message.Wantlist + (*Message_Block)(nil), // 4: github.com.boxo.bitswap.message.v1.pb.Message.Block + (*Message_BlockPresence)(nil), // 5: github.com.boxo.bitswap.message.v1.pb.Message.BlockPresence + (*Message_Wantlist_Entry)(nil), // 6: github.com.boxo.bitswap.message.v1.pb.Message.Wantlist.Entry +} +var file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_depIdxs = []int32{ + 3, // 0: github.com.boxo.bitswap.message.v1.pb.Message.wantlist:type_name -> github.com.boxo.bitswap.message.v1.pb.Message.Wantlist + 4, // 1: github.com.boxo.bitswap.message.v1.pb.Message.payload:type_name -> github.com.boxo.bitswap.message.v1.pb.Message.Block + 5, // 2: github.com.boxo.bitswap.message.v1.pb.Message.blockPresences:type_name -> github.com.boxo.bitswap.message.v1.pb.Message.BlockPresence + 6, // 3: github.com.boxo.bitswap.message.v1.pb.Message.Wantlist.entries:type_name -> github.com.boxo.bitswap.message.v1.pb.Message.Wantlist.Entry + 0, // 4: github.com.boxo.bitswap.message.v1.pb.Message.BlockPresence.type:type_name -> github.com.boxo.bitswap.message.v1.pb.Message.BlockPresenceType + 1, // 5: github.com.boxo.bitswap.message.v1.pb.Message.Wantlist.Entry.wantType:type_name -> github.com.boxo.bitswap.message.v1.pb.Message.Wantlist.WantType + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_init() } +func file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_init() { + if File_github_com_ipfs_boxo_bitswap_message_pb_message_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDesc, + NumEnums: 2, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_goTypes, + DependencyIndexes: file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_depIdxs, + EnumInfos: file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_enumTypes, + MessageInfos: file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_msgTypes, + }.Build() + File_github_com_ipfs_boxo_bitswap_message_pb_message_proto = out.File + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_rawDesc = nil + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_goTypes = nil + file_github_com_ipfs_boxo_bitswap_message_pb_message_proto_depIdxs = nil +} diff --git a/bitswap/message/pb/message.proto b/bitswap/message/pb/message.proto index 0ab385d00..af41322db 100644 --- a/bitswap/message/pb/message.proto +++ b/bitswap/message/pb/message.proto @@ -1,13 +1,10 @@ syntax = "proto3"; -package bitswap.message.v1.pb; +package github.com.boxo.bitswap.message.v1.pb; -import "gogoproto/gogo.proto"; - -option go_package = "bitswap_message_pb"; +option go_package = "github.com/ipfs/boxo/bitswap/message/pb"; message Message { - message Wantlist { enum WantType { Block = 0; @@ -15,19 +12,19 @@ message Message { } message Entry { - bytes block = 1 [(gogoproto.customtype) = "Cid", (gogoproto.nullable) = false]; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0) - int32 priority = 2; // the priority (normalized). default to 1 - bool cancel = 3; // whether this revokes an entry - WantType wantType = 4; // Note: defaults to enum 0, ie Block - bool sendDontHave = 5; // Note: defaults to false - } - - repeated Entry entries = 1 [(gogoproto.nullable) = false]; // a list of wantlist entries - bool full = 2; // whether this is the full wantlist. default to false + bytes block = 1; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0) + int32 priority = 2; // the priority (normalized). default to 1 + bool cancel = 3; // whether this revokes an entry + WantType wantType = 4; // Note: defaults to enum 0, ie Block + bool sendDontHave = 5; // Note: defaults to false + } + + repeated Entry entries = 1; // a list of wantlist entries + bool full = 2; // whether this is the full wantlist. default to false } message Block { - bytes prefix = 1; // CID prefix (cid version, multicodec and multihash prefix (type + length) + bytes prefix = 1; // CID prefix (cid version, multicodec and multihash prefix (type + length) bytes data = 2; } @@ -35,14 +32,15 @@ message Message { Have = 0; DontHave = 1; } + message BlockPresence { - bytes cid = 1 [(gogoproto.customtype) = "Cid", (gogoproto.nullable) = false]; + bytes cid = 1; BlockPresenceType type = 2; } - Wantlist wantlist = 1 [(gogoproto.nullable) = false]; - repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0 - repeated Block payload = 3 [(gogoproto.nullable) = false]; // used to send Blocks in bitswap 1.1.0 - repeated BlockPresence blockPresences = 4 [(gogoproto.nullable) = false]; + Wantlist wantlist = 1; + repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0 + repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0 + repeated BlockPresence blockPresences = 4; int32 pendingBytes = 5; } diff --git a/bitswap/testnet/virtual.go b/bitswap/testnet/virtual.go index 53e56d67d..442ed00f1 100644 --- a/bitswap/testnet/virtual.go +++ b/bitswap/testnet/virtual.go @@ -18,6 +18,7 @@ import ( protocol "github.com/libp2p/go-libp2p/core/protocol" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/libp2p/go-libp2p/p2p/protocol/ping" + "google.golang.org/protobuf/proto" ) // VirtualNetwork generates a new testnet instance - a fake network that @@ -151,7 +152,7 @@ func (n *network) SendMessage( rateLimiters[to] = rateLimiter } - size := mes.ToProtoV1().Size() + size := proto.Size(mes.ToProtoV1()) bandwidthDelay = rateLimiter.Limit(size) } else { bandwidthDelay = 0 diff --git a/examples/go.mod b/examples/go.mod index 780e807a1..8eb9df8c3 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -5,7 +5,7 @@ go 1.22.0 toolchain go1.22.8 require ( - github.com/ipfs/boxo v0.24.3 + github.com/ipfs/boxo v0.27.2 github.com/ipfs/go-block-format v0.2.0 github.com/ipfs/go-cid v0.5.0 github.com/ipfs/go-datastore v0.6.0 @@ -18,7 +18,7 @@ require ( github.com/stretchr/testify v1.10.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 go.opentelemetry.io/contrib/propagators/autoprop v0.46.1 - go.opentelemetry.io/otel v1.31.0 + go.opentelemetry.io/otel v1.34.0 go.opentelemetry.io/otel/sdk v1.31.0 ) @@ -94,9 +94,9 @@ require ( github.com/libp2p/go-doh-resolver v0.5.0 // indirect github.com/libp2p/go-flow-metrics v0.2.0 // indirect github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect - github.com/libp2p/go-libp2p-kad-dht v0.28.2 // indirect + github.com/libp2p/go-libp2p-kad-dht v0.29.0 // indirect github.com/libp2p/go-libp2p-kbucket v0.6.4 // indirect - github.com/libp2p/go-libp2p-record v0.2.0 // indirect + github.com/libp2p/go-libp2p-record v0.3.1 // indirect github.com/libp2p/go-libp2p-routing-helpers v0.7.4 // indirect github.com/libp2p/go-msgio v0.3.0 // indirect github.com/libp2p/go-nat v0.2.0 // indirect @@ -167,6 +167,7 @@ require ( github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/wlynxg/anet v0.0.5 // indirect go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/propagators/aws v1.21.1 // indirect go.opentelemetry.io/contrib/propagators/b3 v1.21.1 // indirect go.opentelemetry.io/contrib/propagators/jaeger v1.21.1 // indirect @@ -176,8 +177,8 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0 // indirect go.opentelemetry.io/otel/exporters/zipkin v1.31.0 // indirect - go.opentelemetry.io/otel/metric v1.31.0 // indirect - go.opentelemetry.io/otel/trace v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.34.0 // indirect + go.opentelemetry.io/otel/trace v1.34.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/dig v1.18.0 // indirect @@ -194,7 +195,7 @@ require ( golang.org/x/text v0.22.0 // indirect golang.org/x/tools v0.29.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect - gonum.org/v1/gonum v0.15.0 // indirect + gonum.org/v1/gonum v0.15.1 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect google.golang.org/grpc v1.67.1 // indirect diff --git a/examples/go.sum b/examples/go.sum index 106917a67..dcae088cd 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -278,12 +278,12 @@ github.com/libp2p/go-libp2p v0.39.0 h1:LmrhDRud4eDkQCSB4l5NfoIFDqvDwAyANmfeYkgnK github.com/libp2p/go-libp2p v0.39.0/go.mod h1:3zicI8Lp7Isun+Afo/JOACUbbJqqR2owK6RQWFsVAbI= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= -github.com/libp2p/go-libp2p-kad-dht v0.28.2 h1:/VivUl/Ru0tVgkWNhDDBy8pK6q+gRdI+z8VfqmSUJWo= -github.com/libp2p/go-libp2p-kad-dht v0.28.2/go.mod h1:sUR/qh4p/5+YFXBtwOiCmIBeBA2YD94ttmL+Xk8+pTE= +github.com/libp2p/go-libp2p-kad-dht v0.29.0 h1:045eW21lGlMSD9aKSZZGH4fnBMIInPwQLxIQ35P962I= +github.com/libp2p/go-libp2p-kad-dht v0.29.0/go.mod h1:mIci3rHSwDsxQWcCjfmxD8vMTgh5xLuvwb1D5WP8ZNk= github.com/libp2p/go-libp2p-kbucket v0.6.4 h1:OjfiYxU42TKQSB8t8WYd8MKhYhMJeO2If+NiuKfb6iQ= github.com/libp2p/go-libp2p-kbucket v0.6.4/go.mod h1:jp6w82sczYaBsAypt5ayACcRJi0lgsba7o4TzJKEfWA= -github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= -github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= +github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg= +github.com/libp2p/go-libp2p-record v0.3.1/go.mod h1:T8itUkLcWQLCYMqtX7Th6r7SexyUJpIyPgks757td/E= github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84= github.com/libp2p/go-libp2p-routing-helpers v0.7.4/go.mod h1:we5WDj9tbolBXOuF1hGOkR+r7Uh1408tQbAKaT5n1LE= github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= @@ -534,6 +534,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM= go.opentelemetry.io/contrib/propagators/autoprop v0.46.1 h1:cXTYcMjY0dsYokAuo8LbNBQxpF8VgTHdiHJJ1zlIXl4= @@ -546,8 +548,8 @@ go.opentelemetry.io/contrib/propagators/jaeger v1.21.1 h1:f4beMGDKiVzg9IcX7/VuWV go.opentelemetry.io/contrib/propagators/jaeger v1.21.1/go.mod h1:U9jhkEl8d1LL+QXY7q3kneJWJugiN3kZJV2OWz3hkBY= go.opentelemetry.io/contrib/propagators/ot v1.21.1 h1:3TN5vkXjKYWp0YdMcnUEC/A+pBPvqz9V3nCS2xmcurk= go.opentelemetry.io/contrib/propagators/ot v1.21.1/go.mod h1:oy0MYCbS/b3cqUDW37wBWtlwBIsutngS++Lklpgh+fc= -go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= -go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0 h1:FFeLy03iVTXP6ffeN2iXrxfGsZGCjVx0/4KlizjyBwU= @@ -558,12 +560,12 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0 h1:UGZ1QwZWY67Z6Bm go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0/go.mod h1:fcwWuDuaObkkChiDlhEpSq9+X1C0omv+s5mBtToAQ64= go.opentelemetry.io/otel/exporters/zipkin v1.31.0 h1:CgucL0tj3717DJnni7HVVB2wExzi8c2zJNEA2BhLMvI= go.opentelemetry.io/otel/exporters/zipkin v1.31.0/go.mod h1:rfzOVNiSwIcWtEC2J8epwG26fiaXlYvLySJ7bwsrtAE= -go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= -go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= -go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= -go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -740,8 +742,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ= -gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo= +gonum.org/v1/gonum v0.15.1 h1:FNy7N6OUZVUaWG9pTiD+jlhdQ3lMP+/LcTpJ6+a8sQ0= +gonum.org/v1/gonum v0.15.1/go.mod h1:eZTZuRFrzu5pcyjN5wJhcIhnUdNijYxX1T2IcrOGY0o= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= diff --git a/filestore/fsrefstore.go b/filestore/fsrefstore.go index 3d7156785..e9b5a3f77 100644 --- a/filestore/fsrefstore.go +++ b/filestore/fsrefstore.go @@ -8,7 +8,6 @@ import ( "os" "path/filepath" - proto "github.com/gogo/protobuf/proto" dshelp "github.com/ipfs/boxo/datastore/dshelp" pb "github.com/ipfs/boxo/filestore/pb" posinfo "github.com/ipfs/boxo/filestore/posinfo" @@ -19,6 +18,7 @@ import ( dsq "github.com/ipfs/go-datastore/query" ipld "github.com/ipfs/go-ipld-format" mh "github.com/multiformats/go-multihash" + proto "google.golang.org/protobuf/proto" ) // FilestorePrefix identifies the key prefix for FileManager blocks. @@ -157,7 +157,7 @@ func (f *FileManager) GetSize(ctx context.Context, c cid.Cid) (int, error) { if err != nil { return -1, err } - return int(dobj.GetSize_()), nil + return int(dobj.GetSize()), nil } func (f *FileManager) readDataObj(ctx context.Context, m mh.Multihash, d *pb.DataObj) ([]byte, error) { @@ -206,7 +206,7 @@ func (f *FileManager) readFileDataObj(m mh.Multihash, d *pb.DataObj) ([]byte, er } defer fi.Close() - outbuf := make([]byte, d.GetSize_()) + outbuf := make([]byte, d.GetSize()) _, err = fi.ReadAt(outbuf, int64(d.GetOffset())) if err == io.EOF || err == io.ErrUnexpectedEOF { return nil, &CorruptReferenceError{StatusFileChanged, err} @@ -243,7 +243,7 @@ func (f *FileManager) readURLDataObj(ctx context.Context, m mh.Multihash, d *pb. return nil, err } - req.Header.Add("Range", fmt.Sprintf("bytes=%d-%d", d.GetOffset(), d.GetOffset()+d.GetSize_()-1)) + req.Header.Add("Range", fmt.Sprintf("bytes=%d-%d", d.GetOffset(), d.GetOffset()+d.GetSize()-1)) res, err := http.DefaultClient.Do(req) if err != nil { @@ -256,7 +256,7 @@ func (f *FileManager) readURLDataObj(ctx context.Context, m mh.Multihash, d *pb. } } - outbuf := make([]byte, d.GetSize_()) + outbuf := make([]byte, d.GetSize()) _, err = io.ReadFull(res.Body, outbuf) if err == io.EOF || err == io.ErrUnexpectedEOF { return nil, &CorruptReferenceError{StatusFileChanged, err} @@ -309,7 +309,7 @@ func (f *FileManager) putTo(ctx context.Context, b *posinfo.FilestoreNode, to pu if !f.AllowUrls { return ErrUrlstoreNotEnabled } - dobj.FilePath = b.PosInfo.FullPath + dobj.FilePath = &b.PosInfo.FullPath } else { if !f.AllowFiles { return ErrFilestoreNotEnabled @@ -326,10 +326,12 @@ func (f *FileManager) putTo(ctx context.Context, b *posinfo.FilestoreNode, to pu return err } - dobj.FilePath = filepath.ToSlash(p) + ps := filepath.ToSlash(p) + dobj.FilePath = &ps } - dobj.Offset = b.PosInfo.Offset - dobj.Size_ = uint64(len(b.RawData())) + dobj.Offset = &b.PosInfo.Offset + size := uint64(len(b.RawData())) + dobj.Size = &size data, err := proto.Marshal(&dobj) if err != nil { diff --git a/filestore/pb/dataobj.pb.go b/filestore/pb/dataobj.pb.go index d47d1931e..7b92447ea 100644 --- a/filestore/pb/dataobj.pb.go +++ b/filestore/pb/dataobj.pb.go @@ -1,387 +1,152 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: dataobj.proto +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc v5.29.3 +// source: github.com/ipfs/boxo/filestore/pb/dataobj.proto -package datastore_pb +package pb import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/gogo/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// 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.GoGoProtoPackageIsVersion3 // please upgrade the proto package - type DataObj struct { - 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"` + state protoimpl.MessageState `protogen:"open.v1"` + FilePath *string `protobuf:"bytes,1,opt,name=FilePath,proto3,oneof" json:"FilePath,omitempty"` + Offset *uint64 `protobuf:"varint,2,opt,name=Offset,proto3,oneof" json:"Offset,omitempty"` + Size *uint64 `protobuf:"varint,3,opt,name=Size,proto3,oneof" json:"Size,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -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_a76cb282d869d683, []int{0} +func (x *DataObj) Reset() { + *x = DataObj{} + mi := &file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *DataObj) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (x *DataObj) String() string { + return protoimpl.X.MessageStringOf(x) } -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.MarshalToSizedBuffer(b) - if err != nil { - return nil, err +func (*DataObj) ProtoMessage() {} + +func (x *DataObj) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } + return mi.MessageOf(x) } -func (m *DataObj) XXX_Merge(src proto.Message) { - xxx_messageInfo_DataObj.Merge(m, src) -} - -func (m *DataObj) XXX_Size() int { - return m.Size() -} - -func (m *DataObj) XXX_DiscardUnknown() { - xxx_messageInfo_DataObj.DiscardUnknown(m) +// Deprecated: Use DataObj.ProtoReflect.Descriptor instead. +func (*DataObj) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescGZIP(), []int{0} } -var xxx_messageInfo_DataObj proto.InternalMessageInfo - -func (m *DataObj) GetFilePath() string { - if m != nil { - return m.FilePath +func (x *DataObj) GetFilePath() string { + if x != nil && x.FilePath != nil { + return *x.FilePath } return "" } -func (m *DataObj) GetOffset() uint64 { - if m != nil { - return m.Offset +func (x *DataObj) GetOffset() uint64 { + if x != nil && x.Offset != nil { + return *x.Offset } return 0 } -func (m *DataObj) GetSize_() uint64 { - if m != nil { - return m.Size_ +func (x *DataObj) GetSize() uint64 { + if x != nil && x.Size != nil { + return *x.Size } return 0 } -func init() { - proto.RegisterType((*DataObj)(nil), "datastore.pb.DataObj") -} - -func init() { proto.RegisterFile("dataobj.proto", fileDescriptor_a76cb282d869d683) } - -var fileDescriptor_a76cb282d869d683 = []byte{ - // 150 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0x49, 0x2c, 0x49, - 0xcc, 0x4f, 0xca, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x71, 0x8b, 0x4b, 0xf2, - 0x8b, 0x52, 0xf5, 0x0a, 0x92, 0x94, 0x92, 0xb9, 0xd8, 0x5d, 0x12, 0x4b, 0x12, 0xfd, 0x93, 0xb2, - 0x84, 0x14, 0xb8, 0x38, 0xdc, 0x32, 0x73, 0x52, 0x03, 0x12, 0x4b, 0x32, 0x24, 0x18, 0x15, 0x18, - 0x35, 0x38, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0x8b, 0x0a, 0xc9, 0x70, 0xb1, 0xf9, - 0xa7, 0xa5, 0x15, 0xa7, 0x96, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xb0, 0x40, 0xe5, 0xa1, 0x62, 0x42, - 0x12, 0x5c, 0x2c, 0xc1, 0x99, 0x55, 0xa9, 0x12, 0xcc, 0x48, 0x72, 0x60, 0x11, 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, 0x00, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5d, 0x4a, - 0x76, 0xa0, 0x9c, 0x00, 0x00, 0x00, -} - -func (m *DataObj) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DataObj) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DataObj) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - i = encodeVarintDataobj(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x18 - i = encodeVarintDataobj(dAtA, i, uint64(m.Offset)) - i-- - dAtA[i] = 0x10 - i -= len(m.FilePath) - copy(dAtA[i:], m.FilePath) - i = encodeVarintDataobj(dAtA, i, uint64(len(m.FilePath))) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} +var File_github_com_ipfs_boxo_filestore_pb_dataobj_proto protoreflect.FileDescriptor -func encodeVarintDataobj(dAtA []byte, offset int, v uint64) int { - offset -= sovDataobj(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base +var file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDesc = []byte{ + 0x0a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, + 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2f, 0x70, 0x62, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x6f, 0x62, 0x6a, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, + 0x78, 0x6f, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x62, 0x22, + 0x81, 0x01, 0x0a, 0x07, 0x44, 0x61, 0x74, 0x61, 0x4f, 0x62, 0x6a, 0x12, 0x1f, 0x0a, 0x08, 0x46, + 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x08, 0x46, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, + 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x48, 0x01, 0x52, 0x06, + 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x53, 0x69, 0x7a, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x48, 0x02, 0x52, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x88, + 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x46, 0x69, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x42, + 0x09, 0x0a, 0x07, 0x5f, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x53, + 0x69, 0x7a, 0x65, 0x42, 0x23, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x69, 0x70, 0x66, 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x66, 0x69, 0x6c, 0x65, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -func (m *DataObj) Size() (n int) { - if m == nil { - return 0 - } - 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 -} +var ( + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescOnce sync.Once + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescData = file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDesc +) -func sovDataobj(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescGZIP() []byte { + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescOnce.Do(func() { + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescData) + }) + return file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDescData } -func sozDataobj(x uint64) (n int) { - return sovDataobj(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +var file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_goTypes = []any{ + (*DataObj)(nil), // 0: github.com.boxo.filestore.pb.DataObj } - -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 < 0 { - return ErrInvalidLengthDataobj - } - 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) < 0 { - return ErrInvalidLengthDataobj - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil +var file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } -func skipDataobj(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 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 - } - } - case 1: - iNdEx += 8 - 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 - } - } - if length < 0 { - return 0, ErrInvalidLengthDataobj - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupDataobj - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthDataobj - } - if depth == 0 { - return iNdEx, nil - } +func init() { file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_init() } +func file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_init() { + if File_github_com_ipfs_boxo_filestore_pb_dataobj_proto != nil { + return } - return 0, io.ErrUnexpectedEOF + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_msgTypes[0].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_goTypes, + DependencyIndexes: file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_depIdxs, + MessageInfos: file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_msgTypes, + }.Build() + File_github_com_ipfs_boxo_filestore_pb_dataobj_proto = out.File + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_rawDesc = nil + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_goTypes = nil + file_github_com_ipfs_boxo_filestore_pb_dataobj_proto_depIdxs = nil } - -var ( - ErrInvalidLengthDataobj = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowDataobj = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupDataobj = fmt.Errorf("proto: unexpected end of group") -) diff --git a/filestore/pb/dataobj.proto b/filestore/pb/dataobj.proto index 909d22b77..f422ecd3f 100644 --- a/filestore/pb/dataobj.proto +++ b/filestore/pb/dataobj.proto @@ -1,6 +1,8 @@ -syntax = "proto2"; +syntax = "proto3"; -package datastore.pb; +package github.com.boxo.filestore.pb; + +option go_package = "github.com/ipfs/boxo/filestore/pb"; message DataObj { optional string FilePath = 1; diff --git a/filestore/pb/gen.go b/filestore/pb/gen.go new file mode 100644 index 000000000..3a08d5d36 --- /dev/null +++ b/filestore/pb/gen.go @@ -0,0 +1,20 @@ +// These commands work around namespace conflicts that occur when multiple +// repositories depend on .proto files with generic filenames. Due to the way +// protobuf registers files (e.g., foo.proto or pb/foo.proto), naming +// collisions can occur when the same filename is used across different +// packages. +// +// The only way to generate a *.pb.go file that includes the full package path +// (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a +// directory structure that mirrors its package path. +// +// References: +// - https://protobuf.dev/reference/go/faq#namespace-conflict +// - https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265 +// +//go:generate mkdir -p github.com/ipfs/boxo/filestore/pb +//go:generate ln -f dataobj.proto github.com/ipfs/boxo/filestore/pb/ +//go:generate protoc --go_out=. github.com/ipfs/boxo/filestore/pb/dataobj.proto +//go:generate mv -f github.com/ipfs/boxo/filestore/pb/dataobj.pb.go . +//go:generate rm -rf github.com +package pb diff --git a/filestore/util.go b/filestore/util.go index 26685795b..908f21c08 100644 --- a/filestore/util.go +++ b/filestore/util.go @@ -196,7 +196,7 @@ func listAllFileOrder(ctx context.Context, fs *Filestore, verify bool) (func(con dsKey: v.Key, filePath: dobj.GetFilePath(), offset: dobj.GetOffset(), - size: dobj.GetSize_(), + size: dobj.GetSize(), }) } } @@ -226,9 +226,9 @@ func listAllFileOrder(ctx context.Context, fs *Filestore, verify bool) (func(con } // 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 @@ -280,8 +280,8 @@ func mkListRes(m mh.Multihash, d *pb.DataObj, err error) *ListRes { Status: status, ErrorMsg: errorMsg, Key: c, - FilePath: d.FilePath, - Size: d.Size_, - Offset: d.Offset, + FilePath: d.GetFilePath(), + Size: d.GetSize(), + Offset: d.GetOffset(), } } diff --git a/go.mod b/go.mod index 616cfc2bb..af1e11915 100644 --- a/go.mod +++ b/go.mod @@ -42,8 +42,8 @@ require ( github.com/libp2p/go-buffer-pool v0.1.0 github.com/libp2p/go-doh-resolver v0.5.0 github.com/libp2p/go-libp2p v0.39.0 - github.com/libp2p/go-libp2p-kad-dht v0.28.2 - github.com/libp2p/go-libp2p-record v0.2.0 + github.com/libp2p/go-libp2p-kad-dht v0.29.0 + github.com/libp2p/go-libp2p-record v0.3.1 github.com/libp2p/go-libp2p-routing-helpers v0.7.4 github.com/libp2p/go-libp2p-testing v0.12.0 github.com/libp2p/go-msgio v0.3.0 @@ -66,13 +66,13 @@ require ( github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f go.opencensus.io v0.24.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 - go.opentelemetry.io/otel v1.31.0 + go.opentelemetry.io/otel v1.34.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0 go.opentelemetry.io/otel/exporters/zipkin v1.31.0 go.opentelemetry.io/otel/sdk v1.31.0 - go.opentelemetry.io/otel/trace v1.31.0 + go.opentelemetry.io/otel/trace v1.34.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c @@ -185,8 +185,9 @@ require ( github.com/whyrusleeping/cbor-gen v0.1.2 // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/wlynxg/anet v0.0.5 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect - go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.34.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/dig v1.18.0 // indirect @@ -198,7 +199,7 @@ require ( golang.org/x/text v0.22.0 // indirect golang.org/x/tools v0.29.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect - gonum.org/v1/gonum v0.15.0 // indirect + gonum.org/v1/gonum v0.15.1 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect google.golang.org/grpc v1.67.1 // indirect diff --git a/go.sum b/go.sum index 29aa0998a..88101ef2a 100644 --- a/go.sum +++ b/go.sum @@ -279,12 +279,12 @@ github.com/libp2p/go-libp2p v0.39.0 h1:LmrhDRud4eDkQCSB4l5NfoIFDqvDwAyANmfeYkgnK github.com/libp2p/go-libp2p v0.39.0/go.mod h1:3zicI8Lp7Isun+Afo/JOACUbbJqqR2owK6RQWFsVAbI= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= -github.com/libp2p/go-libp2p-kad-dht v0.28.2 h1:/VivUl/Ru0tVgkWNhDDBy8pK6q+gRdI+z8VfqmSUJWo= -github.com/libp2p/go-libp2p-kad-dht v0.28.2/go.mod h1:sUR/qh4p/5+YFXBtwOiCmIBeBA2YD94ttmL+Xk8+pTE= +github.com/libp2p/go-libp2p-kad-dht v0.29.0 h1:045eW21lGlMSD9aKSZZGH4fnBMIInPwQLxIQ35P962I= +github.com/libp2p/go-libp2p-kad-dht v0.29.0/go.mod h1:mIci3rHSwDsxQWcCjfmxD8vMTgh5xLuvwb1D5WP8ZNk= github.com/libp2p/go-libp2p-kbucket v0.6.4 h1:OjfiYxU42TKQSB8t8WYd8MKhYhMJeO2If+NiuKfb6iQ= github.com/libp2p/go-libp2p-kbucket v0.6.4/go.mod h1:jp6w82sczYaBsAypt5ayACcRJi0lgsba7o4TzJKEfWA= -github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= -github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= +github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg= +github.com/libp2p/go-libp2p-record v0.3.1/go.mod h1:T8itUkLcWQLCYMqtX7Th6r7SexyUJpIyPgks757td/E= github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84= github.com/libp2p/go-libp2p-routing-helpers v0.7.4/go.mod h1:we5WDj9tbolBXOuF1hGOkR+r7Uh1408tQbAKaT5n1LE= github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= @@ -535,10 +535,12 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM= -go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= -go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0 h1:FFeLy03iVTXP6ffeN2iXrxfGsZGCjVx0/4KlizjyBwU= @@ -549,12 +551,12 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0 h1:UGZ1QwZWY67Z6Bm go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0/go.mod h1:fcwWuDuaObkkChiDlhEpSq9+X1C0omv+s5mBtToAQ64= go.opentelemetry.io/otel/exporters/zipkin v1.31.0 h1:CgucL0tj3717DJnni7HVVB2wExzi8c2zJNEA2BhLMvI= go.opentelemetry.io/otel/exporters/zipkin v1.31.0/go.mod h1:rfzOVNiSwIcWtEC2J8epwG26fiaXlYvLySJ7bwsrtAE= -go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= -go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= -go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= -go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -733,8 +735,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ= -gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo= +gonum.org/v1/gonum v0.15.1 h1:FNy7N6OUZVUaWG9pTiD+jlhdQ3lMP+/LcTpJ6+a8sQ0= +gonum.org/v1/gonum v0.15.1/go.mod h1:eZTZuRFrzu5pcyjN5wJhcIhnUdNijYxX1T2IcrOGY0o= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= diff --git a/ipld/unixfs/pb/Makefile b/ipld/unixfs/pb/Makefile deleted file mode 100644 index 51552a096..000000000 --- a/ipld/unixfs/pb/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -PB = $(wildcard *.proto) -GO = $(PB:.proto=.pb.go) - -all: $(GO) - -%.pb.go: %.proto - protoc --proto_path=$(GOPATH)/src:. --gogo_out=. $< - -clean: - rm -f *.pb.go - rm -f *.go diff --git a/ipld/unixfs/pb/gen.go b/ipld/unixfs/pb/gen.go new file mode 100644 index 000000000..3c6995e6c --- /dev/null +++ b/ipld/unixfs/pb/gen.go @@ -0,0 +1,20 @@ +// These commands work around namespace conflicts that occur when multiple +// repositories depend on .proto files with generic filenames. Due to the way +// protobuf registers files (e.g., foo.proto or pb/foo.proto), naming +// collisions can occur when the same filename is used across different +// packages. +// +// The only way to generate a *.pb.go file that includes the full package path +// (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a +// directory structure that mirrors its package path. +// +// References: +// - https://protobuf.dev/reference/go/faq#namespace-conflict +// - https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265 +// +//go:generate mkdir -p github.com/ipfs/boxo/ipld/unixfs/pb +//go:generate ln -f unixfs.proto github.com/ipfs/boxo/ipld/unixfs/pb/ +//go:generate protoc --go_out=. github.com/ipfs/boxo/ipld/unixfs/pb/unixfs.proto +//go:generate mv -f github.com/ipfs/boxo/ipld/unixfs/pb/unixfs.pb.go . +//go:generate rm -rf github.com +package pb diff --git a/ipld/unixfs/pb/unixfs.pb.go b/ipld/unixfs/pb/unixfs.pb.go index d02e110f2..1da20ed0d 100644 --- a/ipld/unixfs/pb/unixfs.pb.go +++ b/ipld/unixfs/pb/unixfs.pb.go @@ -1,28 +1,25 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: unixfs.proto +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.3 +// protoc v5.29.3 +// source: github.com/ipfs/boxo/ipld/unixfs/pb/unixfs.proto -package unixfs_pb +package pb import ( - fmt "fmt" - math "math" - - proto "github.com/gogo/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// 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.GoGoProtoPackageIsVersion3 // please upgrade the proto package - type Data_DataType int32 const ( @@ -34,23 +31,25 @@ const ( Data_HAMTShard Data_DataType = 5 ) -var Data_DataType_name = map[int32]string{ - 0: "Raw", - 1: "Directory", - 2: "File", - 3: "Metadata", - 4: "Symlink", - 5: "HAMTShard", -} - -var Data_DataType_value = map[string]int32{ - "Raw": 0, - "Directory": 1, - "File": 2, - "Metadata": 3, - "Symlink": 4, - "HAMTShard": 5, -} +// Enum value maps for Data_DataType. +var ( + Data_DataType_name = map[int32]string{ + 0: "Raw", + 1: "Directory", + 2: "File", + 3: "Metadata", + 4: "Symlink", + 5: "HAMTShard", + } + Data_DataType_value = map[string]int32{ + "Raw": 0, + "Directory": 1, + "File": 2, + "Metadata": 3, + "Symlink": 4, + "HAMTShard": 5, + } +) func (x Data_DataType) Enum() *Data_DataType { p := new(Data_DataType) @@ -59,160 +58,176 @@ func (x Data_DataType) Enum() *Data_DataType { } func (x Data_DataType) String() string { - return proto.EnumName(Data_DataType_name, int32(x)) -} - -func (x *Data_DataType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(Data_DataType_value, data, "Data_DataType") - if err != nil { - return err - } - *x = Data_DataType(value) - return nil + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (Data_DataType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_e2fd76cc44dfc7c3, []int{0, 0} +func (Data_DataType) Descriptor() protoreflect.EnumDescriptor { + return file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_enumTypes[0].Descriptor() } -type Data struct { - Type *Data_DataType `protobuf:"varint,1,req,name=Type,enum=unixfs.v1.pb.Data_DataType" json:"Type,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=Data" json:"Data,omitempty"` - Filesize *uint64 `protobuf:"varint,3,opt,name=filesize" json:"filesize,omitempty"` - Blocksizes []uint64 `protobuf:"varint,4,rep,name=blocksizes" json:"blocksizes,omitempty"` - HashType *uint64 `protobuf:"varint,5,opt,name=hashType" json:"hashType,omitempty"` - Fanout *uint64 `protobuf:"varint,6,opt,name=fanout" json:"fanout,omitempty"` - Mode *uint32 `protobuf:"varint,7,opt,name=mode" json:"mode,omitempty"` - Mtime *IPFSTimestamp `protobuf:"bytes,8,opt,name=mtime" json:"mtime,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Data) Reset() { *m = Data{} } -func (m *Data) String() string { return proto.CompactTextString(m) } -func (*Data) ProtoMessage() {} -func (*Data) Descriptor() ([]byte, []int) { - return fileDescriptor_e2fd76cc44dfc7c3, []int{0} +func (Data_DataType) Type() protoreflect.EnumType { + return &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_enumTypes[0] } -func (m *Data) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Data.Unmarshal(m, b) +func (x Data_DataType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -func (m *Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Data.Marshal(b, m, deterministic) +// Deprecated: Do not use. +func (x *Data_DataType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = Data_DataType(num) + return nil } -func (m *Data) XXX_Merge(src proto.Message) { - xxx_messageInfo_Data.Merge(m, src) +// Deprecated: Use Data_DataType.Descriptor instead. +func (Data_DataType) EnumDescriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescGZIP(), []int{0, 0} } -func (m *Data) XXX_Size() int { - return xxx_messageInfo_Data.Size(m) +type Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type *Data_DataType `protobuf:"varint,1,req,name=Type,enum=github.com.boxo.ipld.unixfs.pb.Data_DataType" json:"Type,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=Data" json:"Data,omitempty"` + Filesize *uint64 `protobuf:"varint,3,opt,name=filesize" json:"filesize,omitempty"` + Blocksizes []uint64 `protobuf:"varint,4,rep,name=blocksizes" json:"blocksizes,omitempty"` + HashType *uint64 `protobuf:"varint,5,opt,name=hashType" json:"hashType,omitempty"` + Fanout *uint64 `protobuf:"varint,6,opt,name=fanout" json:"fanout,omitempty"` + Mode *uint32 `protobuf:"varint,7,opt,name=mode" json:"mode,omitempty"` + Mtime *IPFSTimestamp `protobuf:"bytes,8,opt,name=mtime" json:"mtime,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Data) Reset() { + *x = Data{} + mi := &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Data) ProtoMessage() {} + +func (x *Data) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func (m *Data) XXX_DiscardUnknown() { - xxx_messageInfo_Data.DiscardUnknown(m) +// Deprecated: Use Data.ProtoReflect.Descriptor instead. +func (*Data) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescGZIP(), []int{0} } -var xxx_messageInfo_Data proto.InternalMessageInfo - -func (m *Data) GetType() Data_DataType { - if m != nil && m.Type != nil { - return *m.Type +func (x *Data) GetType() Data_DataType { + if x != nil && x.Type != nil { + return *x.Type } return Data_Raw } -func (m *Data) GetData() []byte { - if m != nil { - return m.Data +func (x *Data) GetData() []byte { + if x != nil { + return x.Data } return nil } -func (m *Data) GetFilesize() uint64 { - if m != nil && m.Filesize != nil { - return *m.Filesize +func (x *Data) GetFilesize() uint64 { + if x != nil && x.Filesize != nil { + return *x.Filesize } return 0 } -func (m *Data) GetBlocksizes() []uint64 { - if m != nil { - return m.Blocksizes +func (x *Data) GetBlocksizes() []uint64 { + if x != nil { + return x.Blocksizes } return nil } -func (m *Data) GetHashType() uint64 { - if m != nil && m.HashType != nil { - return *m.HashType +func (x *Data) GetHashType() uint64 { + if x != nil && x.HashType != nil { + return *x.HashType } return 0 } -func (m *Data) GetFanout() uint64 { - if m != nil && m.Fanout != nil { - return *m.Fanout +func (x *Data) GetFanout() uint64 { + if x != nil && x.Fanout != nil { + return *x.Fanout } return 0 } -func (m *Data) GetMode() uint32 { - if m != nil && m.Mode != nil { - return *m.Mode +func (x *Data) GetMode() uint32 { + if x != nil && x.Mode != nil { + return *x.Mode } return 0 } -func (m *Data) GetMtime() *IPFSTimestamp { - if m != nil { - return m.Mtime +func (x *Data) GetMtime() *IPFSTimestamp { + if x != nil { + return x.Mtime } return nil } type Metadata struct { - MimeType *string `protobuf:"bytes,1,opt,name=MimeType" json:"MimeType,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState `protogen:"open.v1"` + MimeType *string `protobuf:"bytes,1,opt,name=MimeType" json:"MimeType,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *Metadata) Reset() { *m = Metadata{} } -func (m *Metadata) String() string { return proto.CompactTextString(m) } -func (*Metadata) ProtoMessage() {} -func (*Metadata) Descriptor() ([]byte, []int) { - return fileDescriptor_e2fd76cc44dfc7c3, []int{1} +func (x *Metadata) Reset() { + *x = Metadata{} + mi := &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *Metadata) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Metadata.Unmarshal(m, b) +func (x *Metadata) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) -} - -func (m *Metadata) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metadata.Merge(m, src) -} +func (*Metadata) ProtoMessage() {} -func (m *Metadata) XXX_Size() int { - return xxx_messageInfo_Metadata.Size(m) +func (x *Metadata) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func (m *Metadata) XXX_DiscardUnknown() { - xxx_messageInfo_Metadata.DiscardUnknown(m) +// Deprecated: Use Metadata.ProtoReflect.Descriptor instead. +func (*Metadata) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescGZIP(), []int{1} } -var xxx_messageInfo_Metadata proto.InternalMessageInfo - -func (m *Metadata) GetMimeType() string { - if m != nil && m.MimeType != nil { - return *m.MimeType +func (x *Metadata) GetMimeType() string { + if x != nil && x.MimeType != nil { + return *x.MimeType } return "" } @@ -220,6 +235,7 @@ func (m *Metadata) GetMimeType() string { // mostly copied from proto 3 - with int32 nanos changed to fixed32 for js-ipfs compatibility // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto type IPFSTimestamp struct { + state protoimpl.MessageState `protogen:"open.v1"` // Represents seconds of UTC time since Unix epoch // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to // 9999-12-31T23:59:59Z inclusive. @@ -228,80 +244,151 @@ type IPFSTimestamp struct { // second values with fractions must still have non-negative nanos values // that count forward in time. Must be from 0 to 999,999,999 // inclusive. - Nanos *uint32 `protobuf:"fixed32,2,opt,name=nanos" json:"nanos,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Nanos *uint32 `protobuf:"fixed32,2,opt,name=nanos" json:"nanos,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (m *IPFSTimestamp) Reset() { *m = IPFSTimestamp{} } -func (m *IPFSTimestamp) String() string { return proto.CompactTextString(m) } -func (*IPFSTimestamp) ProtoMessage() {} -func (*IPFSTimestamp) Descriptor() ([]byte, []int) { - return fileDescriptor_e2fd76cc44dfc7c3, []int{2} -} -func (m *IPFSTimestamp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_IPFSTimestamp.Unmarshal(m, b) -} -func (m *IPFSTimestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_IPFSTimestamp.Marshal(b, m, deterministic) +func (x *IPFSTimestamp) Reset() { + *x = IPFSTimestamp{} + mi := &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (m *IPFSTimestamp) XXX_Merge(src proto.Message) { - xxx_messageInfo_IPFSTimestamp.Merge(m, src) -} -func (m *IPFSTimestamp) XXX_Size() int { - return xxx_messageInfo_IPFSTimestamp.Size(m) + +func (x *IPFSTimestamp) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *IPFSTimestamp) XXX_DiscardUnknown() { - xxx_messageInfo_IPFSTimestamp.DiscardUnknown(m) + +func (*IPFSTimestamp) ProtoMessage() {} + +func (x *IPFSTimestamp) ProtoReflect() protoreflect.Message { + mi := &file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_IPFSTimestamp proto.InternalMessageInfo +// Deprecated: Use IPFSTimestamp.ProtoReflect.Descriptor instead. +func (*IPFSTimestamp) Descriptor() ([]byte, []int) { + return file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescGZIP(), []int{2} +} -func (m *IPFSTimestamp) GetSeconds() int64 { - if m != nil && m.Seconds != nil { - return *m.Seconds +func (x *IPFSTimestamp) GetSeconds() int64 { + if x != nil && x.Seconds != nil { + return *x.Seconds } return 0 } -func (m *IPFSTimestamp) GetNanos() uint32 { - if m != nil && m.Nanos != nil { - return *m.Nanos +func (x *IPFSTimestamp) GetNanos() uint32 { + if x != nil && x.Nanos != nil { + return *x.Nanos } return 0 } -func init() { - proto.RegisterEnum("unixfs.v1.pb.Data_DataType", Data_DataType_name, Data_DataType_value) - proto.RegisterType((*Data)(nil), "unixfs.v1.pb.Data") - proto.RegisterType((*Metadata)(nil), "unixfs.v1.pb.Metadata") - proto.RegisterType((*IPFSTimestamp)(nil), "unixfs.pb.IPFSTimestamp") -} - -func init() { proto.RegisterFile("unixfs.proto", fileDescriptor_e2fd76cc44dfc7c3) } - -var fileDescriptor_e2fd76cc44dfc7c3 = []byte{ - // 322 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0x5f, 0x4b, 0xc3, 0x30, - 0x14, 0xc5, 0xed, 0xbf, 0xb5, 0xbb, 0xdb, 0xa4, 0x5c, 0x44, 0x82, 0x0f, 0x52, 0xfa, 0x20, 0x7d, - 0x90, 0x3e, 0xf8, 0x05, 0x44, 0x18, 0x43, 0x1f, 0x06, 0x92, 0x0d, 0xdf, 0xb3, 0x35, 0x63, 0x61, - 0x4d, 0x33, 0x9a, 0x0c, 0x9d, 0x9f, 0xd3, 0x0f, 0x24, 0x49, 0xd7, 0xe9, 0x5e, 0x4a, 0x7f, 0xb9, - 0xe7, 0x84, 0x73, 0x6e, 0x60, 0x7c, 0x68, 0xc4, 0xd7, 0x46, 0x97, 0xfb, 0x56, 0x19, 0x85, 0xc3, - 0x9e, 0x56, 0xf9, 0x8f, 0x0f, 0xe1, 0x94, 0x19, 0x86, 0x8f, 0x10, 0x2e, 0x8f, 0x7b, 0x4e, 0xbc, - 0xcc, 0x2f, 0xae, 0x9f, 0x48, 0x79, 0x96, 0x94, 0x76, 0xec, 0x3e, 0x76, 0x4e, 0x9d, 0x0a, 0xb1, - 0x73, 0x11, 0x3f, 0xf3, 0x8a, 0x31, 0xed, 0x6e, 0xb8, 0x83, 0x64, 0x23, 0x6a, 0xae, 0xc5, 0x37, - 0x27, 0x41, 0xe6, 0x15, 0x21, 0x3d, 0x33, 0xde, 0x03, 0xac, 0x6a, 0xb5, 0xde, 0x59, 0xd0, 0x24, - 0xcc, 0x82, 0x22, 0xa4, 0xff, 0x4e, 0xac, 0x77, 0xcb, 0xf4, 0xd6, 0x25, 0x88, 0x3a, 0x6f, 0xcf, - 0x78, 0x0b, 0x83, 0x0d, 0x6b, 0xd4, 0xc1, 0x90, 0x81, 0x9b, 0x9c, 0xc8, 0x66, 0x90, 0xaa, 0xe2, - 0x24, 0xce, 0xbc, 0x62, 0x42, 0xdd, 0x3f, 0x96, 0x10, 0x49, 0x23, 0x24, 0x27, 0x49, 0xe6, 0x15, - 0xa3, 0x8b, 0x1a, 0x6f, 0xef, 0xb3, 0xc5, 0x52, 0x48, 0xae, 0x0d, 0x93, 0x7b, 0xda, 0xc9, 0xf2, - 0x0f, 0x48, 0xfa, 0x66, 0x18, 0x43, 0x40, 0xd9, 0x67, 0x7a, 0x85, 0x13, 0x18, 0x4e, 0x45, 0xcb, - 0xd7, 0x46, 0xb5, 0xc7, 0xd4, 0xc3, 0x04, 0xc2, 0x99, 0xa8, 0x79, 0xea, 0xe3, 0x18, 0x92, 0x39, - 0x37, 0xac, 0x62, 0x86, 0xa5, 0x01, 0x8e, 0x20, 0x5e, 0x1c, 0x65, 0x2d, 0x9a, 0x5d, 0x1a, 0x5a, - 0xcf, 0xeb, 0xcb, 0x7c, 0xb9, 0xd8, 0xb2, 0xb6, 0x4a, 0xa3, 0xfc, 0xe1, 0x4f, 0x69, 0xbb, 0xcd, - 0x85, 0xe4, 0xa7, 0xed, 0x7a, 0xc5, 0x90, 0x9e, 0x39, 0x7f, 0x86, 0xc9, 0x45, 0x2e, 0x24, 0x10, - 0x6b, 0xbe, 0x56, 0x4d, 0xa5, 0xdd, 0x4b, 0x04, 0xb4, 0x47, 0xbc, 0x81, 0xa8, 0x61, 0x8d, 0xd2, - 0x6e, 0xe7, 0x31, 0xed, 0xe0, 0x37, 0x00, 0x00, 0xff, 0xff, 0x36, 0xaf, 0xfa, 0x7c, 0xd9, 0x01, - 0x00, 0x00, +var File_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto protoreflect.FileDescriptor + +var file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDesc = []byte{ + 0x0a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, + 0x73, 0x2f, 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x69, 0x70, 0x6c, 0x64, 0x2f, 0x75, 0x6e, 0x69, 0x78, + 0x66, 0x73, 0x2f, 0x70, 0x62, 0x2f, 0x75, 0x6e, 0x69, 0x78, 0x66, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x1e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, + 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, 0x6c, 0x64, 0x2e, 0x75, 0x6e, 0x69, 0x78, 0x66, 0x73, 0x2e, + 0x70, 0x62, 0x22, 0xfe, 0x02, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x41, 0x0a, 0x04, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, 0x6c, 0x64, + 0x2e, 0x75, 0x6e, 0x69, 0x78, 0x66, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, + 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x69, 0x7a, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x04, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x69, 0x7a, 0x65, 0x73, 0x12, 0x1a, + 0x0a, 0x08, 0x68, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x08, 0x68, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x61, + 0x6e, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x66, 0x61, 0x6e, 0x6f, + 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x43, 0x0a, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2e, 0x62, 0x6f, 0x78, 0x6f, 0x2e, 0x69, 0x70, 0x6c, 0x64, 0x2e, 0x75, 0x6e, 0x69, + 0x78, 0x66, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x50, 0x46, 0x53, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x56, 0x0a, 0x08, 0x44, + 0x61, 0x74, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x52, 0x61, 0x77, 0x10, 0x00, + 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x10, 0x01, 0x12, + 0x08, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x79, 0x6d, 0x6c, 0x69, + 0x6e, 0x6b, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x48, 0x41, 0x4d, 0x54, 0x53, 0x68, 0x61, 0x72, + 0x64, 0x10, 0x05, 0x22, 0x26, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, + 0x1a, 0x0a, 0x08, 0x4d, 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x4d, 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x3f, 0x0a, 0x0d, 0x49, + 0x50, 0x46, 0x53, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x02, 0x28, 0x03, 0x52, 0x07, 0x73, + 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x07, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42, 0x25, 0x5a, 0x23, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x70, 0x66, 0x73, 0x2f, + 0x62, 0x6f, 0x78, 0x6f, 0x2f, 0x69, 0x70, 0x6c, 0x64, 0x2f, 0x75, 0x6e, 0x69, 0x78, 0x66, 0x73, + 0x2f, 0x70, 0x62, +} + +var ( + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescOnce sync.Once + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescData = file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDesc +) + +func file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescGZIP() []byte { + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescOnce.Do(func() { + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescData) + }) + return file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDescData +} + +var file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_goTypes = []any{ + (Data_DataType)(0), // 0: github.com.boxo.ipld.unixfs.pb.Data.DataType + (*Data)(nil), // 1: github.com.boxo.ipld.unixfs.pb.Data + (*Metadata)(nil), // 2: github.com.boxo.ipld.unixfs.pb.Metadata + (*IPFSTimestamp)(nil), // 3: github.com.boxo.ipld.unixfs.pb.IPFSTimestamp +} +var file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_depIdxs = []int32{ + 0, // 0: github.com.boxo.ipld.unixfs.pb.Data.Type:type_name -> github.com.boxo.ipld.unixfs.pb.Data.DataType + 3, // 1: github.com.boxo.ipld.unixfs.pb.Data.mtime:type_name -> github.com.boxo.ipld.unixfs.pb.IPFSTimestamp + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_init() } +func file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_init() { + if File_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDesc, + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_goTypes, + DependencyIndexes: file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_depIdxs, + EnumInfos: file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_enumTypes, + MessageInfos: file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_msgTypes, + }.Build() + File_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto = out.File + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_rawDesc = nil + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_goTypes = nil + file_github_com_ipfs_boxo_ipld_unixfs_pb_unixfs_proto_depIdxs = nil } diff --git a/ipld/unixfs/pb/unixfs.proto b/ipld/unixfs/pb/unixfs.proto index bd02aa410..29241c522 100644 --- a/ipld/unixfs/pb/unixfs.proto +++ b/ipld/unixfs/pb/unixfs.proto @@ -1,8 +1,8 @@ syntax = "proto2"; -package unixfs.v1.pb; +package github.com.boxo.ipld.unixfs.pb; -option go_package = "unixfs_pb"; +option go_package = "github.com/ipfs/boxo/ipld/unixfs/pb"; message Data { enum DataType { diff --git a/ipld/unixfs/unixfs.go b/ipld/unixfs/unixfs.go index 92c7671ce..3db4f540f 100644 --- a/ipld/unixfs/unixfs.go +++ b/ipld/unixfs/unixfs.go @@ -9,11 +9,11 @@ import ( "os" "time" - proto "github.com/gogo/protobuf/proto" files "github.com/ipfs/boxo/files" dag "github.com/ipfs/boxo/ipld/merkledag" pb "github.com/ipfs/boxo/ipld/unixfs/pb" ipld "github.com/ipfs/go-ipld-format" + "google.golang.org/protobuf/proto" ) // A LinkResult for any parallel enumeration of links diff --git a/ipld/unixfs/unixfs_test.go b/ipld/unixfs/unixfs_test.go index 2b5af0bfe..a3eeff48a 100644 --- a/ipld/unixfs/unixfs_test.go +++ b/ipld/unixfs/unixfs_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - proto "github.com/gogo/protobuf/proto" pb "github.com/ipfs/boxo/ipld/unixfs/pb" + "google.golang.org/protobuf/proto" ) func TestFSNode(t *testing.T) { diff --git a/routing/offline/offline.go b/routing/offline/offline.go index b9d5281ff..b9d15b055 100644 --- a/routing/offline/offline.go +++ b/routing/offline/offline.go @@ -8,7 +8,6 @@ import ( "errors" "time" - "github.com/gogo/protobuf/proto" dshelp "github.com/ipfs/boxo/datastore/dshelp" "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" @@ -16,6 +15,7 @@ import ( pb "github.com/libp2p/go-libp2p-record/pb" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/routing" + "google.golang.org/protobuf/proto" ) // ErrOffline is returned when trying to perform operations that