Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
6c670eff
Commit
6c670eff
authored
Mar 31, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: manually convert errors to strings on the trace API (json cannot)
parent
798e4fb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
api.go
eth/api.go
+11
-11
No files found.
eth/api.go
View file @
6c670eff
...
@@ -1513,9 +1513,9 @@ func NewPrivateDebugAPI(eth *Ethereum) *PrivateDebugAPI {
...
@@ -1513,9 +1513,9 @@ func NewPrivateDebugAPI(eth *Ethereum) *PrivateDebugAPI {
// BlockTraceResults is the returned value when replaying a block to check for
// BlockTraceResults is the returned value when replaying a block to check for
// consensus results and full VM trace logs for all included transactions.
// consensus results and full VM trace logs for all included transactions.
type
BlockTraceResult
struct
{
type
BlockTraceResult
struct
{
Validated
bool
`json:
"validated"`
Validated
bool
`json:"validated"`
StructLogs
[]
structLogRes
`json:"structLogs"`
StructLogs
[]
structLogRes
`json:"structLogs"`
Error
error
`json:"error"`
Error
string
`json:"error"`
}
}
// TraceBlock processes the given block's RLP but does not import the block in to
// TraceBlock processes the given block's RLP but does not import the block in to
...
@@ -1524,14 +1524,14 @@ func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config vm.Config) BlockT
...
@@ -1524,14 +1524,14 @@ func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config vm.Config) BlockT
var
block
types
.
Block
var
block
types
.
Block
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
blockRlp
),
&
block
)
err
:=
rlp
.
Decode
(
bytes
.
NewReader
(
blockRlp
),
&
block
)
if
err
!=
nil
{
if
err
!=
nil
{
return
BlockTraceResult
{
Error
:
fmt
.
Error
f
(
"could not decode block: %v"
,
err
)}
return
BlockTraceResult
{
Error
:
fmt
.
Sprint
f
(
"could not decode block: %v"
,
err
)}
}
}
validated
,
logs
,
err
:=
api
.
traceBlock
(
&
block
,
config
)
validated
,
logs
,
err
:=
api
.
traceBlock
(
&
block
,
config
)
return
BlockTraceResult
{
return
BlockTraceResult
{
Validated
:
validated
,
Validated
:
validated
,
StructLogs
:
formatLogs
(
logs
),
StructLogs
:
formatLogs
(
logs
),
Error
:
err
,
Error
:
err
.
Error
()
,
}
}
}
}
...
@@ -1540,7 +1540,7 @@ func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config vm.Config) BlockT
...
@@ -1540,7 +1540,7 @@ func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config vm.Config) BlockT
func
(
api
*
PrivateDebugAPI
)
TraceBlockFromFile
(
file
string
,
config
vm
.
Config
)
BlockTraceResult
{
func
(
api
*
PrivateDebugAPI
)
TraceBlockFromFile
(
file
string
,
config
vm
.
Config
)
BlockTraceResult
{
blockRlp
,
err
:=
ioutil
.
ReadFile
(
file
)
blockRlp
,
err
:=
ioutil
.
ReadFile
(
file
)
if
err
!=
nil
{
if
err
!=
nil
{
return
BlockTraceResult
{
Error
:
fmt
.
Error
f
(
"could not read file: %v"
,
err
)}
return
BlockTraceResult
{
Error
:
fmt
.
Sprint
f
(
"could not read file: %v"
,
err
)}
}
}
return
api
.
TraceBlock
(
blockRlp
,
config
)
return
api
.
TraceBlock
(
blockRlp
,
config
)
}
}
...
@@ -1550,14 +1550,14 @@ func (api *PrivateDebugAPI) TraceBlockByNumber(number uint64, config vm.Config)
...
@@ -1550,14 +1550,14 @@ func (api *PrivateDebugAPI) TraceBlockByNumber(number uint64, config vm.Config)
// Fetch the block that we aim to reprocess
// Fetch the block that we aim to reprocess
block
:=
api
.
eth
.
BlockChain
()
.
GetBlockByNumber
(
number
)
block
:=
api
.
eth
.
BlockChain
()
.
GetBlockByNumber
(
number
)
if
block
==
nil
{
if
block
==
nil
{
return
BlockTraceResult
{
Error
:
fmt
.
Error
f
(
"block #%d not found"
,
number
)}
return
BlockTraceResult
{
Error
:
fmt
.
Sprint
f
(
"block #%d not found"
,
number
)}
}
}
validated
,
logs
,
err
:=
api
.
traceBlock
(
block
,
config
)
validated
,
logs
,
err
:=
api
.
traceBlock
(
block
,
config
)
return
BlockTraceResult
{
return
BlockTraceResult
{
Validated
:
validated
,
Validated
:
validated
,
StructLogs
:
formatLogs
(
logs
),
StructLogs
:
formatLogs
(
logs
),
Error
:
err
,
Error
:
err
.
Error
()
,
}
}
}
}
...
@@ -1566,14 +1566,14 @@ func (api *PrivateDebugAPI) TraceBlockByHash(hash common.Hash, config vm.Config)
...
@@ -1566,14 +1566,14 @@ func (api *PrivateDebugAPI) TraceBlockByHash(hash common.Hash, config vm.Config)
// Fetch the block that we aim to reprocess
// Fetch the block that we aim to reprocess
block
:=
api
.
eth
.
BlockChain
()
.
GetBlock
(
hash
)
block
:=
api
.
eth
.
BlockChain
()
.
GetBlock
(
hash
)
if
block
==
nil
{
if
block
==
nil
{
return
BlockTraceResult
{
Error
:
fmt
.
Error
f
(
"block #%x not found"
,
hash
)}
return
BlockTraceResult
{
Error
:
fmt
.
Sprint
f
(
"block #%x not found"
,
hash
)}
}
}
validated
,
logs
,
err
:=
api
.
traceBlock
(
block
,
config
)
validated
,
logs
,
err
:=
api
.
traceBlock
(
block
,
config
)
return
BlockTraceResult
{
return
BlockTraceResult
{
Validated
:
validated
,
Validated
:
validated
,
StructLogs
:
formatLogs
(
logs
),
StructLogs
:
formatLogs
(
logs
),
Error
:
err
,
Error
:
err
.
Error
()
,
}
}
}
}
...
@@ -1641,7 +1641,7 @@ type structLogRes struct {
...
@@ -1641,7 +1641,7 @@ type structLogRes struct {
Gas
*
big
.
Int
`json:"gas"`
Gas
*
big
.
Int
`json:"gas"`
GasCost
*
big
.
Int
`json:"gasCost"`
GasCost
*
big
.
Int
`json:"gasCost"`
Depth
int
`json:"depth"`
Depth
int
`json:"depth"`
Error
error
`json:"error"`
Error
string
`json:"error"`
Stack
[]
string
`json:"stack"`
Stack
[]
string
`json:"stack"`
Memory
[]
string
`json:"memory"`
Memory
[]
string
`json:"memory"`
Storage
map
[
string
]
string
`json:"storage"`
Storage
map
[
string
]
string
`json:"storage"`
...
@@ -1666,7 +1666,7 @@ func formatLogs(structLogs []vm.StructLog) []structLogRes {
...
@@ -1666,7 +1666,7 @@ func formatLogs(structLogs []vm.StructLog) []structLogRes {
Gas
:
trace
.
Gas
,
Gas
:
trace
.
Gas
,
GasCost
:
trace
.
GasCost
,
GasCost
:
trace
.
GasCost
,
Depth
:
trace
.
Depth
,
Depth
:
trace
.
Depth
,
Error
:
trace
.
Err
,
Error
:
trace
.
Err
.
Error
()
,
Stack
:
make
([]
string
,
len
(
trace
.
Stack
)),
Stack
:
make
([]
string
,
len
(
trace
.
Stack
)),
Storage
:
make
(
map
[
string
]
string
),
Storage
:
make
(
map
[
string
]
string
),
}
}
...
...
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