Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split cmd/ into a separate module #93

Merged
merged 1 commit into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,9 +17,9 @@ import (
"github.com/multiformats/go-multicodec"
"github.com/multiformats/go-multihash"

"github.com/filecoin-project/indexer-reference-provider/internal/cardatatransfer/stores"
"github.com/filecoin-project/indexer-reference-provider/internal/suppliers"
"github.com/filecoin-project/indexer-reference-provider/metadata"
"github.com/filecoin-project/index-provider/cardatatransfer/stores"
"github.com/filecoin-project/index-provider/metadata"
"github.com/filecoin-project/index-provider/supplier"
)

var log = logging.Logger("car-data-transfer")
Expand All @@ -33,7 +33,7 @@ func init() {
}

type BlockStoreSupplier interface {
ReadOnlyBlockstore(contextID []byte) (suppliers.ClosableBlockstore, error)
ReadOnlyBlockstore(contextID []byte) (supplier.ClosableBlockstore, error)
}

type carDataTransfer struct {
Expand Down
Expand Up @@ -30,10 +30,10 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"

datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/indexer-reference-provider/internal/cardatatransfer"
"github.com/filecoin-project/indexer-reference-provider/internal/suppliers"
"github.com/filecoin-project/indexer-reference-provider/metadata"
"github.com/filecoin-project/indexer-reference-provider/testutil"
"github.com/filecoin-project/index-provider/cardatatransfer"
"github.com/filecoin-project/index-provider/metadata"
"github.com/filecoin-project/index-provider/supplier"
"github.com/filecoin-project/index-provider/testutil"
)

