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
852d1ee3
Commit
852d1ee3
authored
Aug 06, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
State dumps
parent
3c319f93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
6 deletions
+76
-6
flags.go
ethereum/flags.go
+9
-1
main.go
ethereum/main.go
+30
-1
javascript_runtime.go
ethereum/repl/javascript_runtime.go
+37
-4
No files found.
ethereum/flags.go
View file @
852d1ee3
...
@@ -3,10 +3,11 @@ package main
...
@@ -3,10 +3,11 @@ package main
import
(
import
(
"flag"
"flag"
"fmt"
"fmt"
"github.com/ethereum/eth-go/ethlog"
"os"
"os"
"os/user"
"os/user"
"path"
"path"
"github.com/ethereum/eth-go/ethlog"
)
)
var
Identifier
string
var
Identifier
string
...
@@ -31,6 +32,9 @@ var LogFile string
...
@@ -31,6 +32,9 @@ var LogFile string
var
ConfigFile
string
var
ConfigFile
string
var
DebugFile
string
var
DebugFile
string
var
LogLevel
int
var
LogLevel
int
var
Dump
bool
var
DumpHash
string
var
DumpNumber
int
// flags specific to cli client
// flags specific to cli client
var
StartMining
bool
var
StartMining
bool
...
@@ -71,6 +75,10 @@ func Init() {
...
@@ -71,6 +75,10 @@ func Init() {
flag
.
BoolVar
(
&
DiffTool
,
"difftool"
,
false
,
"creates output for diff'ing. Sets LogLevel=0"
)
flag
.
BoolVar
(
&
DiffTool
,
"difftool"
,
false
,
"creates output for diff'ing. Sets LogLevel=0"
)
flag
.
StringVar
(
&
DiffType
,
"diff"
,
"all"
,
"sets the level of diff output [vm, all]. Has no effect if difftool=false"
)
flag
.
StringVar
(
&
DiffType
,
"diff"
,
"all"
,
"sets the level of diff output [vm, all]. Has no effect if difftool=false"
)
flag
.
BoolVar
(
&
Dump
,
"dump"
,
false
,
"output the ethereum state in JSON format. Sub args [number, hash]"
)
flag
.
StringVar
(
&
DumpHash
,
"hash"
,
""
,
"specify arg in hex"
)
flag
.
IntVar
(
&
DumpNumber
,
"number"
,
-
1
,
"specify arg in number"
)
flag
.
BoolVar
(
&
StartMining
,
"mine"
,
false
,
"start dagger mining"
)
flag
.
BoolVar
(
&
StartMining
,
"mine"
,
false
,
"start dagger mining"
)
flag
.
BoolVar
(
&
StartJsConsole
,
"js"
,
false
,
"launches javascript console"
)
flag
.
BoolVar
(
&
StartJsConsole
,
"js"
,
false
,
"launches javascript console"
)
...
...
ethereum/main.go
View file @
852d1ee3
package
main
package
main
import
(
import
(
"fmt"
"os"
"runtime"
"runtime"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/ethereum/go-ethereum/utils"
...
@@ -24,7 +27,7 @@ func main() {
...
@@ -24,7 +27,7 @@ func main() {
Init
()
// parsing command line
Init
()
// parsing command line
// If the difftool option is selected ignore all other log output
// If the difftool option is selected ignore all other log output
if
DiffTool
{
if
DiffTool
||
Dump
{
LogLevel
=
0
LogLevel
=
0
}
}
...
@@ -47,6 +50,32 @@ func main() {
...
@@ -47,6 +50,32 @@ func main() {
ethereum
:=
utils
.
NewEthereum
(
db
,
clientIdentity
,
keyManager
,
UseUPnP
,
OutboundPort
,
MaxPeer
)
ethereum
:=
utils
.
NewEthereum
(
db
,
clientIdentity
,
keyManager
,
UseUPnP
,
OutboundPort
,
MaxPeer
)
if
Dump
{
var
block
*
ethchain
.
Block
if
len
(
DumpHash
)
==
0
&&
DumpNumber
==
-
1
{
block
=
ethereum
.
BlockChain
()
.
CurrentBlock
}
else
if
len
(
DumpHash
)
>
0
{
block
=
ethereum
.
BlockChain
()
.
GetBlock
(
ethutil
.
Hex2Bytes
(
DumpHash
))
}
else
{
block
=
ethereum
.
BlockChain
()
.
GetBlockByNumber
(
uint64
(
DumpNumber
))
}
if
block
==
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"block not found"
)
// We want to output valid JSON
fmt
.
Println
(
"{}"
)
os
.
Exit
(
1
)
}
// Leave the Println. This needs clean output for piping
fmt
.
Println
(
block
.
State
()
.
Dump
())
os
.
Exit
(
0
)
}
if
ShowGenesis
{
if
ShowGenesis
{
utils
.
ShowGenesis
(
ethereum
)
utils
.
ShowGenesis
(
ethereum
)
}
}
...
...
ethereum/repl/javascript_runtime.go
View file @
852d1ee3
...
@@ -2,6 +2,11 @@ package ethrepl
...
@@ -2,6 +2,11 @@ package ethrepl
import
(
import
(
"fmt"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethlog"
...
@@ -11,10 +16,6 @@ import (
...
@@ -11,10 +16,6 @@ import (
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/ethereum/go-ethereum/utils"
"github.com/obscuren/otto"
"github.com/obscuren/otto"
"io/ioutil"
"os"
"path"
"path/filepath"
)
)
var
jsrelogger
=
ethlog
.
NewLogger
(
"JSRE"
)
var
jsrelogger
=
ethlog
.
NewLogger
(
"JSRE"
)
...
@@ -147,12 +148,44 @@ func (self *JSRE) initStdFuncs() {
...
@@ -147,12 +148,44 @@ func (self *JSRE) initStdFuncs() {
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"stopMining"
,
self
.
stopMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
eth
.
Set
(
"startMining"
,
self
.
startMining
)
eth
.
Set
(
"execBlock"
,
self
.
execBlock
)
eth
.
Set
(
"execBlock"
,
self
.
execBlock
)
eth
.
Set
(
"dump"
,
self
.
dump
)
}
}
/*
/*
* The following methods are natively implemented javascript functions
* The following methods are natively implemented javascript functions
*/
*/
func
(
self
*
JSRE
)
dump
(
call
otto
.
FunctionCall
)
otto
.
Value
{
var
state
*
ethstate
.
State
if
len
(
call
.
ArgumentList
)
>
0
{
var
block
*
ethchain
.
Block
if
call
.
Argument
(
0
)
.
IsNumber
()
{
num
,
_
:=
call
.
Argument
(
0
)
.
ToInteger
()
block
=
self
.
ethereum
.
BlockChain
()
.
GetBlockByNumber
(
uint64
(
num
))
}
else
if
call
.
Argument
(
0
)
.
IsString
()
{
hash
,
_
:=
call
.
Argument
(
0
)
.
ToString
()
block
=
self
.
ethereum
.
BlockChain
()
.
GetBlock
(
ethutil
.
Hex2Bytes
(
hash
))
}
else
{
fmt
.
Println
(
"invalid argument for dump. Either hex string or number"
)
}
if
block
==
nil
{
fmt
.
Println
(
"block not found"
)
return
otto
.
UndefinedValue
()
}
state
=
block
.
State
()
}
else
{
state
=
self
.
ethereum
.
StateManager
()
.
CurrentState
()
}
fmt
.
Println
(
state
.
Dump
())
return
otto
.
UndefinedValue
()
}
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
vm
.
ToValue
(
utils
.
StopMining
(
self
.
ethereum
))
v
,
_
:=
self
.
vm
.
ToValue
(
utils
.
StopMining
(
self
.
ethereum
))
return
v
return
v
...
...
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