You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reintroduce provide records via PUT to HTTP delegated routing
Previous work reduced the scope of IPIP-337 to read operations only. The
changes here re-introduce the write operations originally written by
@guseggert back into IPIP-337.
The specification documents the ability to provide Bitswap records over
`PUT` requests with advisory TTL. An implementation of the specification
is already present in go-libipfs.
See:
- #370
Copy file name to clipboardExpand all lines: routing/DELEGATED_CONTENT_ROUTING_HTTP.md
+91-1
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,39 @@ Response limit: 100 providers
90
90
91
91
Each object in the `Providers` list is a *read provider record*.
92
92
93
+
### `PUT /routing/v1/providers`
94
+
- Response Codes
95
+
-`200`: the server processed the full list of provider records (possibly unsuccessfully, depending on the semantics of the particular records)
96
+
- Request Body
97
+
```json
98
+
{
99
+
"Providers": [
100
+
{
101
+
"Protocol": "<protocol_name>",
102
+
"Schema": "bitswap",
103
+
...
104
+
}
105
+
]
106
+
}
107
+
```
108
+
109
+
Each object in the `Providers` list is a *write provider record*.
110
+
111
+
- Response Body
112
+
```json
113
+
{
114
+
"ProvideResults": [
115
+
{ ... }
116
+
]
117
+
}
118
+
```
119
+
-`ProvideResults` is a list of results in the same order as the `Providers` in the request, and the schema of each object is determined by the `Protocol` of the corresponding write object (called "Write Provider Records Response" in the Known Transfer Protocols section)
120
+
- This may contain output information such as TTLs, errors, etc.
121
+
- It is undefined whether the server will allow partial results
122
+
- The work for processing each provider record should be idempotent so that it can be retried without excessive cost in the case of full or partial failure of the request
123
+
- Default limit of 100 keys per request
124
+
- Implements pagination according to the Pagination section
125
+
93
126
## Pagination
94
127
95
128
This API does not support pagination, but optional pagination can be added in a backwards-compatible spec update.
@@ -118,7 +151,7 @@ limits, allowing every site to query the API for results:
The server should respect a passed `transport` query parameter by filtering against the `Addrs` list.
150
183
184
+
185
+
#### Bitswap Write Provider Records
186
+
187
+
```json
188
+
{
189
+
"Protocol": "transport-bitswap",
190
+
"Schema": "bitswap",
191
+
"Signature": "<signature>",
192
+
"Payload": "<payload>"
193
+
}
194
+
```
195
+
196
+
-`Signature`: a multibase-encoded signature of the sha256 hash of the `Payload` field, signed using the private key of the Peer ID specified in the `Payload` JSON. Signing details for specific key types should follow [libp2p/peerid specs](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#key-types), unless stated otherwise.
197
+
198
+
- Servers may ignore this field if they do not require signature verification.
199
+
-`Payload`: a string containing a serialized JSON object which conforms with the following schema:
200
+
```json
201
+
{
202
+
"Keys": ["cid1", "cid2"],
203
+
"Timestamp": 0,
204
+
"AdvisoryTTL": 0,
205
+
"ID": "12D3K...",
206
+
"Addrs": ["/ip4/..."]
207
+
}
208
+
```
209
+
-`Keys` is a list of the CIDs being provided
210
+
-`Timestamp` is the current time
211
+
-`AdvisoryTTL` is the time by which the caller expects the server to keep the record available
212
+
- If this value is unknown, the caller may use a value of 0
213
+
-`ID` is the peer ID that was used to sign the record
214
+
-`Addrs` is a list of string-encoded multiaddrs
215
+
216
+
A [400 Bad Request](https://httpwg.org/specs/rfc9110.html#status.400) response code should be returned if the signature check fails.
217
+
218
+
Note that this only supports Peer IDs expressed as identity multihashes. Peer IDs with older key types that exceed 42 bytes are not verifiable since they only contain a hash of the key, not the key itself.
219
+
Normally, if the Peer ID contains only a hash of the key, then the key is obtained out-of-band (e.g. by fetching the block via IPFS).
220
+
If support for these Peer IDs is needed in the future, this spec can be updated to allow the client to provide the key and key type out-of-band by adding optional `PublicKey` and `PublicKeyType` fields, and if the Peer ID is a CID, then the server can verify the public key's authenticity against the CID, and then proceed with the rest of the verification scheme.
221
+
222
+
The `Payload` field is a string, not a proper JSON object, to prevent its contents from being accidentally parsed and re-encoded by intermediaries, which may change the order of JSON fields and thus cause the record to fail validation.
223
+
224
+
#### Write Provider Records Response
225
+
226
+
```json
227
+
{
228
+
"AdvisoryTTL": 0
229
+
}
230
+
```
231
+
232
+
-`AdvisoryTTL` is the time at which the server expects itself to drop the record
233
+
- If less than the `AdvisoryTTL` in the request, then the client should re-issue the request by that point
234
+
- If greater than the `AdvisoryTTL` in the request, then the server expects the client to be responsible for the content for up to that amount of time (TODO: this is ambiguous)
235
+
- If 0, the server makes no claims about the lifetime of the record
-`PieceCID`: the CID of the [piece](https://spec.filecoin.io/systems/filecoin_files/piece/#section-systems.filecoin_files.piece) within which the data is stored
174
260
-`VerifiedDeal`: whether the deal corresponding to the data is verified
175
261
-`FastRetrieval`: whether the provider claims there is an unsealed copy of the data available for fast retrieval
0 commit comments