Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Commit 5a83651

Browse files
committed
path: WIP
1 parent 33d445a commit 5a83651

File tree

16 files changed

+287
-273
lines changed

16 files changed

+287
-273
lines changed

block.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package iface
22

33
import (
44
"context"
5+
path "github.com/ipfs/interface-go-ipfs-core/path"
56
"io"
67

7-
options "github.com/ipfs/interface-go-ipfs-core/options"
8+
"github.com/ipfs/interface-go-ipfs-core/options"
89
)
910

1011
// BlockStat contains information about a block
@@ -13,7 +14,7 @@ type BlockStat interface {
1314
Size() int
1415

1516
// Path returns path to the block
16-
Path() ResolvedPath
17+
Path() path.ResolvedPath
1718
}
1819

1920
// BlockAPI specifies the interface to the block layer
@@ -22,15 +23,15 @@ type BlockAPI interface {
2223
Put(context.Context, io.Reader, ...options.BlockPutOption) (BlockStat, error)
2324

2425
// Get attempts to resolve the path and return a reader for data in the block
25-
Get(context.Context, Path) (io.Reader, error)
26+
Get(context.Context, path.Path) (io.Reader, error)
2627

2728
// Rm removes the block specified by the path from local blockstore.
2829
// By default an error will be returned if the block can't be found locally.
2930
//
3031
// NOTE: If the specified block is pinned it won't be removed and no error
3132
// will be returned
32-
Rm(context.Context, Path, ...options.BlockRmOption) error
33+
Rm(context.Context, path.Path, ...options.BlockRmOption) error
3334

3435
// Stat returns information on
35-
Stat(context.Context, Path) (BlockStat, error)
36+
Stat(context.Context, path.Path) (BlockStat, error)
3637
}

coreapi.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package iface
44

