From 9e9f199bd920b7db9550d97bf4c98bfc59e97f8e Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Wed, 14 Oct 2020 14:42:56 -0700 Subject: [PATCH 1/3] feat(message): switch to google protobuf after tracking down an error in Unmarshal code generate by gogoprotobuf, and verifying this is a bug in the library, which appears unmaintained, try switching to google's own golang protobuf tools --- benchmarks/testnet/virtual.go | 3 +- go.mod | 3 +- go.sum | 29 + message/message.go | 48 +- message/message_test.go | 16 +- message/pb/Makefile | 2 +- message/pb/message.pb.go | 1882 +++++++-------------------------- network/libp2p_impl.go | 6 +- 8 files changed, 438 insertions(+), 1551 deletions(-) diff --git a/benchmarks/testnet/virtual.go b/benchmarks/testnet/virtual.go index af82755a..850e4e32 100644 --- a/benchmarks/testnet/virtual.go +++ b/benchmarks/testnet/virtual.go @@ -12,6 +12,7 @@ import ( "github.com/libp2p/go-libp2p-core/peer" tnet "github.com/libp2p/go-libp2p-testing/net" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" + "google.golang.org/protobuf/proto" gsmsg "github.com/ipfs/go-graphsync/message" gsnet "github.com/ipfs/go-graphsync/network" @@ -139,7 +140,7 @@ func (n *network) SendMessage( if err != nil { return err } - size := pbMsg.Size() + size := proto.Size(pbMsg) bandwidthDelay = rateLimiter.Limit(size) } else { bandwidthDelay = 0 diff --git a/go.mod b/go.mod index 916b31d0..4dd90426 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.12 require ( github.com/gogo/protobuf v1.3.1 - github.com/golang/protobuf v1.3.2 // indirect github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f // indirect github.com/hannahhoward/cbor-gen-for v0.0.0-20200817222906-ea96cece81f1 github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e @@ -35,6 +34,7 @@ require ( github.com/libp2p/go-libp2p-netutil v0.1.0 github.com/libp2p/go-libp2p-record v0.1.1 // indirect github.com/libp2p/go-libp2p-testing v0.1.1 + github.com/libp2p/go-msgio v0.0.4 github.com/multiformats/go-multiaddr v0.2.1 github.com/multiformats/go-multihash v0.0.13 github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a // indirect @@ -44,4 +44,5 @@ require ( go.uber.org/multierr v1.4.0 // indirect golang.org/x/tools v0.0.0-20200827010519-17fd2f27a9e3 // indirect golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 + google.golang.org/protobuf v1.25.0 ) diff --git a/go.sum b/go.sum index bc4a6d7a..e122c9e7 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,7 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= @@ -55,6 +56,8 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczC github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= @@ -74,12 +77,22 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -526,6 +539,7 @@ github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 h1:CskT+S6Ay54OwxBG github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a h1:hjZfReYVLbqFkAtr2us7vdy04YWz3LVAirzP7reh8+M= github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -706,6 +720,7 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -724,8 +739,21 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -744,5 +772,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/message/message.go b/message/message.go index 63bf71df..5bed2817 100644 --- a/message/message.go +++ b/message/message.go @@ -1,6 +1,7 @@ package message import ( + "errors" "fmt" "io" @@ -9,6 +10,8 @@ import ( cid "github.com/ipfs/go-cid" "github.com/ipld/go-ipld-prime" "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-msgio" + "google.golang.org/protobuf/proto" "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/ipldutil" @@ -170,9 +173,12 @@ func newResponse(requestID graphsync.RequestID, extensions: extensions, } } -func newMessageFromProto(pbm pb.Message) (GraphSyncMessage, error) { +func newMessageFromProto(pbm *pb.Message) (GraphSyncMessage, error) { gsm := newMsg() for _, req := range pbm.Requests { + if req == nil { + return nil, errors.New("request is nil") + } var root cid.Cid var err error if !req.Cancel && !req.Update { @@ -193,10 +199,17 @@ func newMessageFromProto(pbm pb.Message) (GraphSyncMessage, error) { } for _, res := range pbm.Responses { + if res == nil { + return nil, errors.New("response is nil") + } gsm.AddResponse(newResponse(graphsync.RequestID(res.Id), graphsync.ResponseStatusCode(res.Status), res.GetExtensions())) } for _, b := range pbm.GetData() { + if b == nil { + return nil, errors.New("block is nil") + } + pref, err := cid.PrefixFromBytes(b.GetPrefix()) if err != nil { return nil, err @@ -260,23 +273,30 @@ func (gsm *graphSyncMessage) AddBlock(b blocks.Block) { // FromNet can read a network stream to deserialized a GraphSyncMessage func FromNet(r io.Reader) (GraphSyncMessage, error) { - pbr := ggio.NewDelimitedReader(r, network.MessageSizeMax) - return FromPBReader(pbr) + reader := msgio.NewVarintReaderSize(r, network.MessageSizeMax) + return FromMsgReader(reader) } -// FromPBReader can deserialize a protobuf message into a GraphySyncMessage. -func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error) { - pb := new(pb.Message) - if err := pbr.ReadMsg(pb); err != nil { +// FromMsgReader can deserialize a protobuf message into a GraphySyncMessage. +func FromMsgReader(r msgio.Reader) (GraphSyncMessage, error) { + msg, err := r.ReadMsg() + if err != nil { + return nil, err + } + + var pb pb.Message + err = proto.Unmarshal(msg, &pb) + r.ReleaseMsg(msg) + if err != nil { return nil, err } - return newMessageFromProto(*pb) + return newMessageFromProto(&pb) } func (gsm *graphSyncMessage) ToProto() (*pb.Message, error) { pbm := new(pb.Message) - pbm.Requests = make([]pb.Message_Request, 0, len(gsm.requests)) + pbm.Requests = make([]*pb.Message_Request, 0, len(gsm.requests)) for _, request := range gsm.requests { var selector []byte var err error @@ -286,7 +306,7 @@ func (gsm *graphSyncMessage) ToProto() (*pb.Message, error) { return nil, err } } - pbm.Requests = append(pbm.Requests, pb.Message_Request{ + pbm.Requests = append(pbm.Requests, &pb.Message_Request{ Id: int32(request.id), Root: request.root.Bytes(), Selector: selector, @@ -297,9 +317,9 @@ func (gsm *graphSyncMessage) ToProto() (*pb.Message, error) { }) } - pbm.Responses = make([]pb.Message_Response, 0, len(gsm.responses)) + pbm.Responses = make([]*pb.Message_Response, 0, len(gsm.responses)) for _, response := range gsm.responses { - pbm.Responses = append(pbm.Responses, pb.Message_Response{ + pbm.Responses = append(pbm.Responses, &pb.Message_Response{ Id: int32(response.requestID), Status: int32(response.status), Extensions: response.extensions, @@ -307,9 +327,9 @@ func (gsm *graphSyncMessage) ToProto() (*pb.Message, error) { } blocks := gsm.Blocks() - pbm.Data = make([]pb.Message_Block, 0, len(blocks)) + pbm.Data = make([]*pb.Message_Block, 0, len(blocks)) for _, b := range blocks { - pbm.Data = append(pbm.Data, pb.Message_Block{ + pbm.Data = append(pbm.Data, &pb.Message_Block{ Data: b.RawData(), Prefix: b.Cid().Prefix().Bytes(), }) diff --git a/message/message_test.go b/message/message_test.go index 64d0b513..c395ae74 100644 --- a/message/message_test.go +++ b/message/message_test.go @@ -57,7 +57,7 @@ func TestAppendingRequests(t *testing.T) { require.Equal(t, selectorEncoded, pbRequest.Selector) require.Equal(t, map[string][]byte{"graphsync/awesome": extension.Data}, pbRequest.Extensions) - deserialized, err := newMessageFromProto(*pbMessage) + deserialized, err := newMessageFromProto(pbMessage) require.NoError(t, err, "deserializing protobuf message errored") deserializedRequests := deserialized.Requests() require.Len(t, deserializedRequests, 1, "did not add request to deserialized message") @@ -101,7 +101,7 @@ func TestAppendingResponses(t *testing.T) { require.Equal(t, int32(status), pbResponse.Status) require.Equal(t, map[string][]byte{"graphsync/awesome": extension.Data}, pbResponse.Extensions) - deserialized, err := newMessageFromProto(*pbMessage) + deserialized, err := newMessageFromProto(pbMessage) require.NoError(t, err, "deserializing protobuf message errored") deserializedResponses := deserialized.Responses() require.Len(t, deserializedResponses, 1, "did not add response to deserialized message") @@ -374,3 +374,15 @@ func TestMergeExtensions(t *testing.T) { require.Equal(t, []byte("cheese"), extData3) }) } + +func TestKnownFuzzIssues(t *testing.T) { + inputs := []string{ + "$\x1a \x8000\x1a\x16002\xf4\xff\xff\xff\xff\xff\xff\xff\xff" + + "00000000000000000", + } + for _, input := range inputs { + //inputAsBytes, err := hex.DecodeString(input) + ///require.NoError(t, err) + _, _ = FromNet(bytes.NewReader([]byte(input))) + } +} diff --git a/message/pb/Makefile b/message/pb/Makefile index df34e54b..1cb32f3d 100644 --- a/message/pb/Makefile +++ b/message/pb/Makefile @@ -4,7 +4,7 @@ GO = $(PB:.proto=.pb.go) all: $(GO) %.pb.go: %.proto - protoc --proto_path=$(GOPATH)/src:. --gogofaster_out=. $< + protoc --proto_path=$(GOPATH)/src:. --go_out=. $< clean: rm -f *.pb.go diff --git a/message/pb/message.pb.go b/message/pb/message.pb.go index 131b94e4..981edf68 100644 --- a/message/pb/message.pb.go +++ b/message/pb/message.pb.go @@ -1,1655 +1,479 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.12.4 // source: message.proto package graphsync_message_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 -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +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) +) type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + // the actual data included in this message - CompleteRequestList bool `protobuf:"varint,1,opt,name=completeRequestList,proto3" json:"completeRequestList,omitempty"` - Requests []Message_Request `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests"` - Responses []Message_Response `protobuf:"bytes,3,rep,name=responses,proto3" json:"responses"` - Data []Message_Block `protobuf:"bytes,4,rep,name=data,proto3" json:"data"` + CompleteRequestList bool `protobuf:"varint,1,opt,name=completeRequestList,proto3" json:"completeRequestList,omitempty"` // This request list includes *all* requests, replacing outstanding requests. + Requests []*Message_Request `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests,omitempty"` // The list of requests. + Responses []*Message_Response `protobuf:"bytes,3,rep,name=responses,proto3" json:"responses,omitempty"` // The list of responses. + Data []*Message_Block `protobuf:"bytes,4,rep,name=data,proto3" json:"data,omitempty"` // Blocks related to the responses } -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 (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(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 + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} -func (m *Message) XXX_Size() int { - return m.Size() -} -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) + return mi.MessageOf(x) } -var xxx_messageInfo_Message proto.InternalMessageInfo +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{0} +} -func (m *Message) GetCompleteRequestList() bool { - if m != nil { - return m.CompleteRequestList +func (x *Message) GetCompleteRequestList() bool { + if x != nil { + return x.CompleteRequestList } return false } -func (m *Message) GetRequests() []Message_Request { - if m != nil { - return m.Requests +func (x *Message) GetRequests() []*Message_Request { + if x != nil { + return x.Requests } return nil } -func (m *Message) GetResponses() []Message_Response { - if m != nil { - return m.Responses +func (x *Message) GetResponses() []*Message_Response { + if x != nil { + return x.Responses } return nil } -func (m *Message) GetData() []Message_Block { - if m != nil { - return m.Data +func (x *Message) GetData() []*Message_Block { + if x != nil { + return x.Data } return nil } type Message_Request struct { - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Root []byte `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` - Selector []byte `protobuf:"bytes,3,opt,name=selector,proto3" json:"selector,omitempty"` - Extensions map[string][]byte `protobuf:"bytes,4,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Priority int32 `protobuf:"varint,5,opt,name=priority,proto3" json:"priority,omitempty"` - Cancel bool `protobuf:"varint,6,opt,name=cancel,proto3" json:"cancel,omitempty"` - Update bool `protobuf:"varint,7,opt,name=update,proto3" json:"update,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // unique id set on the requester side + Root []byte `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` // a CID for the root node in the query + Selector []byte `protobuf:"bytes,3,opt,name=selector,proto3" json:"selector,omitempty"` // ipld selector to retrieve + Extensions map[string][]byte `protobuf:"bytes,4,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // aux information. useful for other protocols + Priority int32 `protobuf:"varint,5,opt,name=priority,proto3" json:"priority,omitempty"` // the priority (normalized). default to 1 + Cancel bool `protobuf:"varint,6,opt,name=cancel,proto3" json:"cancel,omitempty"` // whether this cancels a request + Update bool `protobuf:"varint,7,opt,name=update,proto3" json:"update,omitempty"` // whether this requests resumes a previous request } -func (m *Message_Request) Reset() { *m = Message_Request{} } -func (m *Message_Request) String() string { return proto.CompactTextString(m) } -func (*Message_Request) ProtoMessage() {} -func (*Message_Request) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 0} +func (x *Message_Request) Reset() { + *x = Message_Request{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Message_Request) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (x *Message_Request) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message_Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Request.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err + +func (*Message_Request) ProtoMessage() {} + +func (x *Message_Request) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -func (m *Message_Request) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Request.Merge(m, src) -} -func (m *Message_Request) XXX_Size() int { - return m.Size() -} -func (m *Message_Request) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Request.DiscardUnknown(m) + return mi.MessageOf(x) } -var xxx_messageInfo_Message_Request proto.InternalMessageInfo +// Deprecated: Use Message_Request.ProtoReflect.Descriptor instead. +func (*Message_Request) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{0, 0} +} -func (m *Message_Request) GetId() int32 { - if m != nil { - return m.Id +func (x *Message_Request) GetId() int32 { + if x != nil { + return x.Id } return 0 } -func (m *Message_Request) GetRoot() []byte { - if m != nil { - return m.Root +func (x *Message_Request) GetRoot() []byte { + if x != nil { + return x.Root } return nil } -func (m *Message_Request) GetSelector() []byte { - if m != nil { - return m.Selector +func (x *Message_Request) GetSelector() []byte { + if x != nil { + return x.Selector } return nil } -func (m *Message_Request) GetExtensions() map[string][]byte { - if m != nil { - return m.Extensions +func (x *Message_Request) GetExtensions() map[string][]byte { + if x != nil { + return x.Extensions } return nil } -func (m *Message_Request) GetPriority() int32 { - if m != nil { - return m.Priority +func (x *Message_Request) GetPriority() int32 { + if x != nil { + return x.Priority } return 0 } -func (m *Message_Request) GetCancel() bool { - if m != nil { - return m.Cancel +func (x *Message_Request) GetCancel() bool { + if x != nil { + return x.Cancel } return false } -func (m *Message_Request) GetUpdate() bool { - if m != nil { - return m.Update +func (x *Message_Request) GetUpdate() bool { + if x != nil { + return x.Update } return false } type Message_Response struct { - Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` - Extensions map[string][]byte `protobuf:"bytes,3,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Message_Response) Reset() { *m = Message_Response{} } -func (m *Message_Response) String() string { return proto.CompactTextString(m) } -func (*Message_Response) ProtoMessage() {} -func (*Message_Response) Descriptor() ([]byte, []int) { - return fileDescriptor_33c57e4bae7b9afd, []int{0, 1} -} -func (m *Message_Response) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Response.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_Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Response.Merge(m, src) -} -func (m *Message_Response) XXX_Size() int { - return m.Size() -} -func (m *Message_Response) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Response.DiscardUnknown(m) + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // the request id + Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` // a status code. + Extensions map[string][]byte `protobuf:"bytes,3,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // additional data } -var xxx_messageInfo_Message_Response proto.InternalMessageInfo - -func (m *Message_Response) GetId() int32 { - if m != nil { - return m.Id +func (x *Message_Response) Reset() { + *x = Message_Response{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return 0 } -func (m *Message_Response) GetStatus() int32 { - if m != nil { - return m.Status - } - return 0 +func (x *Message_Response) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message_Response) GetExtensions() map[string][]byte { - if m != nil { - return m.Extensions - } - return nil -} - -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"` -} +func (*Message_Response) ProtoMessage() {} -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, 2} -} -func (m *Message_Block) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -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 (x *Message_Response) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && 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) -} - -var xxx_messageInfo_Message_Block proto.InternalMessageInfo -func (m *Message_Block) GetPrefix() []byte { - if m != nil { - return m.Prefix - } - return nil -} - -func (m *Message_Block) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func init() { - proto.RegisterType((*Message)(nil), "graphsync.message.pb.Message") - proto.RegisterType((*Message_Request)(nil), "graphsync.message.pb.Message.Request") - proto.RegisterMapType((map[string][]byte)(nil), "graphsync.message.pb.Message.Request.ExtensionsEntry") - proto.RegisterType((*Message_Response)(nil), "graphsync.message.pb.Message.Response") - proto.RegisterMapType((map[string][]byte)(nil), "graphsync.message.pb.Message.Response.ExtensionsEntry") - proto.RegisterType((*Message_Block)(nil), "graphsync.message.pb.Message.Block") -} - -func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) } - -var fileDescriptor_33c57e4bae7b9afd = []byte{ - // 458 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x8d, 0x9d, 0xd8, 0x49, 0x2f, 0xe5, 0xa1, 0xa1, 0xaa, 0x46, 0x5e, 0x98, 0x08, 0x04, 0xca, - 0x06, 0x17, 0x51, 0x81, 0x10, 0x52, 0x37, 0x91, 0x2a, 0x24, 0x04, 0x9b, 0x91, 0x60, 0xef, 0x38, - 0xb7, 0xae, 0x55, 0xc7, 0x63, 0x66, 0xc6, 0xa8, 0xfe, 0x0b, 0xfe, 0x83, 0x7f, 0x60, 0x5d, 0x76, - 0x5d, 0xb2, 0x42, 0x28, 0xf9, 0x11, 0xe4, 0x3b, 0x83, 0x79, 0x55, 0xa5, 0x12, 0xbb, 0x7b, 0xee, - 0xcc, 0x39, 0xf7, 0x71, 0x66, 0xe0, 0xfa, 0x0a, 0xb5, 0x4e, 0x73, 0x4c, 0x6a, 0x25, 0x8d, 0x64, - 0x3b, 0xb9, 0x4a, 0xeb, 0x63, 0xdd, 0x56, 0x59, 0xd2, 0x1f, 0x2c, 0xa2, 0x87, 0x79, 0x61, 0x8e, - 0x9b, 0x45, 0x92, 0xc9, 0xd5, 0x5e, 0x2e, 0x73, 0xb9, 0x47, 0x97, 0x17, 0xcd, 0x11, 0x21, 0x02, - 0x14, 0x59, 0x91, 0xbb, 0x9f, 0x42, 0x18, 0xbf, 0xb6, 0x6c, 0xf6, 0x08, 0x6e, 0x67, 0x72, 0x55, - 0x97, 0x68, 0x50, 0xe0, 0xbb, 0x06, 0xb5, 0x79, 0x55, 0x68, 0xc3, 0xbd, 0xa9, 0x37, 0x9b, 0x88, - 0x8b, 0x8e, 0xd8, 0x0b, 0x98, 0x28, 0x0b, 0x35, 0xf7, 0xa7, 0xc3, 0xd9, 0xb5, 0xc7, 0xf7, 0x93, - 0x8b, 0xba, 0x4a, 0x5c, 0x89, 0xc4, 0x91, 0xe7, 0xa3, 0xb3, 0xaf, 0x77, 0x06, 0xa2, 0x27, 0xb3, - 0x97, 0xb0, 0xa5, 0x50, 0xd7, 0xb2, 0xd2, 0xa8, 0xf9, 0x90, 0x94, 0x1e, 0xfc, 0x4b, 0xc9, 0x5e, - 0x77, 0x52, 0x3f, 0xe9, 0xec, 0x00, 0x46, 0xcb, 0xd4, 0xa4, 0x7c, 0x44, 0x32, 0xf7, 0x2e, 0x97, - 0x99, 0x97, 0x32, 0x3b, 0x71, 0x1a, 0x44, 0x8b, 0x3e, 0xfa, 0x30, 0x76, 0x6d, 0xb2, 0x1b, 0xe0, - 0x17, 0x4b, 0x5a, 0x40, 0x20, 0xfc, 0x62, 0xc9, 0x18, 0x8c, 0x94, 0x94, 0x86, 0xfb, 0x53, 0x6f, - 0xb6, 0x2d, 0x28, 0x66, 0x11, 0x4c, 0x34, 0x96, 0x98, 0x19, 0xa9, 0xf8, 0x90, 0xf2, 0x3d, 0x66, - 0x6f, 0x00, 0xf0, 0xd4, 0x60, 0xa5, 0x0b, 0x59, 0x69, 0xd7, 0xd0, 0x93, 0x2b, 0x6d, 0x28, 0x39, - 0xec, 0x79, 0x87, 0x95, 0x51, 0xad, 0xf8, 0x45, 0xa8, 0x2b, 0x59, 0xab, 0x42, 0xaa, 0xc2, 0xb4, - 0x3c, 0xa0, 0xe6, 0x7a, 0xcc, 0x76, 0x21, 0xcc, 0xd2, 0x2a, 0xc3, 0x92, 0x87, 0xe4, 0x9b, 0x43, - 0x5d, 0xbe, 0xa9, 0x97, 0xa9, 0x41, 0x3e, 0xb6, 0x79, 0x8b, 0xa2, 0x03, 0xb8, 0xf9, 0x47, 0x29, - 0x76, 0x0b, 0x86, 0x27, 0xd8, 0xd2, 0xd8, 0x5b, 0xa2, 0x0b, 0xd9, 0x0e, 0x04, 0xef, 0xd3, 0xb2, - 0x41, 0x37, 0xb8, 0x05, 0xcf, 0xfd, 0x67, 0x5e, 0xf4, 0xd9, 0x83, 0xc9, 0x0f, 0x2b, 0xfe, 0x5a, - 0xd7, 0x2e, 0x84, 0xda, 0xa4, 0xa6, 0xd1, 0xc4, 0x0b, 0x84, 0x43, 0xec, 0xed, 0x6f, 0x6b, 0xb1, - 0x76, 0x3f, 0xbd, 0x9a, 0xdd, 0x97, 0xed, 0xe5, 0x7f, 0x67, 0xd9, 0x87, 0x80, 0x9e, 0x43, 0xd7, - 0x77, 0xad, 0xf0, 0xa8, 0x38, 0x25, 0xde, 0xb6, 0x70, 0xa8, 0xb3, 0x9f, 0x5e, 0x96, 0xb3, 0xbf, - 0x8b, 0xe7, 0xfc, 0x6c, 0x1d, 0x7b, 0xe7, 0xeb, 0xd8, 0xfb, 0xb6, 0x8e, 0xbd, 0x0f, 0x9b, 0x78, - 0x70, 0xbe, 0x89, 0x07, 0x5f, 0x36, 0xf1, 0x60, 0x11, 0xd2, 0x0f, 0xdb, 0xff, 0x1e, 0x00, 0x00, - 0xff, 0xff, 0xaa, 0x5e, 0x01, 0x7e, 0xb7, 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 len(m.Data) > 0 { - for iNdEx := len(m.Data) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Data[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.Responses) > 0 { - for iNdEx := len(m.Responses) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Responses[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.Requests) > 0 { - for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMessage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.CompleteRequestList { - i-- - if m.CompleteRequestList { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Message_Request) 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_Request) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// Deprecated: Use Message_Response.ProtoReflect.Descriptor instead. +func (*Message_Response) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{0, 1} } -func (m *Message_Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Update { - i-- - if m.Update { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x38 +func (x *Message_Response) GetId() int32 { + if x != nil { + return x.Id } - if m.Cancel { - i-- - if m.Cancel { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } - if m.Priority != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.Priority)) - i-- - dAtA[i] = 0x28 - } - if len(m.Extensions) > 0 { - for k := range m.Extensions { - v := m.Extensions[k] - baseI := i - if len(v) > 0 { - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintMessage(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintMessage(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintMessage(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x22 - } - } - if len(m.Selector) > 0 { - i -= len(m.Selector) - copy(dAtA[i:], m.Selector) - i = encodeVarintMessage(dAtA, i, uint64(len(m.Selector))) - i-- - dAtA[i] = 0x1a - } - if len(m.Root) > 0 { - i -= len(m.Root) - copy(dAtA[i:], m.Root) - i = encodeVarintMessage(dAtA, i, uint64(len(m.Root))) - i-- - dAtA[i] = 0x12 - } - if m.Id != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + return 0 } -func (m *Message_Response) 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_Response) GetStatus() int32 { + if x != nil { + return x.Status } - return dAtA[:n], nil -} - -func (m *Message_Response) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return 0 } -func (m *Message_Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Extensions) > 0 { - for k := range m.Extensions { - v := m.Extensions[k] - baseI := i - if len(v) > 0 { - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintMessage(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - } - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintMessage(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintMessage(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x1a - } - } - if m.Status != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x10 +func (x *Message_Response) GetExtensions() map[string][]byte { + if x != nil { + return x.Extensions } - if m.Id != 0 { - i = encodeVarintMessage(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + return nil } -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 -} +type Message_Block struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Message_Block) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + 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"` } -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 - } - 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 +func (x *Message_Block) Reset() { + *x = Message_Block{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return len(dAtA) - i, nil } -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 (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CompleteRequestList { - n += 2 - } - if len(m.Requests) > 0 { - for _, e := range m.Requests { - l = e.Size() - n += 1 + l + sovMessage(uint64(l)) - } - } - if len(m.Responses) > 0 { - for _, e := range m.Responses { - l = e.Size() - n += 1 + l + sovMessage(uint64(l)) - } - } - if len(m.Data) > 0 { - for _, e := range m.Data { - l = e.Size() - n += 1 + l + sovMessage(uint64(l)) - } - } - return n +func (x *Message_Block) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message_Request) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovMessage(uint64(m.Id)) - } - l = len(m.Root) - if l > 0 { - n += 1 + l + sovMessage(uint64(l)) - } - l = len(m.Selector) - if l > 0 { - n += 1 + l + sovMessage(uint64(l)) - } - if len(m.Extensions) > 0 { - for k, v := range m.Extensions { - _ = k - _ = v - l = 0 - if len(v) > 0 { - l = 1 + len(v) + sovMessage(uint64(len(v))) - } - mapEntrySize := 1 + len(k) + sovMessage(uint64(len(k))) + l - n += mapEntrySize + 1 + sovMessage(uint64(mapEntrySize)) - } - } - if m.Priority != 0 { - n += 1 + sovMessage(uint64(m.Priority)) - } - if m.Cancel { - n += 2 - } - if m.Update { - n += 2 - } - return n -} +func (*Message_Block) ProtoMessage() {} -func (m *Message_Response) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovMessage(uint64(m.Id)) - } - if m.Status != 0 { - n += 1 + sovMessage(uint64(m.Status)) - } - if len(m.Extensions) > 0 { - for k, v := range m.Extensions { - _ = k - _ = v - l = 0 - if len(v) > 0 { - l = 1 + len(v) + sovMessage(uint64(len(v))) - } - mapEntrySize := 1 + len(k) + sovMessage(uint64(len(k))) + l - n += mapEntrySize + 1 + sovMessage(uint64(mapEntrySize)) +func (x *Message_Block) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } + return ms } - return n -} - -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 + return mi.MessageOf(x) } -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)))) +// Deprecated: Use Message_Block.ProtoReflect.Descriptor instead. +func (*Message_Block) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{0, 2} } -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 != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CompleteRequestList", 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.CompleteRequestList = bool(v != 0) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Requests", 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.Requests = append(m.Requests, Message_Request{}) - if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Responses", 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.Responses = append(m.Responses, Message_Response{}) - if err := m.Responses[len(m.Responses)-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 Data", 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.Data = append(m.Data, Message_Block{}) - if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Block) GetPrefix() []byte { + if x != nil { + return x.Prefix } return nil } -func (m *Message_Request) 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: Request: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Root", 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.Root = append(m.Root[:0], dAtA[iNdEx:postIndex]...) - if m.Root == nil { - m.Root = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Selector", 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.Selector = append(m.Selector[:0], dAtA[iNdEx:postIndex]...) - if m.Selector == nil { - m.Selector = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extensions", 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 m.Extensions == nil { - m.Extensions = make(map[string][]byte) - } - var mapkey string - mapvalue := []byte{} - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthMessage - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthMessage - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapbyteLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapbyteLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intMapbyteLen := int(mapbyteLen) - if intMapbyteLen < 0 { - return ErrInvalidLengthMessage - } - postbytesIndex := iNdEx + intMapbyteLen - if postbytesIndex < 0 { - return ErrInvalidLengthMessage - } - if postbytesIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = make([]byte, mapbyteLen) - copy(mapvalue, dAtA[iNdEx:postbytesIndex]) - iNdEx = postbytesIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Extensions[mapkey] = mapvalue - iNdEx = postIndex - case 5: - 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 6: - 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 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Update", 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.Update = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF +func (x *Message_Block) GetData() []byte { + if x != nil { + return x.Data } return nil } -func (m *Message_Response) 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: Response: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extensions", 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 m.Extensions == nil { - m.Extensions = make(map[string][]byte) - } - var mapkey string - mapvalue := []byte{} - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthMessage - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthMessage - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapbyteLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMessage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapbyteLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intMapbyteLen := int(mapbyteLen) - if intMapbyteLen < 0 { - return ErrInvalidLengthMessage - } - postbytesIndex := iNdEx + intMapbyteLen - if postbytesIndex < 0 { - return ErrInvalidLengthMessage - } - if postbytesIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = make([]byte, mapbyteLen) - copy(mapvalue, dAtA[iNdEx:postbytesIndex]) - iNdEx = postbytesIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Extensions[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMessage(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -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 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMessage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -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_message_proto protoreflect.FileDescriptor + +var file_message_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x14, 0x67, 0x72, 0x61, 0x70, 0x68, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x70, 0x62, 0x1a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x06, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x30, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x63, + 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x47, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x73, 0x79, 0x6e, 0x63, + 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, + 0x00, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x4a, 0x0a, 0x09, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, + 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x09, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x73, 0x79, 0x6e, + 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0xab, 0x02, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x12, 0x55, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x73, 0x79, + 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x05, 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, + 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x12, 0x16, 0x0a, + 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x1a, 0x3d, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x1a, 0xc9, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x56, 0x0a, 0x0a, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, + 0x67, 0x72, 0x61, 0x70, 0x68, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 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, 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_message_proto_rawDescOnce sync.Once + file_message_proto_rawDescData = file_message_proto_rawDesc ) + +func file_message_proto_rawDescGZIP() []byte { + file_message_proto_rawDescOnce.Do(func() { + file_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_message_proto_rawDescData) + }) + return file_message_proto_rawDescData +} + +var file_message_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_message_proto_goTypes = []interface{}{ + (*Message)(nil), // 0: graphsync.message.pb.Message + (*Message_Request)(nil), // 1: graphsync.message.pb.Message.Request + (*Message_Response)(nil), // 2: graphsync.message.pb.Message.Response + (*Message_Block)(nil), // 3: graphsync.message.pb.Message.Block + nil, // 4: graphsync.message.pb.Message.Request.ExtensionsEntry + nil, // 5: graphsync.message.pb.Message.Response.ExtensionsEntry +} +var file_message_proto_depIdxs = []int32{ + 1, // 0: graphsync.message.pb.Message.requests:type_name -> graphsync.message.pb.Message.Request + 2, // 1: graphsync.message.pb.Message.responses:type_name -> graphsync.message.pb.Message.Response + 3, // 2: graphsync.message.pb.Message.data:type_name -> graphsync.message.pb.Message.Block + 4, // 3: graphsync.message.pb.Message.Request.extensions:type_name -> graphsync.message.pb.Message.Request.ExtensionsEntry + 5, // 4: graphsync.message.pb.Message.Response.extensions:type_name -> graphsync.message.pb.Message.Response.ExtensionsEntry + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_message_proto_init() } +func file_message_proto_init() { + if File_message_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_Block); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_message_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_message_proto_goTypes, + DependencyIndexes: file_message_proto_depIdxs, + MessageInfos: file_message_proto_msgTypes, + }.Build() + File_message_proto = out.File + file_message_proto_rawDesc = nil + file_message_proto_goTypes = nil + file_message_proto_depIdxs = nil +} diff --git a/network/libp2p_impl.go b/network/libp2p_impl.go index a54a3a42..890b7562 100644 --- a/network/libp2p_impl.go +++ b/network/libp2p_impl.go @@ -6,12 +6,12 @@ import ( "io" "time" - ggio "github.com/gogo/protobuf/io" logging "github.com/ipfs/go-log" "github.com/libp2p/go-libp2p-core/helpers" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-msgio" ma "github.com/multiformats/go-multiaddr" gsmsg "github.com/ipfs/go-graphsync/message" @@ -136,9 +136,9 @@ func (gsnet *libp2pGraphSyncNetwork) handleNewStream(s network.Stream) { return } - reader := ggio.NewDelimitedReader(s, network.MessageSizeMax) + reader := msgio.NewVarintReaderSize(s, network.MessageSizeMax) for { - received, err := gsmsg.FromPBReader(reader) + received, err := gsmsg.FromMsgReader(reader) if err != nil { if err != io.EOF { _ = s.Reset() From e59b28e577d2c5b620cc74eb482fa78f9697428c Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Wed, 14 Oct 2020 16:59:37 -0700 Subject: [PATCH 2/3] fix(message): upgrade msgio resolve bad message strings --- go.mod | 2 +- go.sum | 4 ++++ message/message_test.go | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 4dd90426..05fbe725 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/libp2p/go-libp2p-netutil v0.1.0 github.com/libp2p/go-libp2p-record v0.1.1 // indirect github.com/libp2p/go-libp2p-testing v0.1.1 - github.com/libp2p/go-msgio v0.0.4 + github.com/libp2p/go-msgio v0.0.6 github.com/multiformats/go-multiaddr v0.2.1 github.com/multiformats/go-multihash v0.0.13 github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a // indirect diff --git a/go.sum b/go.sum index e122c9e7..91bdb59e 100644 --- a/go.sum +++ b/go.sum @@ -394,6 +394,8 @@ github.com/libp2p/go-msgio v0.0.2/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+ github.com/libp2p/go-msgio v0.0.3/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.0.4 h1:agEFehY3zWJFUHK6SEMR7UYmk2z6kC3oeCM7ybLhguA= github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= +github.com/libp2p/go-msgio v0.0.6 h1:lQ7Uc0kS1wb1EfRxO2Eir/RJoHkHn7t6o+EiwsYIKJA= +github.com/libp2p/go-msgio v0.0.6/go.mod h1:4ecVB6d9f4BDSL5fqvPiC4A3KivjWn+Venn/1ALLMWA= github.com/libp2p/go-nat v0.0.3 h1:l6fKV+p0Xa354EqQOQP+d8CivdLM4kl5GxC1hSc/UeI= github.com/libp2p/go-nat v0.0.3/go.mod h1:88nUEt0k0JD45Bk93NIwDqjlhiOwOoV36GchpcVc1yI= github.com/libp2p/go-nat v0.0.4 h1:KbizNnq8YIf7+Hn7+VFL/xE0eDrkPru2zIO9NMwL8UQ= @@ -509,6 +511,8 @@ github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS github.com/multiformats/go-varint v0.0.2/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= +github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= diff --git a/message/message_test.go b/message/message_test.go index c395ae74..6711ff1f 100644 --- a/message/message_test.go +++ b/message/message_test.go @@ -379,6 +379,14 @@ func TestKnownFuzzIssues(t *testing.T) { inputs := []string{ "$\x1a \x8000\x1a\x16002\xf4\xff\xff\xff\xff\xff\xff\xff\xff" + "00000000000000000", + "���\x01", + "Dخ0000000000\x12000000" + + "00000000000000000000" + + "000000000 0000000000" + + "000000000", + "�\xefĽ�\x01\"# \n\v5 " + + " \n\x10\x01\x80\x01\x19@\xbf\xbd\xff " + + " \n\v ", } for _, input := range inputs { //inputAsBytes, err := hex.DecodeString(input) From c340d0f922014ff5f484333273903e061b853974 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Thu, 15 Oct 2020 04:47:00 -0700 Subject: [PATCH 3/3] feat(message): initialize empty extensions Initialize extensions to map if nil --- message/message.go | 12 ++++++++++-- message/message_test.go | 14 +++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/message/message.go b/message/message.go index 5bed2817..c4c2416a 100644 --- a/message/message.go +++ b/message/message.go @@ -195,14 +195,22 @@ func newMessageFromProto(pbm *pb.Message) (GraphSyncMessage, error) { return nil, err } } - gsm.AddRequest(newRequest(graphsync.RequestID(req.Id), root, selector, graphsync.Priority(req.Priority), req.Cancel, req.Update, req.GetExtensions())) + exts := req.GetExtensions() + if exts == nil { + exts = make(map[string][]byte) + } + gsm.AddRequest(newRequest(graphsync.RequestID(req.Id), root, selector, graphsync.Priority(req.Priority), req.Cancel, req.Update, exts)) } for _, res := range pbm.Responses { if res == nil { return nil, errors.New("response is nil") } - gsm.AddResponse(newResponse(graphsync.RequestID(res.Id), graphsync.ResponseStatusCode(res.Status), res.GetExtensions())) + exts := res.GetExtensions() + if exts == nil { + exts = make(map[string][]byte) + } + gsm.AddResponse(newResponse(graphsync.RequestID(res.Id), graphsync.ResponseStatusCode(res.Status), exts)) } for _, b := range pbm.GetData() { diff --git a/message/message_test.go b/message/message_test.go index 6711ff1f..03a3e067 100644 --- a/message/message_test.go +++ b/message/message_test.go @@ -387,10 +387,22 @@ func TestKnownFuzzIssues(t *testing.T) { "�\xefĽ�\x01\"# \n\v5 " + " \n\x10\x01\x80\x01\x19@\xbf\xbd\xff " + " \n\v ", + "\x0600\x1a\x02\x180", } for _, input := range inputs { //inputAsBytes, err := hex.DecodeString(input) ///require.NoError(t, err) - _, _ = FromNet(bytes.NewReader([]byte(input))) + msg1, err := FromNet(bytes.NewReader([]byte(input))) + if err != nil { + continue + } + buf2 := new(bytes.Buffer) + err = msg1.ToNet(buf2) + require.NoError(t, err) + + msg2, err := FromNet(buf2) + require.NoError(t, err) + + require.Equal(t, msg1, msg2) } }