Skip to content

Commit 922c1a3

Browse files
committed
chore: upgrade boxo with delegated provide
1 parent 2841ec0 commit 922c1a3

File tree

10 files changed

+44
-31
lines changed

10 files changed

+44
-31
lines changed

core/corehttp/routing.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ func (r *contentRouter) FindProviders(ctx context.Context, key cid.Cid, limit in
4444
}), nil
4545
}
4646

47-
// nolint deprecated
48-
func (r *contentRouter) ProvideBitswap(ctx context.Context, req *server.BitswapWriteProvideRequest) (time.Duration, error) {
49-
return 0, routing.ErrNotSupported
50-
}
51-
5247
func (r *contentRouter) FindPeers(ctx context.Context, pid peer.ID, limit int) (iter.ResultIter[*types.PeerRecord], error) {
5348
ctx, cancel := context.WithCancel(ctx)
5449
defer cancel()
@@ -96,6 +91,14 @@ func (r *contentRouter) PutIPNS(ctx context.Context, name ipns.Name, record *ipn
9691
return r.n.Routing.PutValue(ctx, string(name.RoutingKey()), raw)
9792
}
9893

94+
func (r *contentRouter) Provide(ctx context.Context, req *types.AnnouncementRecord) (time.Duration, error) {
95+
return 0, routing.ErrNotSupported
96+
}
97+
98+
func (r *contentRouter) ProvidePeer(ctx context.Context, req *types.AnnouncementRecord) (time.Duration, error) {
99+
return 0, routing.ErrNotSupported
100+
}
101+
99102
type peerChanIter struct {
100103
ch <-chan peer.AddrInfo
101104
cancel context.CancelFunc

docs/examples/kubo-as-a-library/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ toolchain go1.22.0
99
replace github.com/ipfs/kubo => ./../../..
1010

1111
require (
12-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904
12+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9
1313
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
1414
github.com/libp2p/go-libp2p v0.33.2
1515
github.com/multiformats/go-multiaddr v0.12.3

docs/examples/kubo-as-a-library/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
268268
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
269269
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
270270
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
271-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904 h1:HqjqN6oADXh1UNw8xKnBP50B3ZQDC/RStiBFPp6W+9Y=
272-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904/go.mod h1:hA9Ou/YnfMZOG2nQhngsbBiYt6fiJ1EhWSmccZfV+M0=
271+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9 h1:zo800iXCJgIKt/s4R51/FFWdZS1KdyUONw3FrUt92e8=
272+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9/go.mod h1:hA9Ou/YnfMZOG2nQhngsbBiYt6fiJ1EhWSmccZfV+M0=
273273
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
274274
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
275275
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/hashicorp/go-multierror v1.1.1
1818
github.com/ipfs-shipyard/nopfs v0.0.12
1919
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c
20-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904
20+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9
2121
github.com/ipfs/go-block-format v0.2.0
2222
github.com/ipfs/go-cid v0.4.1
2323
github.com/ipfs/go-cidutil v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
329329
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
330330
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
331331
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
332-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904 h1:HqjqN6oADXh1UNw8xKnBP50B3ZQDC/RStiBFPp6W+9Y=
333-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904/go.mod h1:hA9Ou/YnfMZOG2nQhngsbBiYt6fiJ1EhWSmccZfV+M0=
332+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9 h1:zo800iXCJgIKt/s4R51/FFWdZS1KdyUONw3FrUt92e8=
333+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9/go.mod h1:hA9Ou/YnfMZOG2nQhngsbBiYt6fiJ1EhWSmccZfV+M0=
334334
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
335335
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
336336
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=

routing/delegated.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/libp2p/go-libp2p/core/peer"
2424
"github.com/libp2p/go-libp2p/core/routing"
2525
ma "github.com/multiformats/go-multiaddr"
26+
"github.com/multiformats/go-multicodec"
2627
"go.opencensus.io/stats/view"
2728
)
2829

@@ -203,8 +204,10 @@ func httpRoutingFromConfig(conf config.Router, extraHTTP *ExtraHTTPParams) (rout
203204
cli, err := drclient.New(
204205
params.Endpoint,
205206
drclient.WithHTTPClient(delegateHTTPClient),
206-
drclient.WithIdentity(key),
207-
drclient.WithProviderInfo(addrInfo.ID, addrInfo.Addrs),
207+
drclient.WithProviderInfo(key, addrInfo.ID, addrInfo.Addrs, []string{
208+
multicodec.TransportBitswap.String(),
209+
multicodec.TransportIpfsGatewayHttp.String(),
210+
}),
208211
drclient.WithUserAgent(version.GetUserAgentVersion()),
209212
)
210213
if err != nil {

test/cli/content_routing_http_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import (
2222
)
2323

2424
type fakeHTTPContentRouter struct {
25-
m sync.Mutex
26-
provideBitswapCalls int
27-
findProvidersCalls int
28-
findPeersCalls int
25+
m sync.Mutex
26+
provideCalls int
27+
providePeerCalls int
28+
findProvidersCalls int
29+
findPeersCalls int
2930
}
3031

3132
func (r *fakeHTTPContentRouter) FindProviders(ctx context.Context, key cid.Cid, limit int) (iter.ResultIter[types.Record], error) {
@@ -35,11 +36,17 @@ func (r *fakeHTTPContentRouter) FindProviders(ctx context.Context, key cid.Cid,
3536
return iter.FromSlice([]iter.Result[types.Record]{}), nil
3637
}
3738

38-
// nolint deprecated
39-
func (r *fakeHTTPContentRouter) ProvideBitswap(ctx context.Context, req *server.BitswapWriteProvideRequest) (time.Duration, error) {
39+
func (r *fakeHTTPContentRouter) Provide(ctx context.Context, rec *types.AnnouncementRecord) (time.Duration, error) {
4040
r.m.Lock()
4141
defer r.m.Unlock()
42-
r.provideBitswapCalls++
42+
r.provideCalls++
43+
return 0, nil
44+
}
45+
46+
func (r *fakeHTTPContentRouter) ProvidePeer(ctx context.Context, rec *types.AnnouncementRecord) (time.Duration, error) {
47+
r.m.Lock()
48+
defer r.m.Unlock()
49+
r.providePeerCalls++
4350
return 0, nil
4451
}
4552

test/cli/delegated_routing_v1_http_client_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ func TestHTTPDelegatedRouting(t *testing.T) {
9090
server := fakeServer("application/json", ToJSONStr(JSONObj{
9191
"Providers": []JSONObj{
9292
{
93-
"Schema": "bitswap", // Legacy bitswap schema.
94-
"Protocol": "transport-bitswap",
95-
"ID": provs[1],
96-
"Addrs": []string{"/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/4002"},
93+
"Schema": "peer",
94+
"Protocols": []string{"transport-bitswap"},
95+
"ID": provs[1],
96+
"Addrs": []string{"/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/4002"},
9797
},
9898
{
9999
"Schema": "peer",
@@ -137,10 +137,10 @@ func TestHTTPDelegatedRouting(t *testing.T) {
137137
"ID": provs[0],
138138
"Addrs": []string{"/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/4002"},
139139
}), ToJSONStr(JSONObj{
140-
"Schema": "bitswap", // Legacy bitswap schema.
141-
"Protocol": "transport-bitswap",
142-
"ID": provs[1],
143-
"Addrs": []string{"/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/4002"},
140+
"Schema": "peer",
141+
"Protocols": []string{"transport-bitswap"},
142+
"ID": provs[1],
143+
"Addrs": []string{"/ip4/0.0.0.0/tcp/4001", "/ip4/0.0.0.0/tcp/4002"},
144144
}))
145145
t.Cleanup(server.Close)
146146

test/dependencies/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ require (
105105
github.com/hexops/gotextdiff v1.0.3 // indirect
106106
github.com/inconshreveable/mousetrap v1.1.0 // indirect
107107
github.com/ipfs/bbloom v0.0.4 // indirect
108-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904 // indirect
108+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9 // indirect
109109
github.com/ipfs/go-block-format v0.2.0 // indirect
110110
github.com/ipfs/go-cid v0.4.1 // indirect
111111
github.com/ipfs/go-datastore v0.6.0 // indirect

test/dependencies/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
362362
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
363363
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
364364
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
365-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904 h1:HqjqN6oADXh1UNw8xKnBP50B3ZQDC/RStiBFPp6W+9Y=
366-
github.com/ipfs/boxo v0.19.1-0.20240415103851-7f9506844904/go.mod h1:hA9Ou/YnfMZOG2nQhngsbBiYt6fiJ1EhWSmccZfV+M0=
365+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9 h1:zo800iXCJgIKt/s4R51/FFWdZS1KdyUONw3FrUt92e8=
366+
github.com/ipfs/boxo v0.19.1-0.20240508083100-abf64fcd93a9/go.mod h1:hA9Ou/YnfMZOG2nQhngsbBiYt6fiJ1EhWSmccZfV+M0=
367367
github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
368368
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
369369
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=

0 commit comments

Comments
 (0)