Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3643 from ethereum/eip86
Browse files Browse the repository at this point in the history
storageRangeAt return storage as object
  • Loading branch information
yann300 committed Apr 21, 2017
2 parents 803c644 + 30380ff commit f73c43b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libweb3jsonrpc/Debug.cpp
Expand Up @@ -124,7 +124,7 @@ Json::Value Debug::debug_storageRangeAt(string const& _blockHashOrNumber, int _t
{
Json::Value ret(Json::objectValue);
ret["complete"] = true;
ret["storage"] = Json::Value(Json::arrayValue);
ret["storage"] = Json::Value(Json::objectValue);

if (_txIndex < 0)
throw jsonrpc::JsonRpcException("Negative index");
Expand All @@ -142,21 +142,20 @@ Json::Value Debug::debug_storageRangeAt(string const& _blockHashOrNumber, int _t

// begin is inclusive
auto itBegin = storage.lower_bound(h256fromHex(_begin));

for (auto it = itBegin; it != storage.end(); ++it)
{
if (ret["storage"].size() == static_cast<unsigned>(_maxResults))
{
ret["complete"] = false;
ret["nextKey"] = toCompactHex(it->first, HexPrefix::Add, 1);
break;
}

Json::Value keyValue(Json::objectValue);
keyValue["hashedKey"] = toCompactHex(it->first, HexPrefix::Add, 1);
std::string hashedKey = toCompactHex(it->first, HexPrefix::Add, 1);
keyValue["key"] = toCompactHex(it->second.first, HexPrefix::Add, 1);
keyValue["value"] = toCompactHex(it->second.second, HexPrefix::Add, 1);

ret["storage"].append(keyValue);
ret["storage"][hashedKey] = keyValue;
}
}
catch (Exception const& _e)
Expand Down

0 comments on commit f73c43b

Please sign in to comment.