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
90041625
Commit
90041625
authored
Mar 14, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change to getStorageAt => resolveStorage
parent
1c4e2d3b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
58 deletions
+16
-58
traceCache.js
src/trace/traceCache.js
+13
-5
traceManager.js
src/trace/traceManager.js
+3
-24
traceRetriever.js
src/trace/traceRetriever.js
+0
-29
No files found.
src/trace/traceCache.js
View file @
90041625
'use strict'
'use strict'
var
helper
=
require
(
'../helpers/util'
)
function
TraceCache
()
{
function
TraceCache
()
{
this
.
init
()
this
.
init
()
}
}
...
@@ -84,23 +86,29 @@ TraceCache.prototype.pushStoreChanges = function (index, address, key, value) {
...
@@ -84,23 +86,29 @@ TraceCache.prototype.pushStoreChanges = function (index, address, key, value) {
this
.
sstore
[
index
]
=
{
this
.
sstore
[
index
]
=
{
'address'
:
address
,
'address'
:
address
,
'key'
:
key
,
'key'
:
key
,
'value'
:
value
'value'
:
value
,
'hashedKey'
:
helper
.
sha3
(
key
)
}
}
this
.
storageChanges
.
push
(
index
)
this
.
storageChanges
.
push
(
index
)
}
}
TraceCache
.
prototype
.
rebuildStorage
=
function
(
address
,
storage
,
index
)
{
TraceCache
.
prototype
.
resolveStorage
=
function
(
index
,
address
,
storage
)
{
var
ret
=
Object
.
assign
({},
storage
)
for
(
var
k
in
this
.
storageChanges
)
{
for
(
var
k
in
this
.
storageChanges
)
{
var
changesIndex
=
this
.
storageChanges
[
k
]
var
changesIndex
=
this
.
storageChanges
[
k
]
if
(
changesIndex
>
index
)
{
if
(
changesIndex
>
index
)
{
return
storage
return
ret
}
}
var
sstore
=
this
.
sstore
[
changesIndex
]
var
sstore
=
this
.
sstore
[
changesIndex
]
if
(
sstore
.
address
===
address
&&
sstore
.
key
)
{
if
(
sstore
.
address
===
address
&&
sstore
.
key
)
{
storage
[
sstore
.
key
]
=
sstore
.
value
ret
[
sstore
.
hashedKey
]
=
{
hashedKey
:
sstore
.
hashedKey
,
key
:
sstore
.
key
,
value
:
sstore
.
value
}
}
}
}
}
return
storage
return
ret
}
}
module
.
exports
=
TraceCache
module
.
exports
=
TraceCache
src/trace/traceManager.js
View file @
90041625
...
@@ -74,30 +74,9 @@ TraceManager.prototype.getLength = function (callback) {
...
@@ -74,30 +74,9 @@ TraceManager.prototype.getLength = function (callback) {
}
}
}
}
TraceManager
.
prototype
.
getStorageAt
=
function
(
stepIndex
,
tx
,
callback
,
address
)
{
TraceManager
.
prototype
.
resolveStorage
=
function
(
index
,
address
,
storageOrigin
,
callback
)
{
var
check
=
this
.
checkRequestedStep
(
stepIndex
)
var
storage
=
this
.
traceCache
.
resolveStorage
(
index
,
address
,
storageOrigin
)
if
(
check
)
{
callback
(
null
,
storage
)
return
callback
(
check
,
null
)
}
if
(
!
address
)
{
var
stoChange
=
util
.
findLowerBoundValue
(
stepIndex
,
this
.
traceCache
.
storageChanges
)
if
(
stoChange
===
null
)
return
callback
(
'no storage found'
,
null
)
address
=
this
.
traceCache
.
sstore
[
stoChange
].
address
}
var
self
=
this
if
(
this
.
traceRetriever
.
debugStorageAtAvailable
())
{
this
.
traceRetriever
.
getStorage
(
tx
,
address
,
function
(
error
,
result
)
{
if
(
error
)
{
// TODO throws proper error when debug_storageRangeAt will be available
console
.
log
(
error
)
result
=
{}
}
var
storage
=
self
.
traceCache
.
rebuildStorage
(
address
,
result
,
stepIndex
)
callback
(
null
,
storage
)
})
}
else
{
callback
(
null
,
this
.
trace
[
stoChange
].
storage
)
}
}
}
TraceManager
.
prototype
.
getAddresses
=
function
(
callback
)
{
TraceManager
.
prototype
.
getAddresses
=
function
(
callback
)
{
...
...
src/trace/traceRetriever.js
View file @
90041625
'use strict'
'use strict'
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
util
=
require
(
'../helpers/global'
)
var
util
=
require
(
'../helpers/global'
)
function
TraceRetriever
()
{
function
TraceRetriever
()
{
...
@@ -17,32 +16,4 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) {
...
@@ -17,32 +16,4 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) {
})
})
}
}
TraceRetriever
.
prototype
.
getStorage
=
function
(
tx
,
address
,
callback
)
{
if
(
traceHelper
.
isContractCreation
(
address
))
{
callback
(
null
,
{})
}
else
{
if
(
util
.
web3
.
debug
.
storageRangeAt
)
{
var
end
=
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
var
maxSize
=
10000
// The VM gives only a tx hash
// TODO: get rid of that and use the range parameters
util
.
web3
.
debug
.
storageRangeAt
(
tx
.
blockHash
,
tx
.
transactionIndex
===
undefined
?
tx
.
hash
:
tx
.
transactionIndex
,
address
,
'0x0'
,
'0x'
+
end
,
maxSize
,
function
(
error
,
result
)
{
if
(
error
)
{
callback
(
error
)
}
else
if
(
result
.
storage
)
{
callback
(
null
,
result
.
storage
)
}
else
{
callback
(
'storage has not been provided'
)
}
})
}
else
{
callback
(
'no storageRangeAt endpoint found'
)
}
}
}
TraceRetriever
.
prototype
.
debugStorageAtAvailable
=
function
()
{
return
true
}
module
.
exports
=
TraceRetriever
module
.
exports
=
TraceRetriever
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