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
* archive: Use subscriptions for storageDiff
Signed-off-by: Alexandru Vasile <[email protected]>
* archive: Add stop method
Signed-off-by: Alexandru Vasile <[email protected]>
* archive: Move previousHash as last parameter
Signed-off-by: Alexandru Vasile <[email protected]>
* archive: Make items non-optional
Signed-off-by: Alexandru Vasile <[email protected]>
* archive: Introduce storageDiffError event
Signed-off-by: Alexandru Vasile <[email protected]>
* archive: Simplify error code
Signed-off-by: Alexandru Vasile <[email protected]>
* Update src/api/archive_unstable_stopStorageDiff.md
Co-authored-by: Niklas Adolfsson <[email protected]>
* Update src/api/archive_unstable_stopStorageDiff.md
Co-authored-by: Niklas Adolfsson <[email protected]>
* archive: Move previousHash below items description
Signed-off-by: Alexandru Vasile <[email protected]>
---------
Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: Niklas Adolfsson <[email protected]>
- An opaque string that was returned by `archive_unstable_storageDiff`.
6
+
7
+
**Return value**: *null*
8
+
9
+
Stops a subscription started with `archive_unstable_storageDiff`. Has no effect if the opaque string is invalid or refers to a subscription that has already emitted a `{"event": "storageDiffDone"}` event.
10
+
11
+
JSON-RPC client implementations must be aware that, due to the asynchronous nature of JSON-RPC client <-> server communication, they might still receive chain updates notifications, for example because these notifications were already in the process of being sent back by the JSON-RPC server.
Copy file name to clipboardExpand all lines: src/api/archive_unstable_storageDiff.md
+55-18Lines changed: 55 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,7 @@
4
4
5
5
-`hash`: String containing a hexadecimal-encoded hash of the header of the block whose storage difference will be retrieved.
6
6
7
-
-`previousHash` (optional): String containing a hexadecimal-encoded hash of the header of the block from which the storage difference will be calculated. The `previousHash` must be an ancestor of the provided `hash`. When this parameter is provided, the storage difference is calculated between the `hash` block and the `previousHash` block. If this parameter is not provided, the storage difference is calculated between the `hash` block and the parent of the `hash` block.
8
-
9
-
-`items` (optional): Array of objects. The structure of these objects is found below.
7
+
-`items`: Array of objects. The structure of these objects is found below.
10
8
11
9
```json
12
10
"items": [
@@ -28,25 +26,41 @@
28
26
- `hash`: The result contains the hexadecimal-encoded hash of the storage entry.
29
27
- `childTrieKey` (optional): String containing the hexadecimal-encoded key of the child trie of the "default" namespace. If this field is not present, the storage difference is calculated for the main storage trie.
30
28
31
-
**Return value**: A JSON object.
29
+
- `previousHash` (optional): String containing a hexadecimal-encoded hash of the header of the block from which the storage difference will be calculated. The `previousHash` must be an ancestor of the provided `hash`. When this parameter is provided, the storage difference is calculated between the `hash` block and the `previousHash` block. If this parameter is not provided, the storage difference is calculated between the `hash` block and the parent of the `hash` block.
30
+
31
+
**Return value**: String containing an opaque value representing the operation.
32
32
33
-
The JSON object returned by this function has the following format:
33
+
## Notifications format
34
+
35
+
This function will later generate one or more notifications in the following format:
34
36
35
37
```json
36
38
{
37
-
"result": [
38
-
{
39
-
"key": "0x...",
40
-
"value": "0x...",
41
-
"hash": "0x...",
42
-
"type": "added"| "modified" | "deleted",
43
-
"childTrieKey": "0x...",
44
-
}
45
-
],
39
+
"jsonrpc": "2.0",
40
+
"method": "archive_unstable_storageDiffEvent",
41
+
"params": {
42
+
"subscription": "...",
43
+
"result": ...
44
+
}
46
45
}
47
46
```
48
47
49
-
The `result` field contains an array of objects, each containing a JSON object:
48
+
Where `subscription` is the value returned by this function, and `result` can be one of:
49
+
50
+
### storageDiff
51
+
52
+
```json
53
+
{
54
+
"event": "storageDiff",
55
+
"key": "0x...",
56
+
"value": "0x...",
57
+
"hash": "0x...",
58
+
"type": "added"| "modified" | "deleted",
59
+
"childTrieKey": "0x...",
60
+
}
61
+
```
62
+
63
+
The `storageDiff` event is generated for each storage difference between the two blocks.
50
64
51
65
-`key`: String containing the hexadecimal-encoded key of the storage entry. A prefix of this key may have been provided in the items input.
52
66
@@ -61,18 +75,41 @@ The `result` field contains an array of objects, each containing a JSON object:
61
75
62
76
-`childTrieKey` (optional): String containing the hexadecimal-encoded key of the child trie of the "default" namespace if the storage entry is part of a child trie. If the storage entry is part of the main trie, this field is not present.
63
77
78
+
### storageDiffDone
79
+
80
+
```json
81
+
{
82
+
"event": "storageDiffDone",
83
+
}
84
+
```
85
+
86
+
This event is always generated after all `storageDiff` events have been generated.
87
+
88
+
No more events will be generated after a `storageDiffDone` event.
89
+
90
+
### storageDiffError
91
+
92
+
```json
93
+
{
94
+
"event": "storageDiffError",
95
+
"error": "...",
96
+
}
97
+
```
98
+
99
+
`error` is a human-readable error message indicating why the call has failed. This string isn't meant to be shown to end users, but is for developers to understand the problem.
100
+
101
+
No more events will be generated after a `storageDiffError` event.
102
+
64
103
## Overview
65
104
66
105
This function calculates the storage difference between two blocks. The storage difference is calculated by comparing the storage of the `previousHash` block with the storage of the `hash` block. If the `previousHash` parameter is not provided, the storage difference is calculated between the parent of the `hash` block and the `hash` block.
67
106
68
-
The JSON-RPC server is encouraged to accept at least one `archive_unstable_storageDiff`method per JSON-RPC client. Trying to make more calls might lead to a JSON-RPC error when calling `archive_unstable_storageDiff`. The JSON-RPC server must return an error code if the server is overloaded and cannot accept new method call.
107
+
The JSON-RPC server is encouraged to accept at least one `archive_unstable_storageDiff`subscription per JSON-RPC client. Trying to make more calls might lead to a JSON-RPC error when calling `archive_unstable_storageDiff`. The JSON-RPC server must return an error code if the server is overloaded and cannot accept new subscription call.
69
108
70
109
Users that want to obtain the storage difference between two blocks should use this function instead of calling `archive_unstable_storage` for each block and comparing the results.
71
110
When users are interested in the main trie storage differences, as well as in a child storage difference, they can call this function with `items: [ { "returnType": "value" }, { "returnType": "value", "childTrieKey": "0x..." } ]`.
72
111
73
112
## Possible errors
74
113
75
114
- A JSON-RPC error can be generated if the JSON-RPC client has to many active calls to `archive_unstable_storageDiff`.
76
-
- A JSON-RPC error can be generated if the `previousHash` parameter is provided, but the `previousHash` block is not an ancestor of the `hash` block.
77
-
- A JSON-RPC error can be generated if one of the hashes provided does not correspond to a known block header hash.
78
115
- A JSON-RPC error with error code `-32602` is generated if one of the parameters doesn't correspond to the expected type (similarly to a missing parameter or an invalid parameter type).
0 commit comments