func TestCarDataTransfer(t *testing.T) {
Expand All @@ -54,7 +54,7 @@ func TestCarDataTransfer(t *testing.T) {
missingCid := testutil.GenerateCids(1)[0]
missingContextID := []byte("notFound")

supplier := &fakeSupplier{blockstores: make(map[string]suppliers.ClosableBlockstore)}
supplier := &fakeSupplier{blockstores: make(map[string]supplier.ClosableBlockstore)}
supplier.blockstores[string(contextID1)] = rdOnlyBS1
supplier.blockstores[string(contextID2)] = rdOnlyBS2

Expand Down Expand Up @@ -219,10 +219,10 @@ func TestCarDataTransfer(t *testing.T) {
}

type fakeSupplier struct {
blockstores map[string]suppliers.ClosableBlockstore
blockstores map[string]supplier.ClosableBlockstore
}

func (fs *fakeSupplier) ReadOnlyBlockstore(contextID []byte) (suppliers.ClosableBlockstore, error) {
func (fs *fakeSupplier) ReadOnlyBlockstore(contextID []byte) (supplier.ClosableBlockstore, error) {
bs, ok := fs.blockstores[string(contextID)]
if !ok {
return nil, errors.New("Not found!")
Expand Down
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/filecoin-project/indexer-reference-provider/internal/cardatatransfer/stores"
"github.com/filecoin-project/indexer-reference-provider/testutil"
"github.com/filecoin-project/index-provider/cardatatransfer/stores"
"github.com/filecoin-project/index-provider/testutil"
)

func TestReadOnlyStoreTracker(t *testing.T) {
Expand Down
24 changes: 24 additions & 0 deletions cmd/go.mod
@@ -0,0 +1,24 @@
module github.com/filecoin-project/index-provider/cmd

go 1.16

require (
github.com/filecoin-project/go-data-transfer v1.11.4
github.com/filecoin-project/index-provider v0.0.0-20211115210313-7957526f5b07
github.com/filecoin-project/storetheindex v0.0.0-20211019180831-2704585e5f99
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-ds-leveldb v0.4.2
github.com/ipfs/go-graphsync v0.10.4
github.com/ipfs/go-ipfs v0.10.0
github.com/ipfs/go-log/v2 v2.3.0
github.com/ipld/go-car/v2 v2.0.3-0.20210920144420-f35d88ce16ca
github.com/ipld/go-ipld-prime v0.14.0
github.com/libp2p/go-libp2p v0.15.0
github.com/mitchellh/go-homedir v1.1.0
github.com/multiformats/go-multiaddr v0.4.1
github.com/multiformats/go-multicodec v0.3.1-0.20210902112759-1539a079fd61
github.com/multiformats/go-multihash v0.1.0
github.com/rogpeppe/go-internal v1.8.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
)
1,923 changes: 1,923 additions & 0 deletions cmd/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/provider/connect.go
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/http"

adminserver "github.com/filecoin-project/indexer-reference-provider/server/admin/http"
adminserver "github.com/filecoin-project/index-provider/server/admin/http"
"github.com/urfave/cli/v2"
)

Expand Down
14 changes: 7 additions & 7 deletions cmd/provider/daemon.go
Expand Up @@ -11,12 +11,12 @@ import (
datatransfer "github.com/filecoin-project/go-data-transfer/impl"
dtnetwork "github.com/filecoin-project/go-data-transfer/network"
gstransport "github.com/filecoin-project/go-data-transfer/transport/graphsync"
"github.com/filecoin-project/indexer-reference-provider/config"
"github.com/filecoin-project/indexer-reference-provider/engine"
"github.com/filecoin-project/indexer-reference-provider/internal/cardatatransfer"
"github.com/filecoin-project/indexer-reference-provider/internal/suppliers"
adminserver "github.com/filecoin-project/indexer-reference-provider/server/admin/http"
p2pserver "github.com/filecoin-project/indexer-reference-provider/server/provider/libp2p"
"github.com/filecoin-project/index-provider/cardatatransfer"
"github.com/filecoin-project/index-provider/config"
"github.com/filecoin-project/index-provider/engine"
adminserver "github.com/filecoin-project/index-provider/server/admin/http"
p2pserver "github.com/filecoin-project/index-provider/server/provider/libp2p"
"github.com/filecoin-project/index-provider/supplier"
leveldb "github.com/ipfs/go-ds-leveldb"
gsimpl "github.com/ipfs/go-graphsync/impl"
gsnet "github.com/ipfs/go-graphsync/network"
Expand Down Expand Up @@ -133,7 +133,7 @@ func daemonCommand(cctx *cli.Context) error {
}

// Instantiate CAR supplier and register it as a callback onto the engine.
cs := suppliers.NewCarSupplier(eng, ds, car.ZeroLengthSectionAsEOF(carZeroLengthAsEOFFlagValue))
cs := supplier.NewCarSupplier(eng, ds, car.ZeroLengthSectionAsEOF(carZeroLengthAsEOFFlagValue))

// Start serving CAR files for retrieval requests
err = cardatatransfer.StartCarDataTransfer(dt, cs)
Expand Down
4 changes: 2 additions & 2 deletions cmd/provider/import.go
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"net/http"

"github.com/filecoin-project/indexer-reference-provider/internal/cardatatransfer"
adminserver "github.com/filecoin-project/indexer-reference-provider/server/admin/http"
"github.com/filecoin-project/index-provider/cardatatransfer"
adminserver "github.com/filecoin-project/index-provider/server/admin/http"
stiapi "github.com/filecoin-project/storetheindex/api/v0"
"github.com/urfave/cli/v2"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/index.go
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/filecoin-project/indexer-reference-provider/config"
"github.com/filecoin-project/index-provider/config"
stiapi "github.com/filecoin-project/storetheindex/api/v0"
httpc "github.com/filecoin-project/storetheindex/api/v0/ingest/client/http"
"github.com/ipfs/go-cid"
Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/init.go
@@ -1,7 +1,7 @@
package main

import (
"github.com/filecoin-project/indexer-reference-provider/config"
"github.com/filecoin-project/index-provider/config"
"github.com/urfave/cli/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/provider.go
Expand Up @@ -7,7 +7,7 @@ import (
"os/signal"
"syscall"

"github.com/filecoin-project/indexer-reference-provider/internal/version"
"github.com/filecoin-project/index-provider/version"
"github.com/urfave/cli/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/register.go
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/filecoin-project/indexer-reference-provider/config"
"github.com/filecoin-project/index-provider/config"
httpc "github.com/filecoin-project/storetheindex/api/v0/ingest/client/http"
"github.com/urfave/cli/v2"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/remove.go
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"net/http"

adminserver "github.com/filecoin-project/indexer-reference-provider/server/admin/http"
adminserver "github.com/filecoin-project/index-provider/server/admin/http"
"github.com/urfave/cli/v2"
)

Expand Down
22 changes: 11 additions & 11 deletions e2e_retrieve_test.go
Expand Up @@ -7,15 +7,15 @@ import (
"time"

datatransfer "github.com/filecoin-project/go-data-transfer"
provider "github.com/filecoin-project/indexer-reference-provider"
"github.com/filecoin-project/indexer-reference-provider/config"
"github.com/filecoin-project/indexer-reference-provider/engine"
"github.com/filecoin-project/indexer-reference-provider/internal/cardatatransfer"
"github.com/filecoin-project/indexer-reference-provider/internal/libp2pserver"
"github.com/filecoin-project/indexer-reference-provider/internal/suppliers"
"github.com/filecoin-project/indexer-reference-provider/metadata"
p2pserver "github.com/filecoin-project/indexer-reference-provider/server/provider/libp2p"
"github.com/filecoin-project/indexer-reference-provider/testutil"
provider "github.com/filecoin-project/index-provider"
"github.com/filecoin-project/index-provider/cardatatransfer"
"github.com/filecoin-project/index-provider/config"
"github.com/filecoin-project/index-provider/engine"
"github.com/filecoin-project/index-provider/libp2pserver"
"github.com/filecoin-project/index-provider/metadata"
p2pserver "github.com/filecoin-project/index-provider/server/provider/libp2p"
"github.com/filecoin-project/index-provider/supplier"
"github.com/filecoin-project/index-provider/testutil"
stiapi "github.com/filecoin-project/storetheindex/api/v0"
p2pclient "github.com/filecoin-project/storetheindex/providerclient/libp2p"
"github.com/ipfs/go-datastore"
Expand All @@ -33,7 +33,7 @@ import (
"github.com/stretchr/testify/require"
)

func setupServer(ctx context.Context, t *testing.T) (*libp2pserver.Server, host.Host, *suppliers.CarSupplier, *engine.Engine) {
func setupServer(ctx context.Context, t *testing.T) (*libp2pserver.Server, host.Host, *supplier.CarSupplier, *engine.Engine) {
h, err := libp2p.New(ctx, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
require.NoError(t, err)
priv, _, err := test.RandTestKeyPair(crypto.Ed25519, 256)
Expand All @@ -48,7 +48,7 @@ func setupServer(ctx context.Context, t *testing.T) (*libp2pserver.Server, host.
require.NoError(t, err)
err = e.Start(ctx)
require.NoError(t, err)
cs := suppliers.NewCarSupplier(e, store, car.ZeroLengthSectionAsEOF(false))
cs := supplier.NewCarSupplier(e, store, car.ZeroLengthSectionAsEOF(false))
err = cardatatransfer.StartCarDataTransfer(dt, cs)
require.NoError(t, err)
s := p2pserver.New(ctx, h, e)
Expand Down
4 changes: 2 additions & 2 deletions engine/engine.go
Expand Up @@ -8,8 +8,8 @@ import (

dt "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-legs"
provider "github.com/filecoin-project/indexer-reference-provider"
"github.com/filecoin-project/indexer-reference-provider/config"
provider "github.com/filecoin-project/index-provider"
"github.com/filecoin-project/index-provider/config"
stiapi "github.com/filecoin-project/storetheindex/api/v0"
"github.com/filecoin-project/storetheindex/api/v0/ingest/schema"
"github.com/ipfs/go-cid"
Expand Down
10 changes: 5 additions & 5 deletions engine/engine_test.go
Expand Up @@ -8,13 +8,13 @@ import (
"testing"
"time"

provider "github.com/filecoin-project/indexer-reference-provider"
provider "github.com/filecoin-project/index-provider"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/go-legs"
"github.com/filecoin-project/indexer-reference-provider/config"
"github.com/filecoin-project/indexer-reference-provider/internal/utils"
"github.com/filecoin-project/indexer-reference-provider/testutil"
"github.com/filecoin-project/index-provider/config"
"github.com/filecoin-project/index-provider/testutil"
"github.com/filecoin-project/index-provider/utils"
stiapi "github.com/filecoin-project/storetheindex/api/v0"
"github.com/filecoin-project/storetheindex/api/v0/ingest/schema"
"github.com/ipfs/go-datastore"
Expand Down Expand Up @@ -408,6 +408,6 @@ func clean(ls legs.LegSubscriber, e *Engine, cncl context.CancelFunc) func() {

func skipFlaky(t *testing.T) {
if os.Getenv("DONT_SKIP") == "" {
t.Skip("skipping test since it is flaky on the CI. See https://github.com/filecoin-project/indexer-reference-provider/issues/12")
t.Skip("skipping test since it is flaky on the CI. See https://github.com/filecoin-project/index-provider/issues/12")
}
}
2 changes: 1 addition & 1 deletion engine/linksystem.go
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"io"

"github.com/filecoin-project/indexer-reference-provider"
"github.com/filecoin-project/index-provider"
"github.com/filecoin-project/storetheindex/api/v0/ingest/schema"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
Expand Down
11 changes: 7 additions & 4 deletions go.mod
@@ -1,4 +1,4 @@
module github.com/filecoin-project/indexer-reference-provider
module github.com/filecoin-project/index-provider

go 1.16

Expand All @@ -11,27 +11,30 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
github.com/golang/mock v1.6.0
github.com/gorilla/mux v1.7.4
github.com/ipfs/go-bitswap v0.4.0 // indirect
mvdan marked this conversation as resolved.
Show resolved Hide resolved
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-datastore v0.4.6
github.com/ipfs/go-ds-leveldb v0.4.2
github.com/ipfs/go-graphsync v0.10.4
github.com/ipfs/go-ipfs v0.10.0
github.com/ipfs/go-ipfs-blockstore v1.0.4
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-log/v2 v2.3.0
github.com/ipfs/go-merkledag v0.4.0 // indirect
github.com/ipld/go-car/v2 v2.0.3-0.20210920144420-f35d88ce16ca
github.com/ipld/go-codec-dagpb v1.3.0
github.com/ipld/go-ipld-prime v0.14.0
github.com/libp2p/go-libp2p v0.15.0
github.com/libp2p/go-libp2p-core v0.9.0
github.com/libp2p/go-libp2p-quic-transport v0.12.0 // indirect
github.com/libp2p/go-libp2p-record v0.1.3 // indirect
github.com/libp2p/go-msgio v0.0.6
github.com/mitchellh/go-homedir v1.1.0
github.com/multiformats/go-multiaddr v0.4.1
github.com/multiformats/go-multicodec v0.3.1-0.20210902112759-1539a079fd61
github.com/multiformats/go-multihash v0.1.0
github.com/rogpeppe/go-internal v1.8.0
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
github.com/whyrusleeping/cbor-gen v0.0.0-20210713220151-be142a5ae1a8
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
)