Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
chore: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Jul 6, 2023
1 parent fd6e343 commit db60039
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 261 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require (
go.opentelemetry.io/otel/sdk v1.14.0
go.opentelemetry.io/otel/trace v1.14.0
go.uber.org/atomic v1.10.0
go.uber.org/multierr v1.9.0
go.uber.org/zap v1.24.0
)

Expand Down Expand Up @@ -167,6 +166,7 @@ require (
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/dig v1.15.0 // indirect
go.uber.org/fx v1.18.2 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect
golang.org/x/mod v0.7.0 // indirect
Expand Down
194 changes: 0 additions & 194 deletions lib/block_fetchers.go

This file was deleted.

66 changes: 0 additions & 66 deletions lib/graph_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"
golog "github.com/ipfs/go-log/v2"
"github.com/ipfs/go-unixfsnode"
ufsData "github.com/ipfs/go-unixfsnode/data"
dagpb "github.com/ipld/go-codec-dagpb"
Expand All @@ -49,8 +48,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

var graphLog = golog.Logger("backend/graph")

const GetBlockTimeout = time.Second * 60

// type DataCallback = func(resource string, reader io.Reader) error
Expand Down Expand Up @@ -94,18 +91,6 @@ func WithBlockstore(bs blockstore.Blockstore) GraphGatewayOption {

type GraphGatewayOption func(gwOptions *gwOptions) error

type Notifier interface {
NotifyNewBlocks(ctx context.Context, blocks ...blocks.Block) error
}

// notifiersForRootCid is used for reducing lock contention by only notifying
// exchanges related to the same content root CID
type notifiersForRootCid struct {
lk sync.RWMutex
deleted int8
notifiers []Notifier
}

type GraphGateway struct {
fetcher CarFetcher
blockFetcher exchange.Fetcher
Expand Down Expand Up @@ -272,57 +257,6 @@ func registerGraphGatewayMetrics() *GraphGatewayMetrics {
}
}

func (api *GraphGateway) getRootOfPath(path string) string {
pth, err := ipfspath.ParsePath(path)
if err != nil {
return path
}
if pth.IsJustAKey() {
return pth.Segments()[0]
} else {
return pth.Segments()[1]
}
}

type fileCloseWrapper struct {
files.File
closeFn func()
}

func (w *fileCloseWrapper) Close() error {
w.closeFn()
return w.File.Close()
}

type dirCloseWrapper struct {
files.Directory
closeFn func()
}

func (w *dirCloseWrapper) Close() error {
w.closeFn()
return w.Directory.Close()
}

func wrapNodeWithClose[T files.Node](node T, closeFn func()) (T, error) {
var genericNode files.Node = node
switch n := genericNode.(type) {
case *files.Symlink:
closeFn()
return node, nil
case files.File:
var f files.File = &fileCloseWrapper{n, closeFn}
return f.(T), nil
case files.Directory:
var d files.Directory = &dirCloseWrapper{n, closeFn}
return d.(T), nil
default:
closeFn()
var zeroType T
return zeroType, fmt.Errorf("unsupported node type")
}
}

func (api *GraphGateway) fetchCAR(ctx context.Context, path gateway.ImmutablePath, params gateway.CarParams, cb DataCallback) error {
escapedPath := url.PathEscape(path.String()[1:])
paramsBuilder := strings.Builder{}
Expand Down

0 comments on commit db60039

Please sign in to comment.