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
28948d06
Commit
28948d06
authored
Jul 15, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the repl to a new package
parent
288f1c53
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
105 additions
and
76 deletions
+105
-76
cmd.go
ethereum/cmd.go
+3
-2
flags.go
ethereum/flags.go
+2
-0
main.go
ethereum/main.go
+1
-0
javascript_runtime.go
ethereum/repl/javascript_runtime.go
+1
-1
js_lib.go
ethereum/repl/js_lib.go
+1
-1
repl.go
ethereum/repl/repl.go
+83
-0
repl_darwin.go
ethereum/repl/repl_darwin.go
+1
-1
repl_linux.go
ethereum/repl/repl_linux.go
+0
-0
repl_windows.go
ethereum/repl/repl_windows.go
+1
-1
types.go
ethereum/repl/types.go
+12
-70
No files found.
ethereum/cmd.go
View file @
28948d06
...
@@ -2,13 +2,14 @@ package main
...
@@ -2,13 +2,14 @@ package main
import
(
import
(
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/go-ethereum/ethereum/repl"
"github.com/ethereum/go-ethereum/utils"
"github.com/ethereum/go-ethereum/utils"
"io/ioutil"
"io/ioutil"
"os"
"os"
)
)
func
InitJsConsole
(
ethereum
*
eth
.
Ethereum
)
{
func
InitJsConsole
(
ethereum
*
eth
.
Ethereum
)
{
repl
:=
NewJSRepl
(
ethereum
)
repl
:=
ethrepl
.
NewJSRepl
(
ethereum
)
go
repl
.
Start
()
go
repl
.
Start
()
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
repl
.
Stop
()
repl
.
Stop
()
...
@@ -24,7 +25,7 @@ func ExecJsFile(ethereum *eth.Ethereum, InputFile string) {
...
@@ -24,7 +25,7 @@ func ExecJsFile(ethereum *eth.Ethereum, InputFile string) {
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Fatalln
(
err
)
logger
.
Fatalln
(
err
)
}
}
re
:=
NewJSRE
(
ethereum
)
re
:=
ethrepl
.
NewJSRE
(
ethereum
)
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
re
.
Stop
()
re
.
Stop
()
})
})
...
...
ethereum/flags.go
View file @
28948d06
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
var
Identifier
string
var
Identifier
string
var
KeyRing
string
var
KeyRing
string
var
DiffTool
bool
var
DiffTool
bool
var
DiffType
string
var
KeyStore
string
var
KeyStore
string
var
StartRpc
bool
var
StartRpc
bool
var
RpcPort
int
var
RpcPort
int
...
@@ -68,6 +69,7 @@ func Init() {
...
@@ -68,6 +69,7 @@ func Init() {
flag
.
StringVar
(
&
DebugFile
,
"debug"
,
""
,
"debug file (no debugging if not set)"
)
flag
.
StringVar
(
&
DebugFile
,
"debug"
,
""
,
"debug file (no debugging if not set)"
)
flag
.
IntVar
(
&
LogLevel
,
"loglevel"
,
int
(
ethlog
.
InfoLevel
),
"loglevel: 0-5: silent,error,warn,info,debug,debug detail)"
)
flag
.
IntVar
(
&
LogLevel
,
"loglevel"
,
int
(
ethlog
.
InfoLevel
),
"loglevel: 0-5: silent,error,warn,info,debug,debug detail)"
)
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
.
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 @
28948d06
...
@@ -29,6 +29,7 @@ func main() {
...
@@ -29,6 +29,7 @@ func main() {
utils
.
InitConfig
(
ConfigFile
,
Datadir
,
"ETH"
)
utils
.
InitConfig
(
ConfigFile
,
Datadir
,
"ETH"
)
ethutil
.
Config
.
Diff
=
DiffTool
ethutil
.
Config
.
Diff
=
DiffTool
ethutil
.
Config
.
DiffType
=
DiffType
utils
.
InitDataDir
(
Datadir
)
utils
.
InitDataDir
(
Datadir
)
...
...
ethereum/javascript_runtime.go
→
ethereum/
repl/
javascript_runtime.go
View file @
28948d06
package
main
package
ethrepl
import
(
import
(
"fmt"
"fmt"
...
...
ethereum/js_lib.go
→
ethereum/
repl/
js_lib.go
View file @
28948d06
package
main
package
ethrepl
const
jsLib
=
`
const
jsLib
=
`
function pp(object) {
function pp(object) {
...
...
ethereum/repl/repl.go
0 → 100644
View file @
28948d06
package
ethrepl
import
(
"bufio"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
"io"
"os"
"path"
)
var
logger
=
ethlog
.
NewLogger
(
"REPL"
)
type
Repl
interface
{
Start
()
Stop
()
}
type
JSRepl
struct
{
re
*
JSRE
prompt
string
history
*
os
.
File
running
bool
}
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
hist
,
err
:=
os
.
OpenFile
(
path
.
Join
(
ethutil
.
Config
.
ExecPath
,
"history"
),
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
if
err
!=
nil
{
panic
(
err
)
}
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
),
prompt
:
"> "
,
history
:
hist
}
}
func
(
self
*
JSRepl
)
Start
()
{
if
!
self
.
running
{
self
.
running
=
true
logger
.
Infoln
(
"init JS Console"
)
reader
:=
bufio
.
NewReader
(
self
.
history
)
for
{
line
,
err
:=
reader
.
ReadString
(
'\n'
)
if
err
!=
nil
&&
err
==
io
.
EOF
{
break
}
else
if
err
!=
nil
{
fmt
.
Println
(
"error reading history"
,
err
)
break
}
addHistory
(
line
[
:
len
(
line
)
-
1
])
}
self
.
read
()
}
}
func
(
self
*
JSRepl
)
Stop
()
{
if
self
.
running
{
self
.
running
=
false
self
.
re
.
Stop
()
logger
.
Infoln
(
"exit JS Console"
)
self
.
history
.
Close
()
}
}
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
fmt
.
Println
(
"[native] error"
,
r
)
}
}()
value
,
err
:=
self
.
re
.
Run
(
code
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
}
self
.
PrintValue
(
value
)
}
ethereum/repl_darwin.go
→
ethereum/repl
/repl
_darwin.go
View file @
28948d06
package
main
package
ethrepl
// #cgo darwin CFLAGS: -I/usr/local/opt/readline/include
// #cgo darwin CFLAGS: -I/usr/local/opt/readline/include
// #cgo darwin LDFLAGS: -L/usr/local/opt/readline/lib
// #cgo darwin LDFLAGS: -L/usr/local/opt/readline/lib
...
...
ethereum/repl_linux.go
→
ethereum/repl
/repl
_linux.go
View file @
28948d06
File moved
ethereum/repl_windows.go
→
ethereum/repl
/repl
_windows.go
View file @
28948d06
package
main
package
ethrepl
import
(
import
(
"bufio"
"bufio"
...
...
ethereum/repl.go
→
ethereum/repl
/types
.go
View file @
28948d06
package
main
package
ethrepl
import
(
import
(
"bufio"
"fmt"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/otto"
"github.com/obscuren/otto"
"io"
"os"
"path"
)
)
type
Repl
interface
{
type
JSStateObject
struct
{
Start
()
*
ethpub
.
PStateObject
Stop
()
eth
*
JSEthereum
}
type
JSRepl
struct
{
re
*
JSRE
prompt
string
history
*
os
.
File
running
bool
}
func
NewJSRepl
(
ethereum
*
eth
.
Ethereum
)
*
JSRepl
{
hist
,
err
:=
os
.
OpenFile
(
path
.
Join
(
ethutil
.
Config
.
ExecPath
,
"history"
),
os
.
O_RDWR
|
os
.
O_CREATE
,
os
.
ModePerm
)
if
err
!=
nil
{
panic
(
err
)
}
return
&
JSRepl
{
re
:
NewJSRE
(
ethereum
),
prompt
:
"> "
,
history
:
hist
}
}
func
(
self
*
JSRepl
)
Start
()
{
if
!
self
.
running
{
self
.
running
=
true
logger
.
Infoln
(
"init JS Console"
)
reader
:=
bufio
.
NewReader
(
self
.
history
)
for
{
line
,
err
:=
reader
.
ReadString
(
'\n'
)
if
err
!=
nil
&&
err
==
io
.
EOF
{
break
}
else
if
err
!=
nil
{
fmt
.
Println
(
"error reading history"
,
err
)
break
}
addHistory
(
line
[
:
len
(
line
)
-
1
])
}
self
.
read
()
}
}
func
(
self
*
JSRepl
)
Stop
()
{
if
self
.
running
{
self
.
running
=
false
self
.
re
.
Stop
()
logger
.
Infoln
(
"exit JS Console"
)
self
.
history
.
Close
()
}
}
}
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
func
(
self
*
JSStateObject
)
EachStorage
(
call
otto
.
FunctionCall
)
otto
.
Value
{
defer
func
()
{
cb
:=
call
.
Argument
(
0
)
if
r
:=
recover
();
r
!=
nil
{
self
.
PStateObject
.
EachStorage
(
func
(
key
string
,
value
*
ethutil
.
Value
)
{
fmt
.
Println
(
"[native] error"
,
r
)
value
.
Decode
()
}
}()
value
,
err
:=
self
.
re
.
Run
(
code
)
cb
.
Call
(
self
.
eth
.
toVal
(
self
),
self
.
eth
.
toVal
(
key
),
self
.
eth
.
toVal
(
ethutil
.
Bytes2Hex
(
value
.
Bytes
())))
if
err
!=
nil
{
})
fmt
.
Println
(
err
)
return
}
self
.
PrintValue
(
value
)
return
otto
.
UndefinedValue
(
)
}
}
// The JSEthereum object attempts to wrap the PEthereum object and returns
// The JSEthereum object attempts to wrap the PEthereum object and returns
...
@@ -110,7 +52,7 @@ func (self *JSEthereum) GetKey() otto.Value {
...
@@ -110,7 +52,7 @@ func (self *JSEthereum) GetKey() otto.Value {
}
}
func
(
self
*
JSEthereum
)
GetStateObject
(
addr
string
)
otto
.
Value
{
func
(
self
*
JSEthereum
)
GetStateObject
(
addr
string
)
otto
.
Value
{
return
self
.
toVal
(
self
.
PEthereum
.
GetStateObject
(
addr
)
)
return
self
.
toVal
(
&
JSStateObject
{
self
.
PEthereum
.
GetStateObject
(
addr
),
self
}
)
}
}
func
(
self
*
JSEthereum
)
GetStateKeyVals
(
addr
string
)
otto
.
Value
{
func
(
self
*
JSEthereum
)
GetStateKeyVals
(
addr
string
)
otto
.
Value
{
...
...
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