Skip to content

Commit f3fe9d5

Browse files
lidelhacdias
authored andcommitted
ipip-0417: final editorials, list legacy schemas
we will have legacy schemas in the wild for a while, added a note that clients may parse them the same way as peer one (both have ID and Addrs)
1 parent 86ecfa0 commit f3fe9d5

File tree

2 files changed

+96
-24
lines changed

2 files changed

+96
-24
lines changed

src/ipips/ipip-0417.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ routing.
4747

4848
The section "Known Transfer Protocols" has been removed and replaced by a "Known Schemas"
4949
section. Before, we used to have protocol specific schemas, such as `bitswap` and `graphsync-filecoinv1`.
50-
The usage of the removed schemas is no longer encouraged. Instead, clients and servers
51-
SHOULD be updated to use the new, more generic, `peer` schema.
50+
51+
The usage of these schemas is no longer encouraged. Instead, clients and
52+
servers SHOULD be updated to use the new, more generic, `peer` schema, which
53+
avoids returning the same peer multiple times, making results more efficient
54+
when a peer supports more than one protocol.
5255

5356
See more in the "Compatibility" section of :cite[ipip-0337].
5457

src/routing/http-routing-v1.md

Lines changed: 91 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,26 @@ maturity: reliable
99
editors:
1010
- name: Gus Eggert
1111
github: guseggert
12+
affiliation:
13+
name: Protocol Labs
14+
url: https://protocol.ai/
1215
- name: Masih H. Derkani
1316
github: masih
17+
affiliation:
18+
name: Protocol Labs
19+
url: https://protocol.ai/
1420
- name: Henrique Dias
1521
url: https://hacdias.com/
1622
github: hacdias
23+
affiliation:
24+
name: Protocol Labs
25+
url: https://protocol.ai/
26+
- name: Marcin Rataj
27+
github: lidel
28+
url: https://lidel.org/
29+
affiliation:
30+
name: Protocol Labs
31+
url: https://protocol.ai/
1732
xref:
1833
- ipns-record
1934
order: 0
@@ -32,7 +47,7 @@ As such, human-readable encodings of types are preferred. This specification may
3247

3348
- CIDs are always string-encoded using a [multibase]-encoded [CIDv1].
3449
- Multiaddrs are string-encoded according to the [human-readable multiaddr specification][multiaddr].
35-
- Peer IDs are string-encoded according [PeerID string representation specification][peer-id-representation].
50+
- Peer IDs are string-encoded according [PeerID string representation specification][peer-id-representation]: either a Multihash in Base58btc, or a CIDv1 with libp2p-key (`0x72`) codec.
3651
- Multibase bytes are string-encoded according to [the Multibase spec][multibase], and SHOULD use base64.
3752
- Timestamps are Unix millisecond epoch timestamps.
3853

@@ -62,19 +77,21 @@ This API uses a standard version prefix in the path, such as `/v1/...`. If a bac
6277
{
6378
"Providers": [
6479
{
65-
"Schema": "peer",
66-
"Protocols": ["<protocol-a>", "<protocol-b>", ...],
67-
"ID": "12D3K...",
80+
"Schema": "<schema>",
81+
"ID": "bafz...",
6882
"Addrs": ["/ip4/..."],
83+
...
6984
},
7085
...
7186
]
7287
}
7388
```
7489

75-
Responses SHOULD be limited to 100 providers. This endpoint MAY support [streaming](#streaming).
90+
The `application/json` responses SHOULD be limited to 100 providers.
91+
92+
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
7693

77-
Each object in the `Providers` list is a record conforming to the [Peer Schema](#peer).
94+
Each object in the `Providers` list is a record conforming to a schema, usually the [Peer Schema](#peer-schema).
7895

7996
## Peer Routing API
8097

@@ -99,17 +116,20 @@ represented as a CIDv1 encoded with `libp2p-key` codec.
99116
{
100117
"Schema": "<schema>",
101118
"Protocols": ["<protocol-a>", "<protocol-b>", ...],
102-
"ID": "12D3K...",
119+
"ID": "bafz...",
103120
"Addrs": ["/ip4/..."],
121+
...
104122
},
105123
...
106124
]
107125
}
108126
```
109127

