File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,33 @@ const libp2p = await createLibp2p({
6868await libp2p .peerRouting .findPeer (peerIdFromString (' QmFoo' ))
6969```
7070
71+ ### Filtering with IPIP-484
72+
73+ The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484.
74+ The filter options be set globally, by passing them to the client constructor, or on a per-request basis.
75+
76+ ## Example
77+
78+ ``` typescript
79+ import { createDelegatedRoutingV1HttpApiClient } from ' @helia/delegated-routing-v1-http-api-client'
80+ import { createLibp2p } from ' libp2p'
81+ import { peerIdFromString } from ' @libp2p/peer-id'
82+
83+ // globally set filter options
84+ const client = createDelegatedRoutingV1HttpApiClient (' https://delegated-ipfs.dev' , {
85+ filterProtocols: [' transport-bitswap' , ' unknown' , ' transport-ipfs-gateway-http' ],
86+ filterAddrs: [' webtransport' , ' webrtc-direct' , ' wss' ]
87+ })
88+
89+ // per-request filter options
90+ for await (const prov of getProviders (CID .parse (' bafy' ), {
91+ filterProtocols: [' transport-ipfs-gateway-http' ],
92+ filterAddrs: [' !p2p-circuit' ]
93+ })) {
94+ // ...
95+ }
96+ ```
97+
7198# Install
7299
73100``` console
Original file line number Diff line number Diff line change 3838 * // later this will use the configured HTTP gateway
3939 * await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))
4040 * ```
41+ *
42+ * ### Filtering with IPIP-484
43+ *
44+ * The client can be configured to pass filter options to the delegated routing server as defined in IPIP-484.
45+ * The filter options be set globally, by passing them to the client constructor, or on a per-request basis.
46+ *
47+ * @see https://github.com/ipfs/specs/pull/484
48+ *
49+ * @example
50+ *
51+ * ```typescript
52+ * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
53+ * import { createLibp2p } from 'libp2p'
54+ * import { peerIdFromString } from '@libp2p/peer-id'
55+ *
56+ * // globally set filter options
57+ * const client = createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', {
58+ * filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
59+ * filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
60+ * })
61+ *
62+ * // per-request filter options
63+ * for await (const prov of getProviders(CID.parse('bafy'), {
64+ * filterProtocols: ['transport-ipfs-gateway-http'],
65+ * filterAddrs: ['!p2p-circuit']
66+ * })) {
67+ * // ...
68+ * }
69+ * ```
4170 */
4271
4372import { DefaultDelegatedRoutingV1HttpApiClient } from './client.js'
You can’t perform that action at this time.
0 commit comments