-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[StateService] get historical state (#638)
* StateService: add historical state * GetState and FindState; Results in pages * use root hash * StateService: add from in mpt Find * format * fix merge * Shargon's feedback * rm max page number * Shargon's feedback * rename FindState to FindStates * update * FindStates ignore from * FindStates return first and last proof * fix inexistent contract * StateService: add key length check * fix * fix offset initial value Co-authored-by: Shargon <[email protected]> Co-authored-by: Owen Zhang <[email protected]>
- Loading branch information
1 parent
87ed9f0
commit 50f0473
Showing
12 changed files
with
290 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace Neo.Plugins.MPT | ||
{ | ||
public static class Helper | ||
{ | ||
public static int CompareTo(this byte[] arr1, byte[] arr2) | ||
{ | ||
if (arr1 is null || arr2 is null) throw new ArgumentNullException(); | ||
for (int i = 0; i < arr1.Length && i < arr2.Length; i++) | ||
{ | ||
var r = arr1[i].CompareTo(arr2[i]); | ||
if (r != 0) return r; | ||
} | ||
return arr2.Length < arr1.Length ? 1 : arr2.Length == arr1.Length ? 0 : -1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# StateService | ||
|
||
## RPC API | ||
|
||
### GetStateRoot | ||
#### Params | ||
|Name|Type|Summary|Required| | ||
|-|-|-|-| | ||
|Index|uint|index|true| | ||
#### Result | ||
StateRoot Object | ||
|Name|Type|Summary| | ||
|-|-|-| | ||
|version|number|version| | ||
|index|number|index| | ||
|roothash|string|version| | ||
|witness|Object|witness from validators| | ||
|
||
### GetProof | ||
#### Params | ||
|Name|Type|Summary|Required| | ||
|-|-|-|-| | ||
|RootHash|UInt256|state root|true| | ||
|ScriptHash|UInt160|contract script hash|true| | ||
|Key|base64 string|key|true| | ||
#### Result | ||
Proof in base64 string | ||
|
||
### VerifyProof | ||
#### Params | ||
|Name|Type|Summary| | ||
|-|-|-| | ||
|RootHash|UInt256|state root|true| | ||
|Proof|base64 string|proof|true| | ||
#### Result | ||
Value in base64 string | ||
|
||
### GetStateheight | ||
#### Result | ||
|Name|Type|Summary| | ||
|-|-|-| | ||
|localrootindex|number|root hash index calculated locally| | ||
|validatedrootindex|number|root hash index verified by validators| | ||
|
||
### GetState | ||
#### Params | ||
|Name|Type|Summary|Required| | ||
|-|-|-|-| | ||
|RootHash|UInt256|specify state|true| | ||
|ScriptHash|UInt160|contract script hash|true| | ||
|Key|base64 string|key|true| | ||
#### Result | ||
Value in base64 string or `null` | ||
|
||
### FindStates | ||
#### Params | ||
|Name|Type|Summary|Required| | ||
|-|-|-|-| | ||
|RootHash|UInt256|specify state|true| | ||
|ScriptHash|UInt160|contract script hash|true| | ||
|Prefix|base64 string|key prefix|true| | ||
|From|base64 string|start key, default `Empty`|optional| | ||
|Count|number|count of results in one request, default `MaxFindResultItems`|optional| | ||
#### Result | ||
|Name|Type|Summary| | ||
|-|-|-| | ||
|firstProof|string|proof of first value in results| | ||
|lastProof|string|proof of last value in results| | ||
|truncated|bool|whether the results is truncated because of limitation| | ||
|results|array|key-values found| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.