From a263fb52e660d466fbb4c8f2c8bea9788bcdffbd Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Tue, 15 Mar 2022 22:19:14 +0000 Subject: [PATCH] Remove temporary fixed by depending on specfic commit in sti Depend on head of PR that removes `Metadata` type in storetheindex so that we can remove all workarounds: - https://github.com/filecoin-project/storetheindex/pull/260 --- cmd/go.mod | 4 ++-- cmd/go.sum | 16 ++++++++-------- cmd/provider/find.go | 3 +-- cmd/provider/index.go | 9 +-------- e2e_retrieve_test.go | 7 +++---- engine/engine.go | 5 ++--- engine/engine_test.go | 8 ++++---- go.mod | 4 ++-- go.sum | 16 ++++++++-------- metadata/graphsync_filecoinv1_test.go | 16 +--------------- metadata/hack.go | 24 ------------------------ 11 files changed, 32 insertions(+), 80 deletions(-) delete mode 100644 metadata/hack.go diff --git a/cmd/go.mod b/cmd/go.mod index 4278e206..45006518 100644 --- a/cmd/go.mod +++ b/cmd/go.mod @@ -4,9 +4,9 @@ go 1.16 require ( github.com/filecoin-project/go-data-transfer v1.14.0 - github.com/filecoin-project/go-legs v0.3.8 + github.com/filecoin-project/go-legs v0.3.9 github.com/filecoin-project/index-provider v0.2.1 - github.com/filecoin-project/storetheindex v0.3.5 + github.com/filecoin-project/storetheindex v0.3.8-0.20220315214537-69eb9e149f86 github.com/ipfs/go-cid v0.1.0 github.com/ipfs/go-datastore v0.5.1 github.com/ipfs/go-ds-leveldb v0.5.0 diff --git a/cmd/go.sum b/cmd/go.sum index bc1c012a..5ea3bfa0 100644 --- a/cmd/go.sum +++ b/cmd/go.sum @@ -199,6 +199,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5/go.mod h1:JpoxHjuQauoxiFMl1ie8Xc/7TfLuMZ5eOCONd1sUBHg= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= github.com/filecoin-project/go-address v0.0.5 h1:SSaFT/5aLfPXycUlFyemoHYhRgdyXClXCyDdNJKPlDM= github.com/filecoin-project/go-address v0.0.5/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= @@ -212,10 +213,9 @@ github.com/filecoin-project/go-data-transfer v1.14.0/go.mod h1:wNJKhaLLYBJDM3VFv github.com/filecoin-project/go-ds-versioning v0.0.0-20211206185234-508abd7c2aff/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= github.com/filecoin-project/go-ds-versioning v0.1.1 h1:JiyBqaQlwC+UM0WhcBtVEeT3XrX59mQhT8U3p7nu86o= github.com/filecoin-project/go-ds-versioning v0.1.1/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= -github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY= -github.com/filecoin-project/go-legs v0.3.7/go.mod h1:pgekGm8/gKY5zCtQ/qGAoSjGP92wTLFqpO3GPHeu8YU= -github.com/filecoin-project/go-legs v0.3.8 h1:HDhunjC+E5g3s47zUQY/YnDveatOXWJyfK519jdKhOA= -github.com/filecoin-project/go-legs v0.3.8/go.mod h1:FroH5LQUTfYzs8huA4PjW8spDF691uvK8uk9YAfDa78= +github.com/filecoin-project/go-indexer-core v0.2.9/go.mod h1:u03I3HB6ZnqCc3cm8Tq+QkTWBbfKOvNxM8K6Ny/IHRw= +github.com/filecoin-project/go-legs v0.3.9 h1:YDW+nHn3fdl/5M7dE0EOxU8E3EgJGjuccLcz9xaT3kg= +github.com/filecoin-project/go-legs v0.3.9/go.mod h1:FroH5LQUTfYzs8huA4PjW8spDF691uvK8uk9YAfDa78= github.com/filecoin-project/go-state-types v0.1.0 h1:9r2HCSMMCmyMfGyMKxQtv0GKp6VT/m5GgVk8EhYbLJU= github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe h1:dF8u+LEWeIcTcfUcCf3WFVlc81Fr2JKg8zPzIbBDKDw= @@ -223,8 +223,8 @@ github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/g github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNdofHZoGPjfNaAo5Q= github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= -github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q= -github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI= +github.com/filecoin-project/storetheindex v0.3.8-0.20220315214537-69eb9e149f86 h1:wFmz3Uuvi+8rV6WoowDv5ZS7YLptlJeEaVFDUBHCea4= +github.com/filecoin-project/storetheindex v0.3.8-0.20220315214537-69eb9e149f86/go.mod h1:9pQ47UgP5J4+PevNEH4dN+JKhNlseUSM340uELPQzNE= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= @@ -363,6 +363,7 @@ github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORR github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f h1:KMlcu9X58lhTA/KrfX8Bi1LQSO4pzoVjTiL3h4Jk+Zk= github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= @@ -635,7 +636,7 @@ github.com/ipld/go-ipld-prime v0.14.4/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704n github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5/go.mod h1:gcvzoEDBjwycpXt3LBE061wT9f46szXGHAmj9uoP6fU= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73 h1:TsyATB2ZRRQGTwafJdgEUQkmjOExRV0DNokcihZxbnQ= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73/go.mod h1:2PJ0JgxyB08t0b2WKrcuqI3di0V+5n6RS/LTUJhkoxY= -github.com/ipld/go-storethehash v0.0.1/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ= +github.com/ipld/go-storethehash v0.0.2/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= @@ -1462,7 +1463,6 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20220224212727-7a699437a831/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14 h1:vo2wkP2ceHyGyZwFFtAabpot03EeSxxwAe57pOI9E/4= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= diff --git a/cmd/provider/find.go b/cmd/provider/find.go index af84ee0e..1068829a 100644 --- a/cmd/provider/find.go +++ b/cmd/provider/find.go @@ -57,8 +57,7 @@ func findCommand(cctx *cli.Context) error { for _, pr := range resp.MultihashResults[i].ProviderResults { fmt.Println(" Provider:", pr.Provider) fmt.Println(" ContextID:", base64.StdEncoding.EncodeToString(pr.ContextID)) - fmt.Println(" Proto:", pr.Metadata.ProtocolID) - fmt.Println(" Metadata:", base64.StdEncoding.EncodeToString(pr.Metadata.Data)) + fmt.Println(" Metadata:", base64.StdEncoding.EncodeToString(pr.Metadata)) } } diff --git a/cmd/provider/index.go b/cmd/provider/index.go index 396b3d8c..fe039895 100644 --- a/cmd/provider/index.go +++ b/cmd/provider/index.go @@ -71,14 +71,7 @@ func indexCommand(cctx *cli.Context) error { return err } - // TODO: Temporary workaround: Once v0.Metadata is stripped off in sti, remove this code and - // simply pass in bytes value of md. - stimd, err := md.ToStiMetadata() - if err != nil { - return err - } - - err = client.IndexContent(cctx.Context, peerID, privKey, mh, []byte(cctx.String("ctxid")), stimd, cctx.StringSlice("addr")) + err = client.IndexContent(cctx.Context, peerID, privKey, mh, []byte(cctx.String("ctxid")), decoded, cctx.StringSlice("addr")) if err != nil { return err } diff --git a/e2e_retrieve_test.go b/e2e_retrieve_test.go index 8d2f67fc..b0fbc4fc 100644 --- a/e2e_retrieve_test.go +++ b/e2e_retrieve_test.go @@ -17,7 +17,6 @@ import ( "github.com/filecoin-project/index-provider/metadata" "github.com/filecoin-project/index-provider/supplier" "github.com/filecoin-project/index-provider/testutil" - stiapi "github.com/filecoin-project/storetheindex/api/v0" "github.com/filecoin-project/storetheindex/api/v0/ingest/schema" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" @@ -208,7 +207,7 @@ func testReimportCarWtihTestCase(t *testing.T, tc testCase) { mdb, err := adv.FieldMetadata().AsBytes() require.NoError(t, err) - var receivedMd stiapi.Metadata + var receivedMd metadata.Metadata err = receivedMd.UnmarshalBinary(mdb) require.NoError(t, err) @@ -242,11 +241,11 @@ func testReimportCarWtihTestCase(t *testing.T, tc testCase) { mdb2, err := adv2.FieldMetadata().AsBytes() require.NoError(t, err) - var receivedMd2 stiapi.Metadata + var receivedMd2 metadata.Metadata err = receivedMd2.UnmarshalBinary(mdb2) require.NoError(t, err) - require.False(t, receivedMd2.Equal(receivedMd)) + require.NotEqual(t, receivedMd2, receivedMd) // Check that both advertisements have the same entries link. lnk, err := adv.FieldEntries().AsLink() diff --git a/engine/engine.go b/engine/engine.go index d0d20eba..0c8b99d0 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -430,14 +430,13 @@ func (e *Engine) publishAdvForIndex(ctx context.Context, contextID []byte, md me previousLnk = nb.Build().(schema.Link_Advertisement) } - //TODO: to be removed after https://github.com/filecoin-project/storetheindex/pull/250 - stimd, err := md.ToStiMetadata() + mdBytes, err := md.MarshalBinary() if err != nil { return cid.Undef, err } adv, err := schema.NewAdvertisement(e.key, previousLnk, cidsLnk, - contextID, stimd, isRm, e.h.ID().String(), e.retrievalAddrsAsString()) + contextID, mdBytes, isRm, e.h.ID().String(), e.retrievalAddrsAsString()) if err != nil { return cid.Undef, fmt.Errorf("failed to create advertisement: %s", err) } diff --git a/engine/engine_test.go b/engine/engine_test.go index edbadfe6..d8eb15c6 100644 --- a/engine/engine_test.go +++ b/engine/engine_test.go @@ -59,14 +59,14 @@ func TestEngine_PublishLocal(t *testing.T) { require.NoError(t, err) md := metadata.New(metadata.Bitswap{}) - stiMetadata, err := md.ToStiMetadata() + mdBytes, err := md.MarshalBinary() require.NoError(t, err) wantAd, err := schema.NewAdvertisement( subject.Key(), nil, chunkLnk, []byte("fish"), - stiMetadata, + mdBytes, false, subject.Host().ID().String(), multiAddsToString(subject.Host().Addrs())) @@ -152,14 +152,14 @@ func TestEngine_PublishWithDataTransferPublisher(t *testing.T) { }) require.NoError(t, err) md := metadata.New(metadata.Bitswap{}) - stiMetadata, err := md.ToStiMetadata() + mdBytes, err := md.MarshalBinary() require.NoError(t, err) wantAd, err := schema.NewAdvertisement( subject.Key(), nil, chunkLnk, wantContextID, - stiMetadata, + mdBytes, false, subject.Host().ID().String(), multiAddsToString(subject.Host().Addrs())) diff --git a/go.mod b/go.mod index fc37ab7e..7d36e58b 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.16 require ( github.com/filecoin-project/go-data-transfer v1.14.0 - github.com/filecoin-project/go-legs v0.3.8 + github.com/filecoin-project/go-legs v0.3.9 github.com/filecoin-project/go-state-types v0.1.0 - github.com/filecoin-project/storetheindex v0.3.5 + github.com/filecoin-project/storetheindex v0.3.8-0.20220315214537-69eb9e149f86 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/golang/mock v1.6.0 github.com/gorilla/mux v1.7.4 diff --git a/go.sum b/go.sum index 0653aba0..09eea897 100644 --- a/go.sum +++ b/go.sum @@ -199,6 +199,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5/go.mod h1:JpoxHjuQauoxiFMl1ie8Xc/7TfLuMZ5eOCONd1sUBHg= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= github.com/filecoin-project/go-address v0.0.5 h1:SSaFT/5aLfPXycUlFyemoHYhRgdyXClXCyDdNJKPlDM= github.com/filecoin-project/go-address v0.0.5/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= @@ -212,10 +213,9 @@ github.com/filecoin-project/go-data-transfer v1.14.0/go.mod h1:wNJKhaLLYBJDM3VFv github.com/filecoin-project/go-ds-versioning v0.0.0-20211206185234-508abd7c2aff/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= github.com/filecoin-project/go-ds-versioning v0.1.1 h1:JiyBqaQlwC+UM0WhcBtVEeT3XrX59mQhT8U3p7nu86o= github.com/filecoin-project/go-ds-versioning v0.1.1/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= -github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY= -github.com/filecoin-project/go-legs v0.3.7/go.mod h1:pgekGm8/gKY5zCtQ/qGAoSjGP92wTLFqpO3GPHeu8YU= -github.com/filecoin-project/go-legs v0.3.8 h1:HDhunjC+E5g3s47zUQY/YnDveatOXWJyfK519jdKhOA= -github.com/filecoin-project/go-legs v0.3.8/go.mod h1:FroH5LQUTfYzs8huA4PjW8spDF691uvK8uk9YAfDa78= +github.com/filecoin-project/go-indexer-core v0.2.9/go.mod h1:u03I3HB6ZnqCc3cm8Tq+QkTWBbfKOvNxM8K6Ny/IHRw= +github.com/filecoin-project/go-legs v0.3.9 h1:YDW+nHn3fdl/5M7dE0EOxU8E3EgJGjuccLcz9xaT3kg= +github.com/filecoin-project/go-legs v0.3.9/go.mod h1:FroH5LQUTfYzs8huA4PjW8spDF691uvK8uk9YAfDa78= github.com/filecoin-project/go-state-types v0.1.0 h1:9r2HCSMMCmyMfGyMKxQtv0GKp6VT/m5GgVk8EhYbLJU= github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe h1:dF8u+LEWeIcTcfUcCf3WFVlc81Fr2JKg8zPzIbBDKDw= @@ -223,8 +223,8 @@ github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/g github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNdofHZoGPjfNaAo5Q= github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= -github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q= -github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI= +github.com/filecoin-project/storetheindex v0.3.8-0.20220315214537-69eb9e149f86 h1:wFmz3Uuvi+8rV6WoowDv5ZS7YLptlJeEaVFDUBHCea4= +github.com/filecoin-project/storetheindex v0.3.8-0.20220315214537-69eb9e149f86/go.mod h1:9pQ47UgP5J4+PevNEH4dN+JKhNlseUSM340uELPQzNE= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= @@ -362,6 +362,7 @@ github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORR github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f h1:KMlcu9X58lhTA/KrfX8Bi1LQSO4pzoVjTiL3h4Jk+Zk= github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= @@ -628,7 +629,7 @@ github.com/ipld/go-ipld-prime v0.14.4/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704n github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5/go.mod h1:gcvzoEDBjwycpXt3LBE061wT9f46szXGHAmj9uoP6fU= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73 h1:TsyATB2ZRRQGTwafJdgEUQkmjOExRV0DNokcihZxbnQ= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73/go.mod h1:2PJ0JgxyB08t0b2WKrcuqI3di0V+5n6RS/LTUJhkoxY= -github.com/ipld/go-storethehash v0.0.1/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ= +github.com/ipld/go-storethehash v0.0.2/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= @@ -1447,7 +1448,6 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20220224212727-7a699437a831/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14 h1:vo2wkP2ceHyGyZwFFtAabpot03EeSxxwAe57pOI9E/4= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= diff --git a/metadata/graphsync_filecoinv1_test.go b/metadata/graphsync_filecoinv1_test.go index 505abe39..a772adae 100644 --- a/metadata/graphsync_filecoinv1_test.go +++ b/metadata/graphsync_filecoinv1_test.go @@ -5,7 +5,6 @@ import ( "github.com/filecoin-project/index-provider/metadata" "github.com/filecoin-project/index-provider/testutil" - stiapi "github.com/filecoin-project/storetheindex/api/v0" "github.com/multiformats/go-multicodec" "github.com/multiformats/go-varint" "github.com/stretchr/testify/require" @@ -45,24 +44,11 @@ func TestRoundTripDataTransferFilecoin(t *testing.T) { err = dst.UnmarshalBinary(asBytes) require.NoError(t, err) require.Equal(t, src, dst) - - //TODO: remove this once sti.metadata is removed; for now add tests to assert backwards - // compatibility. - var stimd stiapi.Metadata - err = stimd.UnmarshalBinary(asBytes) - require.NoError(t, err) - require.Equal(t, multicodec.TransportGraphsyncFilecoinv1, stimd.ProtocolID) - require.Equal(t, asBytes[varint.UvarintSize(uint64(multicodec.TransportGraphsyncFilecoinv1)):], stimd.Data) } } func TestGraphsyncFilecoinV1Metadata_FromIndexerMetadataErr(t *testing.T) { - imd := stiapi.Metadata{ - ProtocolID: multicodec.TransportBitswap, - } dst := &metadata.GraphsyncFilecoinV1{} - bytes, err := imd.MarshalBinary() - require.NoError(t, err) - err = dst.UnmarshalBinary(bytes) + err := dst.UnmarshalBinary(varint.ToUvarint(uint64(multicodec.TransportBitswap))) require.Errorf(t, err, "invalid transport ID: transport-bitswap") } diff --git a/metadata/hack.go b/metadata/hack.go deleted file mode 100644 index 8c9bb988..00000000 --- a/metadata/hack.go +++ /dev/null @@ -1,24 +0,0 @@ -package metadata - -import ( - v0 "github.com/filecoin-project/storetheindex/api/v0" - "github.com/multiformats/go-varint" -) - -// ToStiMetadata is a hack to make code compile until this is merged: -// https://github.com/filecoin-project/storetheindex/pull/250 -func (m *Metadata) ToStiMetadata() (v0.Metadata, error) { - //TODO: pass in marshalled bytes once this is merged: - // https://github.com/filecoin-project/storetheindex/pull/250 - // For now, pick the first transport from metadata - - tp := m.protocols[0] - binary, err := tp.MarshalBinary() - if err != nil { - return v0.Metadata{}, err - } - return v0.Metadata{ - ProtocolID: tp.ID(), - Data: binary[varint.UvarintSize(uint64(tp.ID())):], - }, nil -}