Skip to content

Commit

Permalink
add provide messages in reframe (#285)
Browse files Browse the repository at this point in the history
* add provide messages in reframe
  • Loading branch information
willscott authored Aug 16, 2022
1 parent f4b416c commit e4d0123
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions reframe/REFRAME_KNOWN_METHODS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Request union {
| "FindProvidersRequest" FindProvidersRequest
| "GetIPNSRequest" GetIPNSRequest
| "PutIPNSRequest" PutIPNSRequest
| "ProvideRequest" ProvideRequest
}
```

Expand All @@ -50,6 +51,7 @@ type Response union {
| "FindProvidersResponse" FindProvidersResponse
| "GetIPNSResponse" GetIPNSResponse
| "PutIPNSResponse" PutIPNSResponse
| "ProvideResponse" ProvideResponse
| "Error" Error
}
```
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
4. Sign the Hash using the keypair associated with the Provider.ID


#### Provide DAG-JSON Examples

Request:
```json
{"ProvideRequest" : {
"Key" : {"/":{"bytes":"AXIUBPnagss"}},
"Providers" : [
{"Node":{"Peer":{"ID":{
"/":{"bytes":"EncodedPeerID"}}
}}}
]
}}
```

Response:
```json
{"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.
Expand Down

0 comments on commit e4d0123

Please sign in to comment.