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
0dda955f
Commit
0dda955f
authored
May 27, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/poc5-rc10'
parents
0d89c1d2
34b861c1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
617 additions
and
112 deletions
+617
-112
README.md
README.md
+1
-1
debugger.qml
ethereal/assets/debugger/debugger.qml
+215
-0
heart.png
ethereal/assets/heart.png
+0
-0
wallet.qml
ethereal/assets/qml/wallet.qml
+188
-54
samplecoin.html
ethereal/assets/samplecoin/samplecoin.html
+1
-1
debugger.go
ethereal/ui/debugger.go
+177
-0
gui.go
ethereal/ui/gui.go
+10
-10
ui_lib.go
ethereal/ui/ui_lib.go
+18
-46
cmd.go
utils/cmd.go
+7
-0
No files found.
README.md
View file @
0dda955f
...
...
@@ -5,7 +5,7 @@ Ethereum
Ethereum Go Client © 2014 Jeffrey Wilcke.
Current state: Proof of Concept 5.0 RC
9
.
Current state: Proof of Concept 5.0 RC
10
.
For the development package please see the
[
eth-go package
](
https://github.com/ethereum/eth-go
)
.
...
...
ethereal/assets/debugger/debugger.qml
0 → 100644
View file @
0dda955f
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
QtQuick
.
Dialogs
1.0
;
import
QtQuick
.
Window
2.1
;
import
QtQuick
.
Controls
.
Styles
1.1
import
Ethereum
1.0
ApplicationWindow
{
visible
:
false
title
:
"IceCream"
minimumWidth
:
1280
minimumHeight
:
900
width
:
1290
height
:
900
SplitView
{
anchors.fill
:
parent
property
var
asmModel
:
ListModel
{
id
:
asmModel
}
TableView
{
id
:
asmTableView
width
:
200
TableViewColumn
{
role
:
"value"
;
title
:
""
;
width
:
100
}
model
:
asmModel
}
Rectangle
{
color
:
"#00000000"
anchors.left
:
asmTableView
.
right
anchors.right
:
parent
.
right
SplitView
{
orientation
:
Qt
.
Vertical
anchors.fill
:
parent
Rectangle
{
color
:
"#00000000"
height
:
500
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
TextArea
{
id
:
codeEditor
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
anchors.right
:
settings
.
left
}
Column
{
id
:
settings
spacing
:
5
width
:
300
height
:
parent
.
height
anchors.right
:
parent
.
right
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
Label
{
text
:
"Arbitrary data"
}
TextArea
{
id
:
rawDataField
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
height
:
150
}
Label
{
text
:
"Amount"
}
TextField
{
id
:
txValue
width
:
200
placeholderText
:
"Amount"
validator
:
RegExpValidator
{
regExp
:
/
\d
*/
}
}
Label
{
text
:
"Amount of gas"
}
TextField
{
id
:
txGas
width
:
200
validator
:
RegExpValidator
{
regExp
:
/
\d
*/
}
text
:
"10000"
placeholderText
:
"Gas"
}
Label
{
text
:
"Gas price"
}
TextField
{
id
:
txGasPrice
width
:
200
placeholderText
:
"Gas price"
text
:
"1000000000000"
validator
:
RegExpValidator
{
regExp
:
/
\d
*/
}
}
}
}
SplitView
{
orientation
:
Qt
.
Vertical
id
:
inspectorPane
height
:
500
SplitView
{
orientation
:
Qt
.
Horizontal
height
:
250
TableView
{
id
:
stackTableView
property
var
stackModel
:
ListModel
{
id
:
stackModel
}
height
:
parent
.
height
width
:
300
TableViewColumn
{
role
:
"value"
;
title
:
"Stack"
;
width
:
200
}
model
:
stackModel
}
TableView
{
id
:
memoryTableView
property
var
memModel
:
ListModel
{
id
:
memModel
}
height
:
parent
.
height
width
:
parent
.
width
-
stackTableView
.
width
TableViewColumn
{
id
:
mnumColmn
;
role
:
"num"
;
title
:
"#"
;
width
:
50
}
TableViewColumn
{
role
:
"value"
;
title
:
"Memory"
;
width
:
750
}
model
:
memModel
}
}
SplitView
{
height
:
300
TableView
{
id
:
storageTableView
property
var
memModel
:
ListModel
{
id
:
storageModel
}
height
:
parent
.
height
width
:
parent
.
width
-
stackTableView
.
width
TableViewColumn
{
id
:
key
;
role
:
"key"
;
title
:
"#"
;
width
:
storageTableView
.
width
/
2
}
TableViewColumn
{
role
:
"value"
;
title
:
"value"
;
width
:
storageTableView
.
width
/
2
}
model
:
storageModel
}
}
}
}
}
}
toolBar
:
ToolBar
{
RowLayout
{
spacing
:
5
Button
{
property
var
enabled
:
true
id
:
debugStart
onClicked
:
{
dbg
.
debug
(
txValue
.
text
,
txGas
.
text
,
txGasPrice
.
text
,
codeEditor
.
text
,
rawDataField
.
text
)
}
text
:
"Debug"
}
Button
{
property
var
enabled
:
true
id
:
debugNextButton
onClicked
:
{
dbg
.
next
()
}
text
:
"Next"
}
}
}
function
setAsm
(
asm
)
{
asmModel
.
append
({
asm
:
asm
})
}
function
clearAsm
()
{
asmModel
.
clear
()
}
function
setInstruction
(
num
)
{
asmTableView
.
selection
.
clear
()
asmTableView
.
selection
.
select
(
num
-
1
)
}
function
setMem
(
mem
)
{
memModel
.
append
({
num
:
mem
.
num
,
value
:
mem
.
value
})
}
function
clearMem
(){
memModel
.
clear
()
}
function
setStack
(
stack
)
{
stackModel
.
append
({
value
:
stack
})
}
function
addDebugMessage
(
message
){
debuggerLog
.
append
({
value
:
message
})
}
function
clearStack
()
{
stackModel
.
clear
()
}
function
clearStorage
()
{
storageModel
.
clear
()
}
function
setStorage
(
storage
)
{
storageModel
.
append
({
key
:
storage
.
key
,
value
:
storage
.
value
})
}
}
ethereal/assets/heart.png
0 → 100644
View file @
0dda955f
4.18 KB
ethereal/assets/qml/wallet.qml
View file @
0dda955f
...
...
@@ -6,6 +6,7 @@ import QtQuick.Window 2.1;
import
QtQuick
.
Controls
.
Styles
1.1
import
Ethereum
1.0
ApplicationWindow
{
id
:
root
...
...
@@ -122,7 +123,7 @@ ApplicationWindow {
}
Image
{
source
:
ui
.
assetPath
(
"
ne
t.png"
)
source
:
ui
.
assetPath
(
"
hear
t.png"
)
anchors.horizontalCenter
:
parent
.
horizontalCenter
MouseArea
{
anchors.fill
:
parent
...
...
@@ -202,16 +203,14 @@ ApplicationWindow {
anchors.bottom
:
logView
.
top
TableViewColumn
{
role
:
"number"
;
title
:
"#"
;
width
:
100
}
TableViewColumn
{
role
:
"hash"
;
title
:
"Hash"
;
width
:
560
}
TableViewColumn
{
role
:
"txAmount"
;
title
:
"Tx amount"
;
width
:
100
}
model
:
blockModel
/*
onDoubleClicked: {
popup.visible = true
popup.block = eth.getBlock(blockModel.get(row).hash)
popup.hashLabel.text = popup.block.hash
}
*/
onDoubleClicked
:
{
popup
.
visible
=
true
popup
.
setDetails
(
blockModel
.
get
(
row
))
}
}
property
var
logModel
:
ListModel
{
...
...
@@ -285,29 +284,27 @@ ApplicationWindow {
title
:
"Open QML Application"
onAccepted
:
{
//ui.open(openAppDialog.fileUrl.toString())
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
ui
.
openHtml
(
openAppDialog
.
fileUrl
.
toString
())
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
ui
.
openHtml
(
openAppDialog
.
fileUrl
.
toString
())
}
}
statusBar
:
StatusBar
{
RowLayout
{
anchors.fill
:
parent
Button
{
property
var
enabled
:
true
id
:
connectButton
id
:
debuggerWindow
onClicked
:
{
if
(
this
.
enabled
)
{
ui
.
connect
(
this
)
}
ui
.
startDebugger
()
}
text
:
"
Connect
"
text
:
"
Debugger
"
}
Button
{
id
:
importAppButton
anchors.left
:
connectButton
.
right
anchors.left
:
debuggerWindow
.
right
anchors.leftMargin
:
5
onClicked
:
openAppDialog
.
open
()
text
:
"Import App"
...
...
@@ -339,10 +336,107 @@ ApplicationWindow {
id
:
popup
visible
:
false
property
var
block
Label
{
id
:
hashLabel
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.verticalCenter
:
parent
.
verticalCenter
width
:
800
height
:
280
x
:
root
.
x
y
:
root
.
y
+
root
.
height
Component
{
id
:
blockDetailsDelegate
Rectangle
{
color
:
"#252525"
width
:
popup
.
width
height
:
200
Column
{
anchors.leftMargin
:
10
anchors.topMargin
:
5
anchors.top
:
parent
.
top
anchors.left
:
parent
.
left
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>Block found at:</b> '
+
prettyTime
;
color
:
"#F2F2F2"
}
}
}
}
ListView
{
model
:
singleBlock
delegate
:
blockDetailsDelegate
anchors.top
:
parent
.
top
height
:
70
anchors.leftMargin
:
20
id
:
listViewThing
Layout.maximumHeight
:
40
}
TableView
{
id
:
txView
anchors.top
:
listViewThing
.
bottom
anchors.topMargin
:
50
width
:
parent
.
width
TableViewColumn
{
width
:
90
;
role
:
"value"
;
title
:
"Value"
}
TableViewColumn
{
width
:
200
;
role
:
"hash"
;
title
:
"Hash"
}
TableViewColumn
{
width
:
200
;
role
:
"sender"
;
title
:
"Sender"
}
TableViewColumn
{
width
:
200
;
role
:
"address"
;
title
:
"Receiver"
}
TableViewColumn
{
width
:
60
;
role
:
"gas"
;
title
:
"Gas"
}
TableViewColumn
{
width
:
60
;
role
:
"gasPrice"
;
title
:
"Gas Price"
}
TableViewColumn
{
width
:
60
;
role
:
"isContract"
;
title
:
"Contract"
}
model
:
transactionModel
onClicked
:
{
var
tx
=
transactionModel
.
get
(
row
)
if
(
tx
.
data
)
{
popup
.
showContractData
(
tx
.
data
)
}
else
{
popup
.
height
=
230
}
}
}
function
showContractData
(
data
)
{
contractData
.
text
=
data
popup
.
height
=
400
}
Rectangle
{
width
:
popup
.
width
height
:
300
anchors.left
:
listViewThing
.
left
anchors.top
:
txView
.
bottom
Label
{
text
:
"<h4>Contract data</h4>"
anchors.top
:
parent
.
top
anchors.left
:
parent
.
left
id
:
contractLabel
anchors.leftMargin
:
10
}
TextArea
{
id
:
contractData
text
:
"Contract"
anchors.top
:
contractLabel
.
bottom
anchors.left
:
parent
.
left
wrapMode
:
Text
.
Wrap
width
:
parent
.
width
-
30
height
:
80
anchors.leftMargin
:
10
}
}
property
var
transactionModel
:
ListModel
{
id
:
transactionModel
}
property
var
singleBlock
:
ListModel
{
id
:
singleBlock
}
function
setDetails
(
block
){
singleBlock
.
set
(
0
,
block
)
popup
.
height
=
230
transactionModel
.
clear
()
if
(
block
.
txs
!=
undefined
){
for
(
var
i
=
0
;
i
<
block
.
txs
.
count
;
++
i
)
{
transactionModel
.
insert
(
0
,
block
.
txs
.
get
(
i
))
}
if
(
block
.
txs
.
get
(
0
).
data
){
popup
.
showContractData
(
block
.
txs
.
get
(
0
).
data
)
}
}
txView
.
forceActiveFocus
()
}
}
...
...
@@ -409,7 +503,7 @@ ApplicationWindow {
}
Window
{
Application
Window
{
id
:
debugWindow
visible
:
false
title
:
"Debugger"
...
...
@@ -447,36 +541,50 @@ ApplicationWindow {
orientation
:
Qt
.
Vertical
anchors.fill
:
parent
TableView
{
property
var
memModel
:
ListModel
{
id
:
memModel
}
height
:
parent
.
height
/
2
width
:
parent
.
width
TableViewColumn
{
id
:
mnumColmn
;
role
:
"num"
;
title
:
"#"
;
width
:
50
}
TableViewColumn
{
role
:
"value"
;
title
:
"Memory"
;
width
:
750
}
model
:
memModel
}
SplitView
{
orientation
:
Qt
.
Horizontal
TableView
{
property
var
debuggerLog
:
ListModel
{
id
:
debuggerLog
}
TableViewColumn
{
role
:
"value"
;
title
:
"Debug messages"
}
model
:
debuggerLog
}
TableView
{
property
var
stackModel
:
ListModel
{
id
:
stackModel
}
height
:
parent
.
height
/
2
width
:
parent
.
width
TableViewColumn
{
role
:
"value"
;
title
:
"Stack"
;
width
:
parent
.
width
}
model
:
stackModel
}
}
TableView
{
property
var
memModel
:
ListModel
{
id
:
memModel
}
height
:
parent
.
height
/
2
width
:
parent
.
width
TableViewColumn
{
id
:
mnumColmn
;
role
:
"num"
;
title
:
"#"
;
width
:
50
}
TableViewColumn
{
role
:
"value"
;
title
:
"Memory"
;
width
:
750
}
model
:
memModel
}
SplitView
{
orientation
:
Qt
.
Horizontal
id
:
debugSplitView
TableView
{
property
var
debuggerLog
:
ListModel
{
id
:
debuggerLog
}
TableViewColumn
{
role
:
"value"
;
title
:
"Debug messages"
}
model
:
debuggerLog
}
TableView
{
property
var
stackModel
:
ListModel
{
id
:
stackModel
}
height
:
parent
.
height
/
2
width
:
parent
.
width
TableViewColumn
{
role
:
"value"
;
title
:
"Stack"
;
width
:
debugSplitView
.
width
}
model
:
stackModel
}
}
}
}
}
statusBar
:
StatusBar
{
RowLayout
{
anchors.fill
:
parent
Button
{
property
var
enabled
:
true
id
:
debugNextButton
onClicked
:
{
ui
.
next
()
}
text
:
"Next"
}
}
}
...
...
@@ -533,8 +641,22 @@ ApplicationWindow {
txModel
.
insert
(
0
,
{
inout
:
inout
,
hash
:
tx
.
hash
,
address
:
tx
.
address
,
value
:
tx
.
value
,
contract
:
isContract
})
}
function
addBlock
(
block
)
{
blockModel
.
insert
(
0
,
{
number
:
block
.
number
,
hash
:
block
.
hash
})
function
addBlock
(
block
,
initial
)
{
var
txs
=
JSON
.
parse
(
block
.
transactions
);
var
amount
=
0
if
(
initial
==
undefined
){
initial
=
false
}
if
(
txs
!=
null
){
amount
=
txs
.
length
}
if
(
initial
){
blockModel
.
append
({
number
:
block
.
number
,
hash
:
block
.
hash
,
txs
:
txs
,
txAmount
:
amount
,
time
:
block
.
time
,
prettyTime
:
convertToPretty
(
block
.
time
)})
}
else
{
blockModel
.
insert
(
0
,
{
number
:
block
.
number
,
hash
:
block
.
hash
,
txs
:
txs
,
txAmount
:
amount
,
time
:
block
.
time
,
prettyTime
:
convertToPretty
(
block
.
time
)})
}
}
function
addLog
(
str
)
{
...
...
@@ -546,4 +668,16 @@ ApplicationWindow {
function
setPeers
(
text
)
{
peerLabel
.
text
=
text
}
function
convertToPretty
(
unixTs
){
var
a
=
new
Date
(
unixTs
*
1000
);
var
months
=
[
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
];
var
year
=
a
.
getFullYear
();
var
month
=
months
[
a
.
getMonth
()];
var
date
=
a
.
getDate
();
var
hour
=
a
.
getHours
();
var
min
=
a
.
getMinutes
();
var
sec
=
a
.
getSeconds
();
var
time
=
date
+
' '
+
month
+
' '
+
year
+
' '
+
hour
+
':'
+
min
+
':'
+
sec
;
return
time
;
}
}
ethereal/assets/samplecoin/samplecoin.html
View file @
0dda955f
...
...
@@ -9,7 +9,7 @@
<script
type=
"text/javascript"
>
var
jefcoinAddr
=
"
fc0a9436890478bb9b1c6ed7455c2535366f4a9
9"
var
jefcoinAddr
=
"
518546ffa883dcc838a64bc2dabada0fd64af45
9"
var
mAddr
=
""
function
createTransaction
()
{
...
...
ethereal/ui/debugger.go
0 → 100644
View file @
0dda955f
package
ethui
import
(
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
"math/big"
"strings"
)
type
DebuggerWindow
struct
{
win
*
qml
.
Window
engine
*
qml
.
Engine
lib
*
UiLib
Db
*
Debugger
}
func
NewDebuggerWindow
(
lib
*
UiLib
)
*
DebuggerWindow
{
engine
:=
qml
.
NewEngine
()
component
,
err
:=
engine
.
LoadFile
(
lib
.
AssetPath
(
"debugger/debugger.qml"
))
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
nil
}
win
:=
component
.
CreateWindow
(
nil
)
db
:=
&
Debugger
{
win
,
make
(
chan
bool
),
make
(
chan
bool
),
true
}
return
&
DebuggerWindow
{
engine
:
engine
,
win
:
win
,
lib
:
lib
,
Db
:
db
}
}
func
(
self
*
DebuggerWindow
)
Show
()
{
context
:=
self
.
engine
.
Context
()
context
.
SetVar
(
"dbg"
,
self
)
go
func
()
{
self
.
win
.
Show
()
self
.
win
.
Wait
()
}()
}
func
formatData
(
data
string
)
[]
byte
{
if
len
(
data
)
==
0
{
return
nil
}
// Simple stupid
d
:=
new
(
big
.
Int
)
if
data
[
0
:
1
]
==
"
\"
"
&&
data
[
len
(
data
)
-
1
:
]
==
"
\"
"
{
d
.
SetBytes
([]
byte
(
data
[
1
:
len
(
data
)
-
1
]))
}
else
if
data
[
:
2
]
==
"0x"
{
d
.
SetBytes
(
ethutil
.
FromHex
(
data
[
2
:
]))
}
else
{
d
.
SetString
(
data
,
0
)
}
return
ethutil
.
BigToBytes
(
d
,
256
)
}
func
(
self
*
DebuggerWindow
)
Debug
(
valueStr
,
gasStr
,
gasPriceStr
,
scriptStr
,
dataStr
string
)
{
if
!
self
.
Db
.
done
{
self
.
Db
.
Q
<-
true
}
dataSlice
:=
strings
.
Split
(
dataStr
,
"
\n
"
)
var
data
[]
byte
for
_
,
dataItem
:=
range
dataSlice
{
d
:=
formatData
(
dataItem
)
data
=
append
(
data
,
d
...
)
}
state
:=
self
.
lib
.
eth
.
BlockChain
()
.
CurrentBlock
.
State
()
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
fmt
.
Println
(
r
)
}
}()
script
,
err
:=
ethutil
.
Compile
(
scriptStr
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Debugln
(
err
)
return
}
dis
:=
ethchain
.
Disassemble
(
script
)
self
.
win
.
Root
()
.
Call
(
"clearAsm"
)
for
_
,
str
:=
range
dis
{
self
.
win
.
Root
()
.
Call
(
"setAsm"
,
str
)
}
// Contract addr as test address
keyPair
:=
ethutil
.
GetKeyRing
()
.
Get
(
0
)
callerTx
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
valueStr
),
ethutil
.
Big
(
gasStr
),
ethutil
.
Big
(
gasPriceStr
),
script
)
callerTx
.
Sign
(
keyPair
.
PrivateKey
)
account
:=
self
.
lib
.
eth
.
StateManager
()
.
TransState
()
.
GetAccount
(
keyPair
.
Address
())
contract
:=
ethchain
.
MakeContract
(
callerTx
,
state
)
callerClosure
:=
ethchain
.
NewClosure
(
account
,
contract
,
script
,
state
,
ethutil
.
Big
(
gasStr
),
ethutil
.
Big
(
gasPriceStr
))
block
:=
self
.
lib
.
eth
.
BlockChain
()
.
CurrentBlock
vm
:=
ethchain
.
NewVm
(
state
,
self
.
lib
.
eth
.
StateManager
(),
ethchain
.
RuntimeVars
{
Origin
:
account
.
Address
(),
BlockNumber
:
block
.
BlockInfo
()
.
Number
,
PrevHash
:
block
.
PrevHash
,
Coinbase
:
block
.
Coinbase
,
Time
:
block
.
Time
,
Diff
:
block
.
Difficulty
,
})
self
.
Db
.
done
=
false
go
func
()
{
callerClosure
.
Call
(
vm
,
data
,
self
.
Db
.
halting
)
state
.
Reset
()
self
.
Db
.
done
=
true
}()
}
func
(
self
*
DebuggerWindow
)
Next
()
{
self
.
Db
.
Next
()
}
type
Debugger
struct
{
win
*
qml
.
Window
N
chan
bool
Q
chan
bool
done
bool
}
type
storeVal
struct
{
Key
,
Value
string
}
func
(
d
*
Debugger
)
halting
(
pc
int
,
op
ethchain
.
OpCode
,
mem
*
ethchain
.
Memory
,
stack
*
ethchain
.
Stack
,
stateObject
*
ethchain
.
StateObject
)
bool
{
d
.
win
.
Root
()
.
Call
(
"setInstruction"
,
pc
)
d
.
win
.
Root
()
.
Call
(
"clearMem"
)
d
.
win
.
Root
()
.
Call
(
"clearStack"
)
d
.
win
.
Root
()
.
Call
(
"clearStorage"
)
addr
:=
0
for
i
:=
0
;
i
+
32
<=
mem
.
Len
();
i
+=
32
{
d
.
win
.
Root
()
.
Call
(
"setMem"
,
memAddr
{
fmt
.
Sprintf
(
"%03d"
,
addr
),
fmt
.
Sprintf
(
"% x"
,
mem
.
Data
()[
i
:
i
+
32
])})
addr
++
}
for
_
,
val
:=
range
stack
.
Data
()
{
d
.
win
.
Root
()
.
Call
(
"setStack"
,
val
.
String
())
}
stateObject
.
State
()
.
EachStorage
(
func
(
key
string
,
node
*
ethutil
.
Value
)
{
d
.
win
.
Root
()
.
Call
(
"setStorage"
,
storeVal
{
fmt
.
Sprintf
(
"% x"
,
key
),
fmt
.
Sprintf
(
"% x"
,
node
.
Str
())})
})
out
:
for
{
select
{
case
<-
d
.
N
:
break
out
case
<-
d
.
Q
:
d
.
done
=
true
return
false
}
}
return
true
}
func
(
d
*
Debugger
)
Next
()
{
if
!
d
.
done
{
d
.
N
<-
true
}
}
ethereal/ui/gui.go
View file @
0dda955f
...
...
@@ -54,7 +54,7 @@ func New(ethereum *eth.Ethereum) *Gui {
}
func
(
gui
*
Gui
)
Start
(
assetPath
string
)
{
const
version
=
"0.5.0 RC
9
"
const
version
=
"0.5.0 RC
10
"
defer
gui
.
txDb
.
Close
()
...
...
@@ -130,20 +130,19 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
gui
.
win
=
win
gui
.
uiLib
.
win
=
win
db
:=
&
Debugger
{
gui
.
win
,
make
(
chan
bool
)}
db
:=
&
Debugger
{
gui
.
win
,
make
(
chan
bool
)
,
make
(
chan
bool
),
true
}
gui
.
lib
.
Db
=
db
gui
.
uiLib
.
Db
=
db
return
gui
.
win
}
func
(
gui
*
Gui
)
setInitialBlockChain
()
{
// Load previous 10 blocks
chain
:=
gui
.
eth
.
BlockChain
()
.
GetChain
(
gui
.
eth
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
10
)
for
_
,
block
:=
range
chain
{
gui
.
processBlock
(
block
)
sBlk
:=
gui
.
eth
.
BlockChain
()
.
LastBlockHash
blk
:=
gui
.
eth
.
BlockChain
()
.
GetBlock
(
sBlk
)
for
;
blk
!=
nil
;
blk
=
gui
.
eth
.
BlockChain
()
.
GetBlock
(
sBlk
)
{
sBlk
=
blk
.
PrevHash
gui
.
processBlock
(
blk
,
true
)
}
}
func
(
gui
*
Gui
)
readPreviousTransactions
()
{
...
...
@@ -164,8 +163,8 @@ func (gui *Gui) readPreviousTransactions() {
it
.
Release
()
}
func
(
gui
*
Gui
)
processBlock
(
block
*
ethchain
.
Block
)
{
gui
.
win
.
Root
()
.
Call
(
"addBlock"
,
ethpub
.
NewPBlock
(
block
))
func
(
gui
*
Gui
)
processBlock
(
block
*
ethchain
.
Block
,
initial
bool
)
{
gui
.
win
.
Root
()
.
Call
(
"addBlock"
,
ethpub
.
NewPBlock
(
block
)
,
initial
)
}
func
(
gui
*
Gui
)
setWalletValue
(
amount
,
unconfirmedFunds
*
big
.
Int
)
{
...
...
@@ -204,6 +203,7 @@ func (gui *Gui) update() {
select
{
case
b
:=
<-
blockChan
:
block
:=
b
.
Resource
.
(
*
ethchain
.
Block
)
gui
.
processBlock
(
block
,
false
)
if
bytes
.
Compare
(
block
.
Coinbase
,
gui
.
addr
)
==
0
{
gui
.
setWalletValue
(
gui
.
eth
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
gui
.
addr
)
.
Amount
,
nil
)
}
...
...
ethereal/ui/ui_lib.go
View file @
0dda955f
...
...
@@ -2,13 +2,10 @@ package ethui
import
(
"bitbucket.org/kardianos/osext"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"github.com/obscuren/mutan"
"os"
"path"
"path/filepath"
...
...
@@ -92,6 +89,12 @@ func (ui *UiLib) AssetPath(p string) string {
return
path
.
Join
(
ui
.
assetPath
,
p
)
}
func
(
self
*
UiLib
)
StartDebugger
()
{
dbWindow
:=
NewDebuggerWindow
(
self
)
dbWindow
.
Show
()
}
func
DefaultAssetPath
()
string
{
var
base
string
// If the current working directory is the go-ethereum dir
...
...
@@ -121,27 +124,28 @@ func DefaultAssetPath() string {
func
(
ui
*
UiLib
)
DebugTx
(
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
data
string
)
{
state
:=
ui
.
eth
.
BlockChain
()
.
CurrentBlock
.
State
()
mainInput
,
_
:=
mutan
.
PreParse
(
data
)
callerScript
,
err
:=
utils
.
Compile
(
mainInput
)
script
,
err
:=
ethutil
.
Compile
(
data
)
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Debugln
(
err
)
return
}
dis
:=
ethchain
.
Disassemble
(
callerS
cript
)
dis
:=
ethchain
.
Disassemble
(
s
cript
)
ui
.
win
.
Root
()
.
Call
(
"clearAsm"
)
for
_
,
str
:=
range
dis
{
ui
.
win
.
Root
()
.
Call
(
"setAsm"
,
str
)
}
callerTx
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
valueStr
),
ethutil
.
Big
(
gasStr
),
ethutil
.
Big
(
gasPriceStr
),
nil
)
// Contract addr as test address
keyPair
:=
ethutil
.
GetKeyRing
()
.
Get
(
0
)
callerTx
:=
ethchain
.
NewContractCreationTx
(
ethutil
.
Big
(
valueStr
),
ethutil
.
Big
(
gasStr
),
ethutil
.
Big
(
gasPriceStr
),
script
)
callerTx
.
Sign
(
keyPair
.
PrivateKey
)
account
:=
ui
.
eth
.
StateManager
()
.
TransState
()
.
GetStateObject
(
keyPair
.
Address
())
c
:=
ethchain
.
MakeContract
(
callerTx
,
state
)
callerClosure
:=
ethchain
.
NewClosure
(
account
,
c
,
c
.
Scrip
t
(),
state
,
ethutil
.
Big
(
gasStr
),
ethutil
.
Big
(
gasPriceStr
))
c
ontract
:=
ethchain
.
MakeContract
(
callerTx
,
state
)
callerClosure
:=
ethchain
.
NewClosure
(
account
,
c
ontract
,
contract
.
Ini
t
(),
state
,
ethutil
.
Big
(
gasStr
),
ethutil
.
Big
(
gasPriceStr
))
block
:=
ui
.
eth
.
BlockChain
()
.
CurrentBlock
vm
:=
ethchain
.
NewVm
(
state
,
ui
.
eth
.
StateManager
(),
ethchain
.
RuntimeVars
{
...
...
@@ -151,50 +155,18 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string)
Coinbase
:
block
.
Coinbase
,
Time
:
block
.
Time
,
Diff
:
block
.
Difficulty
,
TxData
:
nil
,
})
ui
.
Db
.
done
=
false
go
func
()
{
callerClosure
.
Call
(
vm
,
nil
,
ui
.
Db
.
halting
)
callerClosure
.
Call
(
vm
,
contract
.
Init
()
,
ui
.
Db
.
halting
)
state
.
Reset
()
ui
.
Db
.
done
=
true
}()
}
func
(
ui
*
UiLib
)
Next
()
{
ui
.
Db
.
Next
()
}
type
Debugger
struct
{
win
*
qml
.
Window
N
chan
bool
}
func
(
d
*
Debugger
)
halting
(
pc
int
,
op
ethchain
.
OpCode
,
mem
*
ethchain
.
Memory
,
stack
*
ethchain
.
Stack
)
{
d
.
win
.
Root
()
.
Call
(
"setInstruction"
,
pc
)
d
.
win
.
Root
()
.
Call
(
"clearMem"
)
d
.
win
.
Root
()
.
Call
(
"clearStack"
)
addr
:=
0
for
i
:=
0
;
i
+
32
<=
mem
.
Len
();
i
+=
32
{
d
.
win
.
Root
()
.
Call
(
"setMem"
,
memAddr
{
fmt
.
Sprintf
(
"%03d"
,
addr
),
fmt
.
Sprintf
(
"% x"
,
mem
.
Data
()[
i
:
i
+
32
])})
addr
++
}
for
_
,
val
:=
range
stack
.
Data
()
{
d
.
win
.
Root
()
.
Call
(
"setStack"
,
val
.
String
())
}
out
:
for
{
select
{
case
<-
d
.
N
:
break
out
default
:
}
}
}
func
(
d
*
Debugger
)
Next
()
{
d
.
N
<-
true
}
utils/cmd.go
View file @
0dda955f
...
...
@@ -40,6 +40,13 @@ func DoMining(ethereum *eth.Ethereum) {
// Give it some time to connect with peers
time
.
Sleep
(
3
*
time
.
Second
)
for
ethereum
.
IsUpToDate
()
==
false
{
time
.
Sleep
(
5
*
time
.
Second
)
}
ethutil
.
Config
.
Log
.
Infoln
(
"Miner started"
)
miner
:=
ethminer
.
NewDefaultMiner
(
addr
,
ethereum
)
miner
.
Start
()
}()
}
...
...
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