55
import (
66
"context"
7+
path "github.com/ipfs/interface-go-ipfs-core/path"
78

89
"github.com/ipfs/interface-go-ipfs-core/options"
910

@@ -43,11 +44,11 @@ type CoreAPI interface {
4344
PubSub() PubSubAPI
4445

4546
// ResolvePath resolves the path using Unixfs resolver
46-
ResolvePath(context.Context, Path) (ResolvedPath, error)
47+
ResolvePath(context.Context, path.Path) (path.ResolvedPath, error)
4748

4849
// ResolveNode resolves the path (if not resolved already) using Unixfs
4950
// resolver, gets and returns the resolved Node
50-
ResolveNode(context.Context, Path) (ipld.Node, error)
51+
ResolveNode(context.Context, path.Path) (ipld.Node, error)
5152

5253
// WithOptions creates new instance of CoreAPI based on this instance with
5354
// a set of options applied

dht.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package iface
22

33
import (
44
"context"
5+
path "github.com/ipfs/interface-go-ipfs-core/path"
56

67
"github.com/ipfs/interface-go-ipfs-core/options"
78

8-
peer "github.com/libp2p/go-libp2p-peer"
9+
"github.com/libp2p/go-libp2p-peer"
910
pstore "github.com/libp2p/go-libp2p-peerstore"
1011
)
1112

@@ -19,8 +20,8 @@ type DhtAPI interface {
1920

2021
// FindProviders finds peers in the DHT who can provide a specific value
2122
// given a key.
22-
FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
23+
FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
2324

2425
// Provide announces to the network that you are providing given values
25-
Provide(context.Context, Path, ...options.DhtProvideOption) error
26+
Provide(context.Context, path.Path, ...options.DhtProvideOption) error
2627
}

key.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package iface
22

33
import (
44
"context"
5+
path "github.com/ipfs/interface-go-ipfs-core/path"
56

6-
options "github.com/ipfs/interface-go-ipfs-core/options"
7+
"github.com/ipfs/interface-go-ipfs-core/options"
78

89
"github.com/libp2p/go-libp2p-peer"
910
)
@@ -14,7 +15,7 @@ type Key interface {
1415
Name() string
1516

1617
// Path returns key path
17-
Path() Path
18+
Path() path.Path
1819

1920
// ID returns key PeerID
2021
ID() peer.ID

name.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package iface
33
import (
44
"context"
55
"errors"
6+
path "github.com/ipfs/interface-go-ipfs-core/path"
67

7-
options "github.com/ipfs/interface-go-ipfs-core/options"
8+
"github.com/ipfs/interface-go-ipfs-core/options"
89
)
910

1011
var ErrResolveFailed = errors.New("could not resolve name")
@@ -14,11 +15,11 @@ type IpnsEntry interface {
1415
// Name returns IpnsEntry name
1516
Name() string
1617
// Value returns IpnsEntry value
17-
Value() Path
18+
Value() path.Path
1819
}
1920

2021
type IpnsResult struct {
21-
Path
22+
path.Path
2223
Err error
2324
}
2425

@@ -32,10 +33,10 @@ type IpnsResult struct {
3233
// You can use .Key API to list and generate more names and their respective keys.
3334
type NameAPI interface {
3435
// Publish announces new IPNS name
35-
Publish(ctx context.Context, path Path, opts ...options.NamePublishOption) (IpnsEntry, error)
36+
Publish(ctx context.Context, path path.Path, opts ...options.NamePublishOption) (IpnsEntry, error)
3637

3738
// Resolve attempts to resolve the newest version of the specified name
38-
Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (Path, error)
39+
Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (path.Path, error)
3940

4041
// Search is a version of Resolve which outputs paths as they are discovered,
4142
// reducing the time to first entry

object.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package iface
22

33
import (
44
"context"
5+
path "github.com/ipfs/interface-go-ipfs-core/path"
56
"io"
67

7-
options "github.com/ipfs/interface-go-ipfs-core/options"
8+
"github.com/ipfs/interface-go-ipfs-core/options"
89

9-
cid "github.com/ipfs/go-cid"
10+
"github.com/ipfs/go-cid"
1011
ipld "github.com/ipfs/go-ipld-format"
1112
)
1213

@@ -58,11 +59,11 @@ type ObjectChange struct {
5859

5960
// Before holds the link path before the change. Note that when a link is
6061
// added, this will be nil.
61-
Before ResolvedPath
62+
Before path.ResolvedPath
6263

6364
// After holds the link path after the change. Note that when a link is
6465
// removed, this will be nil.
65-
After ResolvedPath
66+
After path.ResolvedPath
6667
}
6768

6869
// ObjectAPI specifies the interface to MerkleDAG and contains useful utilities
@@ -72,35 +73,35 @@ type ObjectAPI interface {
7273
New(context.Context, ...options.ObjectNewOption) (ipld.Node, error)
7374

7475
// Put imports the data into merkledag
75-
Put(context.Context, io.Reader, ...options.ObjectPutOption) (ResolvedPath, error)
76+
Put(context.Context, io.Reader, ...options.ObjectPutOption) (path.ResolvedPath, error)
7677

7778
// Get returns the node for the path
78-
Get(context.Context, Path) (ipld.Node, error)
79+
Get(context.Context, path.Path) (ipld.Node, error)
7980

8081
// Data returns reader for data of the node
81-
Data(context.Context, Path) (io.Reader, error)
82+
Data(context.Context, path.Path) (io.Reader, error)
8283

8384
// Links returns lint or links the node contains
84-
Links(context.Context, Path) ([]*ipld.Link, error)
85+
Links(context.Context, path.Path) ([]*ipld.Link, error)
8586

8687
// Stat returns information about the node
87-
Stat(context.Context, Path) (*ObjectStat, error)
88+
Stat(context.Context, path.Path) (*ObjectStat, error)
8889

8990
// AddLink adds a link under the specified path. child path can point to a
9091
// subdirectory within the patent which must be present (can be overridden
9192
// with WithCreate option).
92-
AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (ResolvedPath, error)
93+
AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...options.ObjectAddLinkOption) (path.ResolvedPath, error)
9394

9495
// RmLink removes a link from the node
95-
RmLink(ctx context.Context, base Path, link string) (ResolvedPath, error)
96+
RmLink(ctx context.Context, base path.Path, link string) (path.ResolvedPath, error)
9697

9798
// AppendData appends data to the node
98-
AppendData(context.Context, Path, io.Reader) (ResolvedPath, error)
99+
AppendData(context.Context, path.Path, io.Reader) (path.ResolvedPath, error)
99100

100101
// SetData sets the data contained in the node
101-
SetData(context.Context, Path, io.Reader) (ResolvedPath, error)
102+
SetData(context.Context, path.Path, io.Reader) (path.ResolvedPath, error)
102103

103104
// Diff returns a set of changes needed to transform the first object into the
104105
// second.
105-
Diff(context.Context, Path, Path) ([]ObjectChange, error)
106+
Diff(context.Context, path.Path, path.Path) ([]ObjectChange, error)
106107
}

0 commit comments

Comments
 (0)