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
f3a8cf40
Commit
f3a8cf40
authored
Apr 11, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check key && hashedkey
parent
c0dcb5a7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
9 deletions
+32
-9
storageResolver.js
src/storage/storageResolver.js
+12
-8
storageViewer.js
src/storage/storageViewer.js
+15
-1
traceCache.js
src/trace/traceCache.js
+5
-0
No files found.
src/storage/storageResolver.js
View file @
f3a8cf40
'use strict'
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
helper
=
require
(
'../helpers/util'
)
var
util
=
require
(
'../helpers/global'
)
class
StorageResolver
{
...
...
@@ -19,7 +18,7 @@ class StorageResolver {
* @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value}
*/
storageRange
(
tx
,
stepIndex
,
callback
)
{
storageRangeInternal
(
this
,
'0x0'
,
tx
,
stepIndex
,
true
,
callback
)
storageRangeInternal
(
this
,
'0x0
000000000000000000000000000000000000000000000000000000000000000
'
,
tx
,
stepIndex
,
true
,
callback
)
}
/**
...
...
@@ -31,12 +30,11 @@ class StorageResolver {
* @param {Function} - callback - {key, hashedKey, value} -
*/
storageSlot
(
slot
,
tx
,
stepIndex
,
callback
)
{
var
hashed
=
helper
.
sha3_32
(
slot
)
storageRangeInternal
(
this
,
hashed
,
tx
,
stepIndex
,
false
,
function
(
error
,
storage
)
{
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
false
,
function
(
error
,
storage
)
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
storage
[
hashed
]
!==
undefined
?
storage
[
hashed
]
:
null
)
callback
(
null
,
storage
[
slot
]
!==
undefined
?
storage
[
slot
]
:
null
)
}
})
}
...
...
@@ -71,15 +69,21 @@ function storageRangeInternal (self, slotKey, tx, stepIndex, fullStorage, callba
return
callback
(
null
,
storageChanges
)
}
var
cached
=
fromCache
(
self
,
address
)
if
(
cached
&&
cached
[
slotKey
])
{
// we have the current slot in the cache and maybe the next 1000...
return
callback
(
null
,
Object
.
assign
(
cached
,
storageChanges
))
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
))
}
storageRangeWeb3Call
(
tx
,
address
,
slotKey
,
self
.
maxSize
,
(
error
,
storage
,
complete
)
=>
{
if
(
error
)
{
return
callback
(
error
)
}
if
(
!
storage
[
slotKey
])
{
storage
[
slotKey
]
=
{
key
:
slotKey
,
value
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
}
}
toCache
(
self
,
address
,
storage
)
if
(
slotKey
===
'0x0'
&&
Object
.
keys
(
storage
).
length
<
self
.
maxSize
)
{
if
(
slotKey
===
'0x0
000000000000000000000000000000000000000000000000000000000000000
'
&&
Object
.
keys
(
storage
).
length
<
self
.
maxSize
)
{
self
.
storageByAddress
[
address
].
complete
=
true
}
callback
(
null
,
Object
.
assign
(
storage
,
storageChanges
))
...
...
src/storage/storageViewer.js
View file @
f3a8cf40
'use strict'
var
helper
=
require
(
'../helpers/util'
)
class
StorageViewer
{
constructor
(
_context
,
_storageResolver
)
{
...
...
@@ -22,7 +23,20 @@ class StorageViewer {
* @param {Function} - callback - {key, hashedKey, value} -
*/
storageSlot
(
slot
,
callback
)
{
this
.
storageResolver
.
storageSlot
(
slot
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
callback
)
this
.
storageResolver
.
storageSlot
(
slot
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
(
error
,
result
)
=>
{
if
(
error
||
!
result
||
!
result
[
slot
])
{
var
hashed
=
helper
.
sha3_32
(
slot
)
this
.
storageResolver
.
storageSlot
(
hashed
,
this
.
context
.
tx
,
this
.
context
.
stepIndex
,
(
error
,
result
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
callback
(
null
,
result
)
}
})
}
else
{
return
callback
(
null
,
result
)
}
})
}
/**
...
...
src/trace/traceCache.js
View file @
f3a8cf40
...
...
@@ -106,6 +106,11 @@ TraceCache.prototype.accumulateStorageChanges = function (index, address, storag
key
:
sstore
.
key
,
value
:
sstore
.
value
}
ret
[
sstore
.
key
]
=
{
hashedKey
:
sstore
.
hashedKey
,
key
:
sstore
.
key
,
value
:
sstore
.
value
}
}
}
return
ret
...
...
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