From 627326de134836d3a68b6d3e1f6cfbeddc9ea310 Mon Sep 17 00:00:00 2001 From: "Heverson B. Ribeiro" Date: Mon, 25 Sep 2023 14:51:35 +0200 Subject: [PATCH 1/3] minor fix: mistype --- docs/id-cryptography-encoding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/id-cryptography-encoding.md b/docs/id-cryptography-encoding.md index bef7b99a7..08429a34f 100644 --- a/docs/id-cryptography-encoding.md +++ b/docs/id-cryptography-encoding.md @@ -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)). From 69ff4b3dbe1019a9ce3542ead789f47c81c5405b Mon Sep 17 00:00:00 2001 From: "Heverson B. Ribeiro" Date: Tue, 26 Sep 2023 16:45:38 +0200 Subject: [PATCH 2/3] fix missing information about SCALEencoding on HttpRequestStatus codes --- docs/chap-host-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/chap-host-api.md b/docs/chap-host-api.md index 5bff31ba6..573c3c8c0 100644 --- a/docs/chap-host-api.md +++ b/docs/chap-host-api.md @@ -1088,7 +1088,7 @@ 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. +A SCALE encoded structure holding of one of the following **HTTP status codes** that get returned by offchain http functions. - `0`: the specified request identifier is invalid. From 72ae30c3bd45e1a9d5663bac96f46b1e3cbee6d3 Mon Sep 17 00:00:00 2001 From: "Heverson B. Ribeiro" Date: Thu, 28 Sep 2023 10:45:46 +0200 Subject: [PATCH 3/3] update definition, now using the already defined scale-encode operation for varying data types --- docs/chap-host-api.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/chap-host-api.md b/docs/chap-host-api.md index 573c3c8c0..ee75602ee 100644 --- a/docs/chap-host-api.md +++ b/docs/chap-host-api.md @@ -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 -A SCALE encoded structure holding of one of the following **HTTP status codes** that get returned by 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}