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
4d5a890b
Commit
4d5a890b
authored
Jul 21, 2014
by
zelig
Browse files
Options
Browse Files
Download
Plain Diff
merge upstream
parents
75a7a4c9
f702e274
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
257 additions
and
117 deletions
+257
-117
README.md
README.md
+1
-1
debugger.qml
ethereal/assets/debugger/debugger.qml
+1
-1
wallet.qml
ethereal/assets/qml/wallet.qml
+48
-22
samplecoin
ethereal/assets/samplecoin
+0
-1
debugger.go
ethereal/debugger.go
+3
-0
flags.go
ethereal/flags.go
+1
-1
gui.go
ethereal/gui.go
+55
-9
main.go
ethereal/main.go
+1
-1
cmd.go
ethereum/cmd.go
+3
-2
flags.go
ethereum/flags.go
+2
-0
main.go
ethereum/main.go
+2
-1
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
cmd.go
utils/cmd.go
+41
-4
No files found.
README.md
View file @
4d5a890b
...
...
@@ -5,7 +5,7 @@ Ethereum
Ethereum Go Client © 2014 Jeffrey Wilcke.
Current state: Proof of Concept 0.5.1
6
.
Current state: Proof of Concept 0.5.1
7
.
For the development package please see the
[
eth-go package
](
https://github.com/ethereum/eth-go
)
.
...
...
ethereal/assets/debugger/debugger.qml
View file @
4d5a890b
...
...
@@ -86,7 +86,7 @@ ApplicationWindow {
TableView
{
id
:
asmTableView
width
:
200
TableViewColumn
{
role
:
"value"
;
title
:
""
;
width
:
200
}
TableViewColumn
{
role
:
"value"
;
title
:
""
;
width
:
asmTableView
.
width
-
2
}
model
:
asmModel
}
...
...
ethereal/assets/qml/wallet.qml
View file @
4d5a890b
...
...
@@ -419,30 +419,54 @@ ApplicationWindow {
}
}
Label
{
y
:
7
anchors.right
:
peerImage
.
left
anchors.rightMargin
:
5
id
:
peerLabel
font.pixelSize
:
8
text
:
"0 / 0"
}
Image
{
y
:
7
id
:
peerImage
anchors.right
:
parent
.
right
width
:
10
;
height
:
10
MouseArea
{
onDoubleClicked
:
peerWindow
.
visible
=
true
anchors.fill
:
parent
}
source
:
"../network.png"
}
Label
{
y
:
6
id
:
lastBlockLabel
objectName
:
"lastBlockLabel"
visible
:
true
text
:
""
font.pixelSize
:
10
anchors.right
:
peerGroup
.
left
anchors.rightMargin
:
5
}
ProgressBar
{
id
:
syncProgressIndicator
visible
:
false
objectName
:
"syncProgressIndicator"
y
:
3
width
:
140
indeterminate
:
true
anchors.right
:
peerGroup
.
left
anchors.rightMargin
:
5
}
RowLayout
{
id
:
peerGroup
y
:
7
anchors.right
:
parent
.
right
MouseArea
{
onDoubleClicked
:
peerWindow
.
visible
=
true
anchors.fill
:
parent
}
Label
{
id
:
peerLabel
font.pixelSize
:
8
text
:
"0 / 0"
}
Image
{
id
:
peerImage
width
:
10
;
height
:
10
source
:
"../network.png"
}
}
}
Window
{
id
:
popup
visible
:
false
//flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint
property
var
block
width
:
root
.
width
height
:
300
...
...
@@ -460,7 +484,7 @@ ApplicationWindow {
Text
{
text
:
'<h3>Block details</h3>'
;
color
:
"#F2F2F2"
}
Text
{
text
:
'<b>Block number:</b> '
+
number
;
color
:
"#F2F2F2"
}
Text
{
text
:
'<b>Hash:</b> '
+
hash
;
color
:
"#F2F2F2"
}
Text
{
text
:
'<b>Coinbase:</b> '
+
coinbase
;
color
:
"#F2F2F2"
}
Text
{
text
:
'<b>Coinbase:</b>
<'
+
name
+
'>
'
+
coinbase
;
color
:
"#F2F2F2"
}
Text
{
text
:
'<b>Block found at:</b> '
+
prettyTime
;
color
:
"#F2F2F2"
}
Text
{
text
:
'<b>Gas used:</b> '
+
gasUsed
+
" / "
+
gasLimit
;
color
:
"#F2F2F2"
}
}
...
...
@@ -577,6 +601,7 @@ ApplicationWindow {
Window
{
id
:
addPeerWin
//flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint
visible
:
false
minimumWidth
:
230
maximumWidth
:
230
...
...
@@ -686,9 +711,9 @@ ApplicationWindow {
}
if
(
initial
){
blockModel
.
append
({
number
:
block
.
number
,
gasLimit
:
block
.
gasLimit
,
gasUsed
:
block
.
gasUsed
,
coinbase
:
block
.
coinbase
,
hash
:
block
.
hash
,
txs
:
txs
,
txAmount
:
amount
,
time
:
block
.
time
,
prettyTime
:
convertToPretty
(
block
.
time
)})
blockModel
.
append
({
number
:
block
.
number
,
name
:
block
.
name
,
gasLimit
:
block
.
gasLimit
,
gasUsed
:
block
.
gasUsed
,
coinbase
:
block
.
coinbase
,
hash
:
block
.
hash
,
txs
:
txs
,
txAmount
:
amount
,
time
:
block
.
time
,
prettyTime
:
convertToPretty
(
block
.
time
)})
}
else
{
blockModel
.
insert
(
0
,
{
number
:
block
.
number
,
gasLimit
:
block
.
gasLimit
,
gasUsed
:
block
.
gasUsed
,
coinbase
:
block
.
coinbase
,
hash
:
block
.
hash
,
txs
:
txs
,
txAmount
:
amount
,
time
:
block
.
time
,
prettyTime
:
convertToPretty
(
block
.
time
)})
blockModel
.
insert
(
0
,
{
number
:
block
.
number
,
name
:
block
.
name
,
gasLimit
:
block
.
gasLimit
,
gasUsed
:
block
.
gasUsed
,
coinbase
:
block
.
coinbase
,
hash
:
block
.
hash
,
txs
:
txs
,
txAmount
:
amount
,
time
:
block
.
time
,
prettyTime
:
convertToPretty
(
block
.
time
)})
}
}
...
...
@@ -743,6 +768,7 @@ ApplicationWindow {
// ******************************************
Window
{
id
:
peerWindow
//flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint
height
:
200
width
:
700
Rectangle
{
...
...
samplecoin
@
944fbaa3
Subproject commit 944fbaa31d51328b522c0cd55113716630b4cbcb
ethereal/debugger.go
View file @
4d5a890b
...
...
@@ -17,6 +17,8 @@ type DebuggerWindow struct {
vm
*
ethchain
.
Vm
Db
*
Debugger
state
*
ethchain
.
State
}
func
NewDebuggerWindow
(
lib
*
UiLib
)
*
DebuggerWindow
{
...
...
@@ -53,6 +55,7 @@ func (self *DebuggerWindow) SetCode(code string) {
func
(
self
*
DebuggerWindow
)
SetData
(
data
string
)
{
self
.
win
.
Set
(
"dataText"
,
data
)
}
func
(
self
*
DebuggerWindow
)
SetAsm
(
data
[]
byte
)
{
self
.
win
.
Root
()
.
Call
(
"clearAsm"
)
...
...
ethereal/flags.go
View file @
4d5a890b
...
...
@@ -36,6 +36,7 @@ var LogLevel int
// flags specific to gui client
var
AssetPath
string
//TODO: If we re-use the one defined in cmd.go the binary osx image crashes. If somebody finds out why we can dry this up.
func
defaultAssetPath
()
string
{
var
assetPath
string
// If the current working directory is the go-ethereum dir
...
...
@@ -60,7 +61,6 @@ func defaultAssetPath() string {
}
return
assetPath
}
func
defaultDataDir
()
string
{
usr
,
_
:=
user
.
Current
()
return
path
.
Join
(
usr
.
HomeDir
,
".ethereal"
)
...
...
ethereal/gui.go
View file @
4d5a890b
...
...
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethminer"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
...
...
@@ -14,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
"strconv"
"strings"
"time"
)
...
...
@@ -41,6 +43,8 @@ type Gui struct {
Session
string
clientIdentity
*
ethwire
.
SimpleClientIdentity
config
*
ethutil
.
ConfigManager
miner
*
ethminer
.
Miner
}
// Create GUI, but doesn't start it
...
...
@@ -125,6 +129,7 @@ func (gui *Gui) ToggleMining() {
txt
=
"Start mining"
}
else
{
utils
.
StartMining
(
gui
.
eth
)
gui
.
miner
=
utils
.
GetMiner
()
txt
=
"Stop mining"
}
...
...
@@ -244,7 +249,11 @@ func (gui *Gui) readPreviousTransactions() {
}
func
(
gui
*
Gui
)
processBlock
(
block
*
ethchain
.
Block
,
initial
bool
)
{
gui
.
win
.
Root
()
.
Call
(
"addBlock"
,
ethpub
.
NewPBlock
(
block
),
initial
)
name
:=
ethpub
.
FindNameInNameReg
(
gui
.
eth
.
StateManager
(),
block
.
Coinbase
)
b
:=
ethpub
.
NewPBlock
(
block
)
b
.
Name
=
name
gui
.
win
.
Root
()
.
Call
(
"addBlock"
,
b
,
initial
)
}
func
(
gui
*
Gui
)
setWalletValue
(
amount
,
unconfirmedFunds
*
big
.
Int
)
{
...
...
@@ -263,20 +272,32 @@ func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
gui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
str
)
}
func
(
self
*
Gui
)
getObjectByName
(
objectName
string
)
qml
.
Object
{
return
self
.
win
.
Root
()
.
ObjectByName
(
objectName
)
}
// Simple go routine function that updates the list of peers in the GUI
func
(
gui
*
Gui
)
update
()
{
reactor
:=
gui
.
eth
.
Reactor
()
blockChan
:=
make
(
chan
ethreact
.
Event
,
1
)
txChan
:=
make
(
chan
ethreact
.
Event
,
1
)
objectChan
:=
make
(
chan
ethreact
.
Event
,
1
)
peerChan
:=
make
(
chan
ethreact
.
Event
,
1
)
ticker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
var
(
blockChan
=
make
(
chan
ethreact
.
Event
,
1
)
txChan
=
make
(
chan
ethreact
.
Event
,
1
)
objectChan
=
make
(
chan
ethreact
.
Event
,
1
)
peerChan
=
make
(
chan
ethreact
.
Event
,
1
)
chainSyncChan
=
make
(
chan
ethreact
.
Event
,
1
)
miningChan
=
make
(
chan
ethreact
.
Event
,
1
)
)
peerUpdateTicker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
generalUpdateTicker
:=
time
.
NewTicker
(
1
*
time
.
Second
)
state
:=
gui
.
eth
.
StateManager
()
.
TransState
()
unconfirmedFunds
:=
new
(
big
.
Int
)
gui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
fmt
.
Sprintf
(
"%v"
,
ethutil
.
CurrencyToString
(
state
.
GetAccount
(
gui
.
address
())
.
Amount
)))
gui
.
getObjectByName
(
"syncProgressIndicator"
)
.
Set
(
"visible"
,
!
gui
.
eth
.
IsUpToDate
())
lastBlockLabel
:=
gui
.
getObjectByName
(
"lastBlockLabel"
)
go
func
()
{
for
{
...
...
@@ -319,18 +340,43 @@ func (gui *Gui) update() {
state
.
UpdateStateObject
(
object
)
}
case
msg
:=
<-
chainSyncChan
:
sync
:=
msg
.
Resource
.
(
bool
)
gui
.
win
.
Root
()
.
ObjectByName
(
"syncProgressIndicator"
)
.
Set
(
"visible"
,
sync
)
case
<-
objectChan
:
gui
.
loadAddressBook
()
case
<-
peerChan
:
gui
.
setPeerInfo
()
case
<-
t
icker
.
C
:
case
<-
peerUpdateT
icker
.
C
:
gui
.
setPeerInfo
()
case
msg
:=
<-
miningChan
:
if
msg
.
Name
==
"miner:start"
{
gui
.
miner
=
msg
.
Resource
.
(
*
ethminer
.
Miner
)
}
else
{
gui
.
miner
=
nil
}
case
<-
generalUpdateTicker
.
C
:
statusText
:=
"#"
+
gui
.
eth
.
BlockChain
()
.
CurrentBlock
.
Number
.
String
()
if
gui
.
miner
!=
nil
{
pow
:=
gui
.
miner
.
GetPow
()
if
pow
.
GetHashrate
()
!=
0
{
statusText
=
"Mining @ "
+
strconv
.
FormatInt
(
pow
.
GetHashrate
(),
10
)
+
"Khash - "
+
statusText
}
}
lastBlockLabel
.
Set
(
"text"
,
statusText
)
}
}
}()
reactor
:=
gui
.
eth
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
reactor
.
Subscribe
(
"newTx:pre"
,
txChan
)
reactor
.
Subscribe
(
"newTx:post"
,
txChan
)
reactor
.
Subscribe
(
"chainSync"
,
chainSyncChan
)
reactor
.
Subscribe
(
"miner:start"
,
miningChan
)
reactor
.
Subscribe
(
"miner:stop"
,
miningChan
)
nameReg
:=
ethpub
.
EthereumConfig
(
gui
.
eth
.
StateManager
())
.
NameReg
()
if
nameReg
!=
nil
{
...
...
@@ -357,7 +403,7 @@ func (gui *Gui) address() []byte {
}
func
(
gui
*
Gui
)
RegisterName
(
name
string
)
{
name
=
fmt
.
Sprintf
(
"
\"
%s
\"
"
,
name
)
name
=
fmt
.
Sprintf
(
"
\"
register
\"\n\"
%s
\"
"
,
name
)
gui
.
pub
.
Transact
(
gui
.
privateKey
(),
"NameReg"
,
""
,
"10000"
,
"10000000000000"
,
name
)
}
...
...
ethereal/main.go
View file @
4d5a890b
...
...
@@ -10,7 +10,7 @@ import (
const
(
ClientIdentifier
=
"Ethereal"
Version
=
"0.5.1
6
"
Version
=
"0.5.1
7
"
)
func
main
()
{
...
...
ethereum/cmd.go
View file @
4d5a890b
...
...
@@ -2,13 +2,14 @@ package main
import
(
"github.com/ethereum/eth-go"
"github.com/ethereum/go-ethereum/ethereum/repl"
"github.com/ethereum/go-ethereum/utils"
"io/ioutil"
"os"
)
func
InitJsConsole
(
ethereum
*
eth
.
Ethereum
)
{
repl
:=
NewJSRepl
(
ethereum
)
repl
:=
ethrepl
.
NewJSRepl
(
ethereum
)
go
repl
.
Start
()
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
repl
.
Stop
()
...
...
@@ -24,7 +25,7 @@ func ExecJsFile(ethereum *eth.Ethereum, InputFile string) {
if
err
!=
nil
{
logger
.
Fatalln
(
err
)
}
re
:=
NewJSRE
(
ethereum
)
re
:=
ethrepl
.
NewJSRE
(
ethereum
)
utils
.
RegisterInterrupt
(
func
(
os
.
Signal
)
{
re
.
Stop
()
})
...
...
ethereum/flags.go
View file @
4d5a890b
...
...
@@ -12,6 +12,7 @@ import (
var
Identifier
string
var
KeyRing
string
var
DiffTool
bool
var
DiffType
string
var
KeyStore
string
var
StartRpc
bool
var
RpcPort
int
...
...
@@ -68,6 +69,7 @@ func Init() {
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
.
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
(
&
StartJsConsole
,
"js"
,
false
,
"launches javascript console"
)
...
...
ethereum/main.go
View file @
4d5a890b
...
...
@@ -9,7 +9,7 @@ import (
const
(
ClientIdentifier
=
"Ethereum(G)"
Version
=
"0.5.1
6
"
Version
=
"0.5.1
7
"
)
var
logger
=
ethlog
.
NewLogger
(
"CLI"
)
...
...
@@ -29,6 +29,7 @@ func main() {
utils
.
InitConfig
(
ConfigFile
,
Datadir
,
"ETH"
)
ethutil
.
Config
.
Diff
=
DiffTool
ethutil
.
Config
.
DiffType
=
DiffType
utils
.
InitDataDir
(
Datadir
)
...
...
ethereum/javascript_runtime.go
→
ethereum/
repl/
javascript_runtime.go
View file @
4d5a890b
package
main
package
ethrepl
import
(
"fmt"
...
...
ethereum/js_lib.go
→
ethereum/
repl/
js_lib.go
View file @
4d5a890b
package
main
package
ethrepl
const
jsLib
=
`
function pp(object) {
...
...
ethereum/repl/repl.go
0 → 100644
View file @
4d5a890b
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 @
4d5a890b
package
main
package
ethrepl
// #cgo darwin CFLAGS: -I/usr/local/opt/readline/include
// #cgo darwin LDFLAGS: -L/usr/local/opt/readline/lib
...
...
ethereum/repl_linux.go
→
ethereum/repl
/repl
_linux.go
View file @
4d5a890b
File moved
ethereum/repl_windows.go
→
ethereum/repl
/repl
_windows.go
View file @
4d5a890b
package
main
package
ethrepl
import
(
"bufio"
...
...
ethereum/repl.go
→
ethereum/repl
/types
.go
View file @
4d5a890b
package
main
package
ethrepl
import
(
"bufio"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/otto"
"io"
"os"
"path"
)
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
()
}
type
JSStateObject
struct
{
*
ethpub
.
PStateObject
eth
*
JSEthereum
}
func
(
self
*
JSRepl
)
parseInput
(
code
string
)
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
fmt
.
Println
(
"[native] error"
,
r
)
}
}()
func
(
self
*
JSStateObject
)
EachStorage
(
call
otto
.
FunctionCall
)
otto
.
Value
{
cb
:=
call
.
Argument
(
0
)
self
.
PStateObject
.
EachStorage
(
func
(
key
string
,
value
*
ethutil
.
Value
)
{
value
.
Decode
()
value
,
err
:=
self
.
re
.
Run
(
code
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
}
cb
.
Call
(
self
.
eth
.
toVal
(
self
),
self
.
eth
.
toVal
(
key
),
self
.
eth
.
toVal
(
ethutil
.
Bytes2Hex
(
value
.
Bytes
())))
})
self
.
PrintValue
(
value
)
return
otto
.
UndefinedValue
(
)
}
// The JSEthereum object attempts to wrap the PEthereum object and returns
...
...
@@ -110,7 +52,7 @@ func (self *JSEthereum) GetKey() 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
{
...
...
utils/cmd.go
View file @
4d5a890b
package
utils
import
(
"bitbucket.org/kardianos/osext"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethcrypto"
...
...
@@ -16,6 +17,8 @@ import (
"os"
"os/signal"
"path"
"path/filepath"
"runtime"
"time"
)
...
...
@@ -165,7 +168,34 @@ func NewKeyManager(KeyStore string, Datadir string, db ethutil.Database) *ethcry
return
keyManager
}
func
DefaultAssetPath
()
string
{
var
assetPath
string
// If the current working directory is the go-ethereum dir
// assume a debug build and use the source directory as
// asset directory.
pwd
,
_
:=
os
.
Getwd
()
if
pwd
==
path
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"go-ethereum"
,
"ethereal"
)
{
assetPath
=
path
.
Join
(
pwd
,
"assets"
)
}
else
{
switch
runtime
.
GOOS
{
case
"darwin"
:
// Get Binary Directory
exedir
,
_
:=
osext
.
ExecutableFolder
()
assetPath
=
filepath
.
Join
(
exedir
,
"../Resources"
)
case
"linux"
:
assetPath
=
"/usr/share/ethereal"
case
"windows"
:
assetPath
=
"./assets"
default
:
assetPath
=
"."
}
}
return
assetPath
}
func
KeyTasks
(
keyManager
*
ethcrypto
.
KeyManager
,
KeyRing
string
,
GenAddr
bool
,
SecretFile
string
,
ExportDir
string
,
NonInteractive
bool
)
{
ethcrypto
.
InitWords
(
DefaultAssetPath
())
// Init mnemonic word list
var
err
error
switch
{
case
GenAddr
:
...
...
@@ -205,7 +235,11 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
}
}
var
miner
ethminer
.
Miner
var
miner
*
ethminer
.
Miner
func
GetMiner
()
*
ethminer
.
Miner
{
return
miner
}
func
StartMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
!
ethereum
.
Mining
{
...
...
@@ -214,13 +248,14 @@ func StartMining(ethereum *eth.Ethereum) bool {
go
func
()
{
logger
.
Infoln
(
"Start mining"
)
miner
=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
if
miner
==
nil
{
miner
=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
}
// Give it some time to connect with peers
time
.
Sleep
(
3
*
time
.
Second
)
for
!
ethereum
.
IsUpToDate
()
{
time
.
Sleep
(
5
*
time
.
Second
)
}
miner
.
Start
()
}()
RegisterInterrupt
(
func
(
os
.
Signal
)
{
...
...
@@ -232,12 +267,14 @@ func StartMining(ethereum *eth.Ethereum) bool {
}
func
StopMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
ethereum
.
Mining
{
if
ethereum
.
Mining
&&
miner
!=
nil
{
miner
.
Stop
()
logger
.
Infoln
(
"Stopped mining"
)
ethereum
.
Mining
=
false
return
true
}
return
false
}
...
...
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