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
92eaa98e
Commit
92eaa98e
authored
May 19, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added js interpret mode
parent
017bbbb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
config.go
ethereum/config.go
+2
-0
ethereum.go
ethereum/ethereum.go
+18
-1
js_lib.go
ethereum/js_lib.go
+9
-2
No files found.
ethereum/config.go
View file @
92eaa98e
...
...
@@ -21,6 +21,7 @@ var LogFile string
var
DataDir
string
var
NonInteractive
bool
var
StartJsConsole
bool
var
InputFile
string
func
Init
()
{
flag
.
BoolVar
(
&
StartConsole
,
"c"
,
false
,
"debug and testing console"
)
...
...
@@ -40,6 +41,7 @@ func Init() {
flag
.
StringVar
(
&
ImportKey
,
"import"
,
""
,
"imports the given private key (hex)"
)
flag
.
IntVar
(
&
MaxPeer
,
"x"
,
5
,
"maximum desired peers"
)
flag
.
BoolVar
(
&
StartJsConsole
,
"js"
,
false
,
"exp"
)
flag
.
StringVar
(
&
InputFile
,
"e"
,
""
,
"Run javascript file"
)
flag
.
Parse
()
}
ethereum/ethereum.go
View file @
92eaa98e
...
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"io/ioutil"
"log"
"os"
"os/signal"
...
...
@@ -51,7 +52,7 @@ func main() {
var
logSys
*
log
.
Logger
flags
:=
log
.
LstdFlags
if
StartJsConsole
{
if
StartJsConsole
||
len
(
InputFile
)
>
0
{
ethutil
.
ReadConfig
(
DataDir
,
ethutil
.
LogFile
)
}
else
{
ethutil
.
ReadConfig
(
DataDir
,
ethutil
.
LogFile
|
ethutil
.
LogStd
)
...
...
@@ -157,6 +158,22 @@ save these words so you can restore your account later: %s
RegisterInterrupt
(
func
(
os
.
Signal
)
{
repl
.
Stop
()
})
}
else
if
len
(
InputFile
)
>
0
{
file
,
err
:=
os
.
Open
(
InputFile
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Fatal
(
err
)
}
content
,
err
:=
ioutil
.
ReadAll
(
file
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Fatal
(
err
)
}
re
:=
NewJSRE
(
ethereum
)
RegisterInterrupt
(
func
(
os
.
Signal
)
{
re
.
Stop
()
})
re
.
Run
(
string
(
content
))
}
if
StartRpc
{
...
...
ethereum/js_lib.go
View file @
92eaa98e
...
...
@@ -31,6 +31,8 @@ function pp(object) {
str += "\033[1m\033[30m" + object;
} else if(typeof(object) === "number") {
str += "\033[31m" + object;
} else if(typeof(object) === "function") {
str += "\033[35m[Function]";
} else {
str += object;
}
...
...
@@ -40,7 +42,12 @@ function pp(object) {
return str;
}
function prettyPrint(object) {
console.log(pp(object))
function prettyPrint(/* */) {
var args = arguments;
for(var i = 0, l = args.length; i < l; i++) {
console.log(pp(args[i]))
}
}
var print = prettyPrint;
`
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