110-
Responses SHOULD be limited to 100 providers. This endpoint MAY support [streaming](#streaming).
128+
The `application/json` responses SHOULD be limited to 100 peers.
111129

112-
Each object in the `Peers` list is a record conforming to the [Peer Schema](#peer).
130+
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
131+
132+
Each object in the `Peers` list is a record conforming to the [Peer Schema](#peer-schema).
113133

114134
## IPNS API
115135

@@ -212,43 +232,92 @@ Access-Control-Allow-Methods: GET, OPTIONS
212232

213233
This section contains a non-exhaustive list of known schemas that MAY be supported by clients and servers.
214234

215-
### Peer
235+
### Peer Schema
216236

217237
The `peer` schema represents an arbitrary peer.
218238

219239
```json
220240
{
221241
"Schema": "peer",
222-
"ID": "12D3K...",
242+
"ID": "bafz...",
223243
"Addrs": ["/ip4/..."],
224244
"Protocols": ["transport-bitswap", ...]
245+
...
225246
}
226247
```
227248

228-
- `ID`: the [Peer ID][peer-id].
229-
- `Addrs`: a list of known [multiaddrs][multiaddr] for this peer. This list MAY be incomplete.
230-
- `Protocols`: a list of protocols known to be supported by this peer.
231-
- If empty, it means the server is missing protocol information, and the client should use `ID` and `Addrs` to connect to the peer and use the [libp2p identify protocol](https://github.com/libp2p/specs/tree/master/identify) to learn about supported ones.
249+
- `ID`: the [Peer ID][peer-id] as Multihash in Base58btc or CIDv1 with libp2p-key codec.
250+
- `Addrs`: an optional list of known [multiaddrs][multiaddr] for this peer.
251+
- If missing or empty, it means the router server is missing that information, and the client should use `ID` to lookup updated peer information.
252+
- `Protocols`: an optional list of protocols known to be supported by this peer.
253+
- If missing or empty, it means the router server is missing that information, and the client should use `ID` and `Addrs` to lookup connect to the peer and use the [libp2p identify protocol](https://github.com/libp2p/specs/tree/master/identify) to learn about supported ones.
232254

233255
:::note
234256

235-
To allow for protocol-specific fields and future-proofing, the parser MUST allow for unknown fields,
236-
and the clients MUST ignore unknown ones. Below is an example on how one could create a `foobar` protocol
237-
that includes an additional field `foobar`. If the client knows the `foobar` protocol, they are free to
238-
use the information contained in the additional field. If that is not the case, the field MUST be ignored.
257+
To allow for protocol-specific fields and future-proofing, the parser MUST
258+
allow for unknown fields, and the clients MUST ignore unknown ones.
259+
260+
Below is an example on how one could include `protocol-a` and `protocol-b`
261+
protocols that includes an additional fields `protocol-a` and `protocol-b`.
262+
263+
If the client knows the protocol, they are free to use the extra binary
264+
(base64) or JSON information contained in the additional field. If that is not
265+
the case, the field MUST be ignored.
239266

240267
```json
241268
{
242269
"Schema": "peer",
243-
"ID": "12D3K...",
270+
"ID": "bafz...",
244271
"Addrs": ["/ip4/..."],
245-
"Protocols": ["transport-bitswap", "foobar", ...],
246-
"foobar": "[base64-blob]"
272+
"Protocols": ["transport-bitswap", "protocol-a", "protocol-b", ...],
273+
"protocol-a": "[base64-blob]",
274+
"protocol-b": { "foo": "bar" }
247275
}
248276
```
249277

250278
:::
251279

280+
### Legacy Schemas
281+
282+
Legacy schemas include `ID` and optional `Addrs` list just like
283+
the [`peer` schema](#peer-schema) does.
284+
285+
These schemas are deprecated and SHOULD be replaced with `peer` over time, but
286+
MAY be returned by some legacy endpoints. In such case, a client MAY parse
287+
them the same way as the `peer` schema.
288+
289+
#### Bitswap Schema
290+
291+
A legacy schema used by some routers to indicate a peer supports retrieval over
292+
the `/ipfs/bitswap[/*]` libp2p protocol.
293+
294+
```json
295+
{
296+
"Protocol": "transport-bitswap",
297+
"Schema": "bitswap",
298+
"ID": "bafz...",
299+
"Addrs": ["/ip4/..."]
300+
}
301+
```
302+
303+
#### Graphsync Schema
304+
305+
A legacy schema used by some routers to indicate a peer supports retrieval over
306+
the [graphsync](https://github.com/ipfs/go-graphsync/blob/main/docs/architecture.md)
307+
libp2p protocol.
308+
309+
```json
310+
{
311+
"Protocol": "transport-graphsync-filecoinv1",
312+
"Schema": "graphsync-filecoinv1",
313+
"ID": "bafz...",
314+
"Addrs": ["/ip4/..."],
315+
"PieceCID": "<cid>",
316+
"VerifiedDeal": true,
317+
"FastRetrieval": true
318+
}
319+
```
320+
252321
[multibase]: https://github.com/multiformats/multibase
253322
[CIDv1]: https://github.com/multiformats/cid#cidv1
254323
[multiaddr]: https://github.com/multiformats/multiaddr#specification

0 commit comments

Comments
 (0)