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({
68
68
await libp2p .peerRouting .findPeer (peerIdFromString (' QmFoo' ))
69
69
```
70
70
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 peer of client .getPeers (peerIdFromString (' QmFoo' ), {
91
+ filterProtocols: [' transport-ipfs-gateway-http' ],
92
+ filterAddrs: [' !p2p-circuit' ]
93
+ })) {
94
+ // ...
95
+ }
96
+ ```
97
+
71
98
# Install
72
99
73
100
``` console
Original file line number Diff line number Diff line change 38
38
* // later this will use the configured HTTP gateway
39
39
* await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))
40
40
* ```
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 peer of client.getPeers(peerIdFromString('QmFoo'), {
64
+ * filterProtocols: ['transport-ipfs-gateway-http'],
65
+ * filterAddrs: ['!p2p-circuit']
66
+ * })) {
67
+ * // ...
68
+ * }
69
+ * ```
41
70
*/
42
71
43
72
import { DefaultDelegatedRoutingV1HttpApiClient } from './client.js'
You can’t perform that action at this time.
0 commit comments