Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
31c1a5f0
Commit
31c1a5f0
authored
Apr 18, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move storageRanges to the viewer
parent
427801ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
storageResolver.js
src/storage/storageResolver.js
+7
-12
storageViewer.js
src/storage/storageViewer.js
+12
-3
No files found.
src/storage/storageResolver.js
View file @
31c1a5f0
...
...
@@ -14,12 +14,11 @@ class StorageResolver {
*
* @param {Object} - tx - transaction
* @param {Int} - stepIndex - Index of the stop in the vm trace
* @param {Object} - storageChanges - contains storage changes by hashde key
* @param {String} - address - lookup address
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
*/
storageRange
(
tx
,
stepIndex
,
storageChanges
,
address
,
callback
)
{
storageRangeInternal
(
this
,
zeroSlot
,
tx
,
stepIndex
,
true
,
storageChanges
,
address
,
callback
)
storageRange
(
tx
,
stepIndex
,
address
,
callback
)
{
storageRangeInternal
(
this
,
zeroSlot
,
tx
,
stepIndex
,
address
,
callback
)
}
/**
...
...
@@ -28,12 +27,11 @@ class StorageResolver {
* @param {String} - slot - slot key
* @param {Object} - tx - transaction
* @param {Int} - stepIndex - Index of the stop in the vm trace
* @param {Object} - storageChanges - contains storage changes by hashde key
* @param {String} - address - lookup address
* @param {Function} - callback - {key, hashedKey, value} -
*/
storageSlot
(
slot
,
tx
,
stepIndex
,
storageChanges
,
address
,
callback
)
{
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
false
,
storageChanges
,
address
,
function
(
error
,
storage
)
{
storageSlot
(
slot
,
tx
,
stepIndex
,
address
,
callback
)
{
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
address
,
function
(
error
,
storage
)
{
if
(
error
)
{
callback
(
error
)
}
else
{
...
...
@@ -59,13 +57,10 @@ class StorageResolver {
* even if the next 1000 items are not in the cache.
* - If @arg slot is not cached, the corresponding value will be resolved and the next 1000 slots.
*/
function
storageRangeInternal
(
self
,
slotKey
,
tx
,
stepIndex
,
fullStorage
,
storageChanges
,
address
,
callback
)
{
if
(
!
fullStorage
&&
storageChanges
[
slotKey
])
{
// don't need the full storage just returning the value from the storageChanges
return
callback
(
null
,
storageChanges
)
}
function
storageRangeInternal
(
self
,
slotKey
,
tx
,
stepIndex
,
address
,
callback
)
{
var
cached
=
fromCache
(
self
,
address
)
if
(
cached
&&
cached
.
storage
[
slotKey
])
{
// we have the current slot in the cache and maybe the next 1000...
return
callback
(
null
,
Object
.
assign
({},
cached
.
storage
,
storageChanges
)
)
return
callback
(
null
,
cached
.
storage
)
}
storageRangeWeb3Call
(
tx
,
address
,
slotKey
,
self
.
maxSize
,
(
error
,
storage
,
complete
)
=>
{
if
(
error
)
{
...
...
@@ -81,7 +76,7 @@ function storageRangeInternal (self, slotKey, tx, stepIndex, fullStorage, storag
if
(
slotKey
===
zeroSlot
&&
Object
.
keys
(
storage
).
length
<
self
.
maxSize
)
{
// only working if keys are sorted !!
self
.
storageByAddress
[
address
].
complete
=
true
}
callback
(
null
,
Object
.
assign
(
storage
,
storageChanges
)
)
callback
(
null
,
storage
)
})
}
...
...
src/storage/storageViewer.js
View file @
31c1a5f0
...
...
@@ -21,7 +21,13 @@ class StorageViewer {
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
*/
storageRange
(
callback
)
{
this
.
storageResolver
.
storageRange
(
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
this
.
storageChanges
,
this
.
context
.
address
,
callback
)
this
.
storageResolver
.
storageRange
(
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
this
.
context
.
address
,
(
error
,
storage
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
Object
.
assign
({},
storage
,
this
.
storageChanges
))
}
})
}
/**
...
...
@@ -31,11 +37,14 @@ class StorageViewer {
*/
storageSlot
(
slot
,
callback
)
{
var
hashed
=
helper
.
sha3_256
(
slot
)
this
.
storageResolver
.
storageSlot
(
hashed
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
this
.
storageChanges
,
this
.
context
.
address
,
(
error
,
result
)
=>
{
if
(
this
.
storageChanges
[
hashed
])
{
return
callback
(
null
,
this
.
storageChanges
[
hashed
])
}
this
.
storageResolver
.
storageSlot
(
hashed
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
this
.
context
.
address
,
(
error
,
storage
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
result
)
callback
(
null
,
storage
[
hashed
]
!==
undefined
?
storage
[
hashed
]
:
null
)
}
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment