Skip to content

Commit

Permalink
feat(deps): update graphsync 0.2.0 (#83)
Browse files Browse the repository at this point in the history
updates to graphsync 0.2.0 which includes ipld-prime update also
  • Loading branch information
hannahhoward committed Sep 23, 2020
1 parent d0517de commit a0d6e31
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 40 deletions.
2 changes: 1 addition & 1 deletion channels/channel_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c channelState) BaseCID() cid.Cid { return c.baseCid }
// Selector returns the IPLD selector for this data transfer (represented as
// an IPLD node)
func (c channelState) Selector() ipld.Node {
builder := basicnode.Style.Any.NewBuilder()
builder := basicnode.Prototype.Any.NewBuilder()
reader := bytes.NewReader(c.selector.Raw)
err := dagcbor.Decoder(builder, reader)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion channels/channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestChannels(t *testing.T) {
fv1 := &testutil.FakeDTType{}
fv2 := &testutil.FakeDTType{}
cids := testutil.GenerateCids(2)
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node()
peers := testutil.GeneratePeers(4)

t.Run("adding channels", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Decoder interface {
func NewDecoder(decodeType Encodable) (Decoder, error) {
// check if type is ipld.Node, if so, just use style
if ipldDecodable, ok := decodeType.(ipld.Node); ok {
return &ipldDecoder{ipldDecodable.Style()}, nil
return &ipldDecoder{ipldDecodable.Prototype()}, nil
}
// check if type is a pointer, as we need that to make new copies
// for cborgen types & regular IPLD types
Expand All @@ -73,7 +73,7 @@ func NewDecoder(decodeType Encodable) (Decoder, error) {
}

type ipldDecoder struct {
style ipld.NodeStyle
style ipld.NodePrototype
}

func (decoder *ipldDecoder) DecodeFromCbor(encoded []byte) (Encodable, error) {
Expand Down
2 changes: 1 addition & 1 deletion encoding/testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// Prime = an instance of an ipld prime piece of data
var Prime = fluent.MustBuildMap(basicnode.Style.Map, 2, func(na fluent.MapAssembler) {
var Prime = fluent.MustBuildMap(basicnode.Prototype.Map, 2, func(na fluent.MapAssembler) {
nva := na.AssembleEntry("X")
nva.AssignInt(100)
nva = na.AssembleEntry("Y")
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.13
require (
github.com/filecoin-project/go-statemachine v0.0.0-20200714194326-a77c3ae20989
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
github.com/hannahhoward/cbor-gen-for v0.0.0-20191218204337-9ab7b1bcc099
github.com/hannahhoward/cbor-gen-for v0.0.0-20200817222906-ea96cece81f1
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e
github.com/hashicorp/go-multierror v1.1.0
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.3
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.4
github.com/ipfs/go-graphsync v0.1.2
github.com/ipfs/go-graphsync v0.2.0
github.com/ipfs/go-ipfs-blockstore v1.0.1
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.5
Expand All @@ -23,7 +23,7 @@ require (
github.com/ipfs/go-log/v2 v2.0.3
github.com/ipfs/go-merkledag v0.3.2
github.com/ipfs/go-unixfs v0.2.4
github.com/ipld/go-ipld-prime v0.0.4-0.20200828224805-5ff8c8b0b6ef
github.com/ipld/go-ipld-prime v0.5.1-0.20200828233916-988837377a7f
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/libp2p/go-libp2p v0.6.0
github.com/libp2p/go-libp2p-core v0.5.0
Expand Down
25 changes: 11 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvK
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
github.com/hannahhoward/cbor-gen-for v0.0.0-20191218204337-9ab7b1bcc099 h1:vQqOW42RRM5LoM/1K5dK940VipLqpH8lEVGrMz+mNjU=
github.com/hannahhoward/cbor-gen-for v0.0.0-20191218204337-9ab7b1bcc099/go.mod h1:WVPCl0HO/0RAL5+vBH2GMxBomlxBF70MAS78+Lu1//k=
github.com/hannahhoward/cbor-gen-for v0.0.0-20200817222906-ea96cece81f1 h1:F9k+7wv5OIk1zcq23QpdiL0hfDuXPjuOmMNaC6fgQ0Q=
github.com/hannahhoward/cbor-gen-for v0.0.0-20200817222906-ea96cece81f1/go.mod h1:jvfsLIxk0fY/2BKSQ1xf2406AKA5dwMmKKv0ADcOfN8=
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e h1:3YKHER4nmd7b5qy5t0GWDTwSn4OyRgfAXSmo6VnryBY=
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e/go.mod h1:I8h3MITA53gN9OnWGCgaMa0JWVRdXthWw4M3CPM54OY=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
Expand Down Expand Up @@ -151,8 +151,8 @@ github.com/ipfs/go-ds-badger v0.0.5/go.mod h1:g5AuuCGmr7efyzQhLL8MzwqcauPojGPUaH
github.com/ipfs/go-ds-badger v0.2.1/go.mod h1:Tx7l3aTph3FMFrRS838dcSJh+jjA7cX9DrGVwx/NOwE=
github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc=
github.com/ipfs/go-ds-leveldb v0.4.1/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s=
github.com/ipfs/go-graphsync v0.1.2 h1:25Ll9kIXCE+DY0dicvfS3KMw+U5sd01b/FJbA7KAbhg=
github.com/ipfs/go-graphsync v0.1.2/go.mod h1:sLXVXm1OxtE2XYPw62MuXCdAuNwkAdsbnfrmos5odbA=
github.com/ipfs/go-graphsync v0.2.0 h1:x94MvHLNuRwBlZzVal7tR1RYK7T7H6bqQLPopxDbIF0=
github.com/ipfs/go-graphsync v0.2.0/go.mod h1:gEBvJUNelzMkaRPJTpg/jaKN4AQW/7wDWu0K92D8o10=
github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08=
github.com/ipfs/go-ipfs-blockstore v0.1.0/go.mod h1:5aD0AvHPi7mZc6Ci1WCAhiBQu2IsfTduLl+422H6Rqw=
github.com/ipfs/go-ipfs-blockstore v0.1.4 h1:2SGI6U1B44aODevza8Rde3+dY30Pb+lbcObe1LETxOQ=
Expand Down Expand Up @@ -229,12 +229,10 @@ github.com/ipfs/go-unixfs v0.2.4 h1:6NwppOXefWIyysZ4LR/qUBPvXd5//8J3jiMdvpbw6Lo=
github.com/ipfs/go-unixfs v0.2.4/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw=
github.com/ipfs/go-verifcid v0.0.1 h1:m2HI7zIuR5TFyQ1b79Da5N9dnnCP1vcu2QqawmWlK2E=
github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZc0g37pY0=
github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e h1:ZISbJlM0urTANR9KRfRaqlBmyOj5uUtxs2r4Up9IXsA=
github.com/ipld/go-ipld-prime v0.0.2-0.20200428162820-8b59dc292b8e/go.mod h1:uVIwe/u0H4VdKv3kaN1ck7uCb6yD9cFLS9/ELyXbsw8=
github.com/ipld/go-ipld-prime v0.0.4-0.20200828224805-5ff8c8b0b6ef h1:/yPelt/0CuzZsmRkYzBBnJ499JnAOGaIaAXHujx96ic=
github.com/ipld/go-ipld-prime v0.0.4-0.20200828224805-5ff8c8b0b6ef/go.mod h1:uVIwe/u0H4VdKv3kaN1ck7uCb6yD9cFLS9/ELyXbsw8=
github.com/ipld/go-ipld-prime-proto v0.0.0-20200828231332-ae0aea07222b h1:ZtlW6pubN17TDaStlxgrwEXXwwUfJaXu9RobwczXato=
github.com/ipld/go-ipld-prime-proto v0.0.0-20200828231332-ae0aea07222b/go.mod h1:OAV6xBmuTLsPZ+epzKkPB1e25FHk/vCtyatkdHcArLs=
github.com/ipld/go-ipld-prime v0.5.1-0.20200828233916-988837377a7f h1:XpOuNQ5GbXxUcSukbQcW9jkE7REpaFGJU2/T00fo9kA=
github.com/ipld/go-ipld-prime v0.5.1-0.20200828233916-988837377a7f/go.mod h1:0xEgdD6MKbZ1vF0GC+YcR/C4SQCAlRuOjIJ2i0HxqzM=
github.com/ipld/go-ipld-prime-proto v0.0.0-20200922192210-9a2bfd4440a6 h1:6Mq+tZGSEMEoJJ1NbJRhddeelkXZcU8yfH/ZRYUo/Es=
github.com/ipld/go-ipld-prime-proto v0.0.0-20200922192210-9a2bfd4440a6/go.mod h1:3pHYooM9Ea65jewRwrb2u5uHZCNkNTe9ABsVB+SrkH0=
github.com/jackpal/gateway v1.0.5 h1:qzXWUJfuMdlLMtt0a3Dgt+xkWQiA5itDEITVJtuSwMc=
github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA=
github.com/jackpal/go-nat-pmp v1.0.1 h1:i0LektDkO1QlrTm/cSuP+PyBCDnYvjPLGl4LdWEMiaA=
Expand Down Expand Up @@ -521,6 +519,8 @@ github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY=
github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=
Expand Down Expand Up @@ -552,12 +552,9 @@ github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830 h1:8kxMKmKzXXL4Ru
github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w=
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a h1:xc8sbWMwBsvi8OrxFZR8zxw/fdCneHBLFDJJaV14eaE=
github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
github.com/whyrusleeping/cbor-gen v0.0.0-20191216205031-b047b6acb3c0/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI=
github.com/whyrusleeping/cbor-gen v0.0.0-20200402171437-3d27c146c105 h1:Sh6UG5dW5xW8Ek2CtRGq4ipdEvvx9hOyBJjEGyTYDl0=
github.com/whyrusleeping/cbor-gen v0.0.0-20200402171437-3d27c146c105/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI=
github.com/whyrusleeping/cbor-gen v0.0.0-20200710004633-5379fc63235d/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c h1:BMg3YUwLEUIYBJoYZVhA4ZDTciXRj6r7ffOCshWrsoE=
github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E=
Expand Down
6 changes: 3 additions & 3 deletions message/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

func TestNewRequest(t *testing.T) {
baseCid := testutil.GenerateCids(1)[0]
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node()
isPull := true
id := datatransfer.TransferID(rand.Int31())
voucher := testutil.NewFakeDTType()
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestCompleteResponse(t *testing.T) {
}
func TestToNetFromNetEquivalency(t *testing.T) {
baseCid := testutil.GenerateCids(1)[0]
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node()
isPull := false
id := datatransfer.TransferID(rand.Int31())
accepted := false
Expand Down Expand Up @@ -314,7 +314,7 @@ func TestFromNetMessageValidation(t *testing.T) {

func NewTestTransferRequest() (datatransfer.Request, error) {
bcid := testutil.GenerateCids(1)[0]
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node()
isPull := false
id := datatransfer.TransferID(rand.Int31())
voucher := testutil.NewFakeDTType()
Expand Down
2 changes: 1 addition & 1 deletion message/transfer_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (trq *transferRequest) Selector() (ipld.Node, error) {
if trq.Stor == nil {
return nil, xerrors.New("No selector present to read")
}
builder := basicnode.Style.Any.NewBuilder()
builder := basicnode.Prototype.Any.NewBuilder()
reader := bytes.NewReader(trq.Stor.Raw)
err := dagcbor.Decoder(builder, reader)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion network/libp2p_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestMessageSendAndReceive(t *testing.T) {

t.Run("Send Request", func(t *testing.T) {
baseCid := testutil.GenerateCids(1)[0]
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node()
isPull := false
id := datatransfer.TransferID(rand.Int31())
voucher := testutil.NewFakeDTType()
Expand Down
4 changes: 2 additions & 2 deletions testutil/fakegraphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ type FakeOutgoingRequestHookActions struct {
func (fa *FakeOutgoingRequestHookActions) UsePersistenceOption(name string) {
fa.PersistenceOption = name
}
func (fa *FakeOutgoingRequestHookActions) UseLinkTargetNodeStyleChooser(_ traversal.LinkTargetNodeStyleChooser) {
func (fa *FakeOutgoingRequestHookActions) UseLinkTargetNodePrototypeChooser(_ traversal.LinkTargetNodePrototypeChooser) {
}

var _ graphsync.OutgoingRequestHookActions = &FakeOutgoingRequestHookActions{}
Expand Down Expand Up @@ -531,7 +531,7 @@ func (fa *FakeIncomingRequestHookActions) UsePersistenceOption(name string) {
fa.PersistenceOption = name
}

func (fa *FakeIncomingRequestHookActions) UseLinkTargetNodeStyleChooser(_ traversal.LinkTargetNodeStyleChooser) {
func (fa *FakeIncomingRequestHookActions) UseLinkTargetNodePrototypeChooser(_ traversal.LinkTargetNodePrototypeChooser) {
}

func (fa *FakeIncomingRequestHookActions) TerminateWithError(err error) {
Expand Down
2 changes: 1 addition & 1 deletion testutil/gstestdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
var allSelector ipld.Node

func init() {
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)
ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)
allSelector = ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func NewDTRequest(t *testing.T, transferID datatransfer.TransferID) datatransfer.Request {
voucher := NewFakeDTType()
baseCid := GenerateCids(1)[0]
selector := builder.NewSelectorSpecBuilder(basicnode.Style.Any).Matcher().Node()
selector := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node()
r, err := message.NewRequest(transferID, false, voucher.Type(), voucher, baseCid, selector)
require.NoError(t, err)
return r
Expand Down
2 changes: 1 addition & 1 deletion testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func AssertEqualSelector(t *testing.T, expectedRequest datatransfer.Request, req

// AllSelector just returns a new instance of a "whole dag selector"
func AllSelector() ipld.Node {
ssb := builder.NewSelectorSpecBuilder(basicnode.Style.Any)
ssb := builder.NewSelectorSpecBuilder(basicnode.Prototype.Any)
return ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
}
20 changes: 12 additions & 8 deletions transport/graphsync/graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,18 @@ func (t *Transport) consumeResponses(ctx context.Context, errChan <-chan error)

func (t *Transport) executeGsRequest(ctx context.Context, channelID datatransfer.ChannelID, errChan <-chan error) {
lastError := t.consumeResponses(ctx, errChan)
if _, ok := lastError.(graphsync.RequestCancelledErr); !ok {
if lastError != nil {
log.Warnf("graphsync error: %s", lastError.Error())
}
err := t.events.OnChannelCompleted(channelID, lastError == nil)
if err != nil {
log.Error(err)
}
if _, ok := lastError.(graphsync.RequestContextCancelledErr); ok {
return
}
if _, ok := lastError.(graphsync.RequestCancelledErr); ok {
return
}
if lastError != nil {
log.Warnf("graphsync error: %s", lastError.Error())
}
err := t.events.OnChannelCompleted(channelID, lastError == nil)
if err != nil {
log.Error(err)
}
}

Expand Down

0 comments on commit a0d6e31

Please sign in to comment.