Skip to content

Commit ca629a8

Browse files
committed
refactor: new boxo/namesys
This applies changes necessary after ipfs/boxo#459 we need this to unblock ipfs/kubo#10161
1 parent 3b5bfd3 commit ca629a8

File tree

6 files changed

+23
-34
lines changed

6 files changed

+23
-34
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/fsnotify/fsnotify v1.6.0
7-
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3
7+
github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9
88
github.com/ipfs/go-cid v0.4.1
99
github.com/ipfs/go-log/v2 v2.5.1
1010
github.com/multiformats/go-multicodec v0.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
77
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
8-
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 h1:sgrhALL6mBoZsNvJ2zUcITcN6IW3y14ej6w7gv5RcOI=
9-
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
8+
github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ=
9+
github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
1010
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
1111
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
1212
github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=

ipfs/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941
7-
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3
7+
github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9
88
github.com/ipfs/go-block-format v0.1.2
99
github.com/ipfs/go-cid v0.4.1
1010
github.com/ipfs/go-log/v2 v2.5.1

ipfs/go.sum

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,12 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG
8686
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
8787
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
8888
github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY=
89-
github.com/ipfs-shipyard/nopfs v0.0.11 h1:+JrOqVs4Za0eu4jntdAqxoWolWcmtJnTQXxn2Y/Io2E=
90-
github.com/ipfs-shipyard/nopfs v0.0.11/go.mod h1:zCmxRNQBYwTRYemK6zcKBGLKN9DkDJYNzmNMqw9GtIA=
9189
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941 h1:IkOu07ym9Pi+O5Xl50CpMjvqULLFatzNY3+dyI54swM=
9290
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941/go.mod h1:kuVnRVtaUO33/H05F/TH0pia1Pr/VW3DrFRGZGP4bpg=
9391
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
9492
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
95-
github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI=
96-
github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
97-
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 h1:sgrhALL6mBoZsNvJ2zUcITcN6IW3y14ej6w7gv5RcOI=
98-
github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
93+
github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ=
94+
github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
9995
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
10096
github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo=
10197
github.com/ipfs/go-block-format v0.1.2/go.mod h1:mACVcrxarQKstUU3Yf/RdwbC4DzPV6++rO2a3d+a/KE=

ipfs/namesys.go

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/ipfs-shipyard/nopfs"
7-
opts "github.com/ipfs/boxo/coreiface/options/namesys"
87
"github.com/ipfs/boxo/namesys"
98
"github.com/ipfs/boxo/path"
109
crypto "github.com/libp2p/go-libp2p/core/crypto"
@@ -29,46 +28,32 @@ func WrapNameSystem(ns namesys.NameSystem, blocker *nopfs.Blocker) namesys.NameS
2928
}
3029

3130
// Resolve resolves an IPNS name unless it is blocked.
32-
func (ns *NameSystem) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error) {
33-
p, err := path.NewPath(name)
34-
if err != nil {
35-
return nil, err
36-
}
31+
func (ns *NameSystem) Resolve(ctx context.Context, p path.Path, options ...namesys.ResolveOption) (namesys.Result, error) {
3732
if err := ns.blocker.IsPathBlocked(p).ToError(); err != nil {
3833
logger.Warn(err.Response)
39-
return nil, err
34+
return namesys.Result{}, err
4035
}
41-
return ns.ns.Resolve(ctx, name, options...)
36+
return ns.ns.Resolve(ctx, p, options...)
4237
}
4338

4439
// ResolveAsync resolves an IPNS name asynchronously unless it is blocked.
45-
func (ns *NameSystem) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan namesys.Result {
46-
p, err := path.NewPath(name)
47-
if err != nil {
48-
ch := make(chan namesys.Result, 1)
49-
ch <- namesys.Result{
50-
Path: nil,
51-
Err: err,
52-
}
53-
close(ch)
54-
return ch
55-
}
40+
func (ns *NameSystem) ResolveAsync(ctx context.Context, p path.Path, options ...namesys.ResolveOption) <-chan namesys.AsyncResult {
5641
status := ns.blocker.IsPathBlocked(p)
5742
if err := status.ToError(); err != nil {
5843
logger.Warn(err.Response)
59-
ch := make(chan namesys.Result, 1)
60-
ch <- namesys.Result{
44+
ch := make(chan namesys.AsyncResult, 1)
45+
ch <- namesys.AsyncResult{
6146
Path: status.Path,
6247
Err: err,
6348
}
6449
close(ch)
6550
return ch
6651
}
6752

68-
return ns.ns.ResolveAsync(ctx, name, options...)
53+
return ns.ns.ResolveAsync(ctx, p, options...)
6954
}
7055

7156
// Publish publishes an IPNS record.
72-
func (ns *NameSystem) Publish(ctx context.Context, name crypto.PrivKey, value path.Path, options ...opts.PublishOption) error {
57+
func (ns *NameSystem) Publish(ctx context.Context, name crypto.PrivKey, value path.Path, options ...namesys.PublishOption) error {
7358
return ns.ns.Publish(ctx, name, value, options...)
7459
}

nopfs-kubo-plugin/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# nopfs-kubo-plugin
1+
# nopfs-kubo-plugin (for Kubo <=0.23)
2+
3+
> ### ℹ️ Kubo 0.24 shipped with this plugin built-in
4+
>
5+
> It now lives at [ipfs/kubo/plugin/plugins/nopfs](https://github.com/ipfs/kubo/tree/master/plugin/plugins/nopfs)
6+
>
7+
> This version will no longer be maintained.
8+
>
9+
> Learn more at [`kubo/docs/content-blocking.md`](https://github.com/ipfs/kubo/blob/master/docs/content-blocking.md)
210
311
## Installation
412

0 commit comments

Comments
 (0)