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
017bbbb5
Commit
017bbbb5
authored
May 19, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved REPL output
parent
16421106
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
12 deletions
+89
-12
ethereum.go
ethereum/ethereum.go
+15
-9
javascript_console.go
ethereum/javascript_console.go
+9
-1
js_lib.go
ethereum/js_lib.go
+46
-0
repl_darwin.go
ethereum/repl_darwin.go
+15
-2
repl_windows.go
ethereum/repl_windows.go
+4
-0
No files found.
ethereum/ethereum.go
View file @
017bbbb5
...
@@ -15,16 +15,15 @@ import (
...
@@ -15,16 +15,15 @@ import (
const
Debug
=
true
const
Debug
=
true
// Register interrupt handlers so we can stop the ethereum
func
RegisterInterrupt
(
cb
func
(
os
.
Signal
))
{
func
RegisterInterrupts
(
s
*
eth
.
Ethereum
)
{
// Buffered chan of one is enough
c
:=
make
(
chan
os
.
Signal
,
1
)
// Notify about interrupts for now
signal
.
Notify
(
c
,
os
.
Interrupt
)
go
func
()
{
go
func
()
{
// Buffered chan of one is enough
c
:=
make
(
chan
os
.
Signal
,
1
)
// Notify about interrupts for now
signal
.
Notify
(
c
,
os
.
Interrupt
)
for
sig
:=
range
c
{
for
sig
:=
range
c
{
fmt
.
Printf
(
"Shutting down (%v) ...
\n
"
,
sig
)
cb
(
sig
)
s
.
Stop
()
}
}
}()
}()
}
}
...
@@ -154,13 +153,20 @@ save these words so you can restore your account later: %s
...
@@ -154,13 +153,20 @@ save these words so you can restore your account later: %s
repl
:=
NewJSRepl
(
ethereum
)
repl
:=
NewJSRepl
(
ethereum
)
go
repl
.
Start
()
go
repl
.
Start
()
RegisterInterrupt
(
func
(
os
.
Signal
)
{
repl
.
Stop
()
})
}
}
if
StartRpc
{
if
StartRpc
{
utils
.
DoRpc
(
ethereum
,
RpcPort
)
utils
.
DoRpc
(
ethereum
,
RpcPort
)
}
}
RegisterInterrupts
(
ethereum
)
RegisterInterrupt
(
func
(
sig
os
.
Signal
)
{
fmt
.
Printf
(
"Shutting down (%v) ...
\n
"
,
sig
)
ethereum
.
Stop
()
})
ethereum
.
Start
(
UseSeed
)
ethereum
.
Start
(
UseSeed
)
...
...
ethereum/javascript_console.go
View file @
017bbbb5
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
type
Repl
interface
{
type
Repl
interface
{
Start
()
Start
()
Stop
()
}
}
type
JSRE
struct
{
type
JSRE
struct
{
...
@@ -36,6 +37,9 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
...
@@ -36,6 +37,9 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
make
(
map
[
string
][]
otto
.
Value
),
make
(
map
[
string
][]
otto
.
Value
),
}
}
// Init the JS lib
re
.
vm
.
Run
(
jsLib
)
// We have to make sure that, whoever calls this, calls "Stop"
// We have to make sure that, whoever calls this, calls "Stop"
go
re
.
mainLoop
()
go
re
.
mainLoop
()
...
@@ -113,6 +117,10 @@ func (self *JSRepl) Start() {
...
@@ -113,6 +117,10 @@ func (self *JSRepl) Start() {
self
.
read
()
self
.
read
()
}
}
func
(
self
*
JSRepl
)
Stop
()
{
self
.
re
.
Stop
()
}
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
defer
func
()
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
if
r
:=
recover
();
r
!=
nil
{
...
@@ -126,7 +134,7 @@ func (self *JSRepl) parseInput(code string) {
...
@@ -126,7 +134,7 @@ func (self *JSRepl) parseInput(code string) {
return
return
}
}
fmt
.
Println
(
value
)
self
.
PrintValue
(
value
)
}
}
// The JSEthereum object attempts to wrap the PEthereum object and returns
// The JSEthereum object attempts to wrap the PEthereum object and returns
...
...
ethereum/js_lib.go
0 → 100644
View file @
017bbbb5
package
main
const
jsLib
=
`
function pp(object) {
var str = "";
if(object instanceof Array) {
str += "[ ";
for(var i = 0, l = object.length; i < l; i++) {
str += pp(object[i]);
if(i < l-1) {
str += ", ";
}
}
str += " ]";
} else if(typeof(object) === "object") {
str += "{ ";
var last = Object.keys(object).sort().pop()
for(var k in object) {
str += k + ": " + pp(object[k]);
if(k !== last) {
str += ", ";
}
}
str += " }";
} else if(typeof(object) === "string") {
str += "\033[32m'" + object + "'";
} else if(typeof(object) === "undefined") {
str += "\033[1m\033[30m" + object;
} else if(typeof(object) === "number") {
str += "\033[31m" + object;
} else {
str += object;
}
str += "\033[0m";
return str;
}
function prettyPrint(object) {
console.log(pp(object))
}
`
ethereum/repl_darwin.go
View file @
017bbbb5
...
@@ -8,6 +8,7 @@ package main
...
@@ -8,6 +8,7 @@ package main
import
"C"
import
"C"
import
(
import
(
"github.com/robertkrimen/otto"
"strings"
"strings"
"unsafe"
"unsafe"
)
)
...
@@ -63,18 +64,30 @@ L:
...
@@ -63,18 +64,30 @@ L:
for
{
for
{
switch
result
:=
readLine
(
&
self
.
prompt
);
true
{
switch
result
:=
readLine
(
&
self
.
prompt
);
true
{
case
result
==
nil
:
case
result
==
nil
:
break
L
//exit loop
break
L
case
*
result
!=
""
:
//ignore blank lines
case
*
result
!=
""
:
str
+=
*
result
+
"
\n
"
str
+=
*
result
+
"
\n
"
self
.
setIndent
()
self
.
setIndent
()
if
indentCount
<=
0
{
if
indentCount
<=
0
{
if
*
result
==
"exit"
{
self
.
Stop
()
break
L
}
addHistory
(
str
)
//allow user to recall this line
addHistory
(
str
)
//allow user to recall this line
self
.
parseInput
(
str
)
self
.
parseInput
(
str
)
str
=
""
}
}
}
}
}
}
}
}
func
(
self
*
JSRepl
)
PrintValue
(
value
otto
.
Value
)
{
method
,
_
:=
self
.
re
.
vm
.
Get
(
"prettyPrint"
)
method
.
Call
(
method
,
value
)
}
ethereum/repl_windows.go
View file @
017bbbb5
...
@@ -18,3 +18,7 @@ func (self *JSRepl) read() {
...
@@ -18,3 +18,7 @@ func (self *JSRepl) read() {
}
}
}
}
}
}
func
(
self
*
JSRepl
)
PrintValue
(
value
otto
.
Value
)
{
fmt
.
Println
(
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