Skip to content

Commit

Permalink
Merge pull request #705 from w3f/hbr/encode_update
Browse files Browse the repository at this point in the history
fix: missing information about SCALE encoding on HttpRequestStatus codes
  • Loading branch information
Noc2 authored Sep 28, 2023
2 parents 7694f67 + 72ae30c commit 260346c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions docs/chap-host-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1088,15 +1088,18 @@ All data and results generated by Offchain workers are unique per node and nonde
###### Definition -def-num- HTTP Status Code {#defn-http-status-code}
:::definition

**HTTP status codes** that can get returned by certain Offchain HTTP functions.
An enumerated data type that holds a finite set of distinct variants that gets SCALE-encoded as described in ([Definition -def-num-ref-](id-cryptography-encoding#defn-scale-variable-type)) and returned by offchain http functions. The set of variants is defined as follows.

- `0`: the specified request identifier is invalid.
| Id | Name | Description |
|-----|-------------------------|------------------------------------------------------------|
| 0 | *DeadlineReached* | the deadline for the started request was reached. |
| 1 | *IoError* | an error has occurred during the request. |
| 2 | *Invalid* | the specified request identifier is invalid. |
| 3 | *Finished(http_status)* | the request has finished with the given HTTP status code. |

- `10`: the deadline for the started request was reached.

- `20`: an error has occurred during the request, e.g. a timeout or the remote server has closed the connection. On returning this error code, the request is considered destroyed and must be reconstructed again.
**where**

- `100`-`999`: the request has finished with the given HTTP status code.
- `http_status`: a 16-bit unsigned integer type representing the [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) to be returned.

:::
###### Definition -def-num- HTTP Error {#defn-http-error}
Expand Down
2 changes: 1 addition & 1 deletion docs/id-cryptography-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ $$
{\mathcal{{T}}}={\left\lbrace{T}_{{1}},\ldots,{T}_{{n}}\right\rbrace}
$$

A value ${A}$ of varying date type is a pair ${\left({A}_{{\text{Type}}},{A}_{{\text{Value}}}\right)}$ where ${A}_{{\text{Type}}}={T}_{{i}}$ for some ${T}_{{i}}\in{\mathcal{{T}}}$ and ${A}_{{\text{Value}}}$ is its value of type ${T}_{{i}}$, which can be empty. We define $\text{idx}{\left({T}_{{i}}\right)}={i}-{1}$, unless it is explicitly defined as another value in the definition of a particular varying data type.
A value ${A}$ of varying data type is a pair ${\left({A}_{{\text{Type}}},{A}_{{\text{Value}}}\right)}$ where ${A}_{{\text{Type}}}={T}_{{i}}$ for some ${T}_{{i}}\in{\mathcal{{T}}}$ and ${A}_{{\text{Value}}}$ is its value of type ${T}_{{i}}$, which can be empty. We define $\text{idx}{\left({T}_{{i}}\right)}={i}-{1}$, unless it is explicitly defined as another value in the definition of a particular varying data type.

In particular, we define two specific varying data which are frequently used in various part of Polkadot protocol: *Option* ([Definition -def-num-ref-](id-cryptography-encoding#defn-option-type)) and *Result* ([Definition -def-num-ref-](id-cryptography-encoding#defn-result-type)).

Expand Down

0 comments on commit 260346c

Please sign in to comment.