Skip to content

Commit

Permalink
Fix RpcServer[GetStorage] (neo-project#183)
Browse files Browse the repository at this point in the history
* Fix RpcServer.Blockchain.cs[GetStorage], using id to be key.

* Accept id and hash

Co-authored-by: Shargon <shargon@gmail.com>
  • Loading branch information
2 people authored and 陈志同 committed Oct 13, 2020
1 parent 9279513 commit b678021
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/RpcServer/RpcServer.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,17 @@ private JObject GetRawTransaction(JArray _params)
[RpcMethod]
private JObject GetStorage(JArray _params)
{
UInt160 script_hash = UInt160.Parse(_params[0].AsString());
if (!int.TryParse(_params[0].AsString(), out int id))
{
UInt160 script_hash = UInt160.Parse(_params[0].AsString());
ContractState contract = Blockchain.Singleton.View.Contracts.TryGet(script_hash);
if (contract == null) return null;
id = contract.Id;
}
byte[] key = _params[1].AsString().HexToBytes();
StorageItem item = Blockchain.Singleton.View.Storages.TryGet(new StorageKey
{
ScriptHash = script_hash,
Id = id,
Key = key
}) ?? new StorageItem();
return item.Value?.ToHexString();
Expand Down

0 comments on commit b678021

Please sign in to comment.