-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add provide messages in reframe #285
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ type Request union { | |
| "FindProvidersRequest" FindProvidersRequest | ||
| "GetIPNSRequest" GetIPNSRequest | ||
| "PutIPNSRequest" PutIPNSRequest | ||
| "ProvideRequest" ProvideRequest | ||
} | ||
``` | ||
|
||
|
@@ -50,6 +51,7 @@ type Response union { | |
| "FindProvidersResponse" FindProvidersResponse | ||
| "GetIPNSResponse" GetIPNSResponse | ||
| "PutIPNSResponse" PutIPNSResponse | ||
| "ProvideResponse" ProvideResponse | ||
| "Error" Error | ||
} | ||
``` | ||
|
@@ -131,9 +133,9 @@ Note: While the Key is a CID it is highly recommended that server implementation | |
} | ||
|
||
type Provider struct { | ||
Node Node | ||
Proto optional [TransferProtocol] | ||
} | ||
Node Node | ||
Proto optional [TransferProtocol] | ||
} | ||
|
||
# Note: This is not quite valid IPLD Schema because having fallbacks within unions is not yet implemented and codified https://github.com/ipld/ipld/issues/194. We will use this syntax within this spec though. | ||
|
||
|
@@ -261,6 +263,60 @@ Response: | |
{"PutIPNSResponse : {}"} | ||
``` | ||
|
||
#### Provide | ||
|
||
A message for indicating that the client is able to act as a provider for a given key. | ||
|
||
```ipldsch | ||
type ProvideRequest struct | ||
Key &Any | ||
Provider Provider | ||
Timestamp Integer | ||
AdvisoryTTL Integer | ||
Signature Bytes | ||
} | ||
|
||
type ProvideResponse struct { | ||
AdvisoryTTL Integer | ||
} | ||
``` | ||
|
||
Note: While the Key is a CID, it is highly recommended that server implementations treat these Requests as if they were for the multihash. | ||
|
||
There are a a few semantics relevant to the construction of a ProvideRequest: | ||
|
||
* The timestamp should be the current unix timestamp, encoded in an int64 | ||
* AdvistoryTTL may list the time for which the provider desires the content will remain available. If the provider cannot not anticipate how long the content will remain available, it may use a 0 value for this field. | ||
* The AdvisoryTTL response may provide an expectation from the reframe endpoint of how long the content will remain available. | ||
* If it is less than the requested TTL from the request, it indicates that the client should re-issue a ProvideRequest for the content by that point. | ||
* If it is greater than the clients request, it indicates that the client may be perceived as responsible for the content for up to that amount of time. | ||
* If it is 0, the endpoint is indicating it cannot make any claims about the lifetime of the request. | ||
* Construction of the Signature is performed as follows: | ||
1. Create the ProviderRequest struct, with empty bytes for Signature | ||
2. Serialize the ProviderRequest as DagJSON | ||
3. Hash the serialization with Sha256 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: it feels off, hardcoding hash in provider request spec like this is not following the spirit of Multiformats. Should we add an escape hatch for signaling function without having to rewrite all clients and all servers? Sadly "multisig" it does not exist: multiformats/multiformats#23). |
||
4. Sign the Hash using the keypair associated with the Provider.ID | ||
|
||
|
||
##### DAG-JSON Examples | ||
|
||
Request: | ||
``` | ||
{"ProvideRequest" : { | ||
"Key" : {"/":{"bytes":"AXIUBPnagss"}}, | ||
"Providers" : [ | ||
{"Node":{"Peer":{"ID":{ | ||
"/":{"bytes":"EncodedPeerID"}} | ||
}}} | ||
] | ||
}} | ||
``` | ||
|
||
Response: | ||
``` | ||
{"ProvideResponse : {}"} | ||
``` | ||
|
||
# Method Upgrade Paths | ||
|
||
It is acknowledged that the initial methods and mechanisms of this protocol will likely need to change over time and that we should prepare for how to do so without the need to wholesale replace this protocol with an alternative. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw In IPNS V2 we sign a DAG-CBOR document.
Not sure if this is a controversial take, but I expect people will ask us to allow more compact DAG-CBOR instead of DAG-JSON on the wire. In that future, requirement to use JSON here will work, but look really awkward.
Maybe it is a good idea to use CBOR from the beginning?
(as a side benefit, CBOR will be more efficient than JSON: less bytes to hash)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also second CBOR specifically for data compaction reasons - to reduce snapshot size of the larger nodes.