Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
3e8b27c9
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e8b27c9
编写于
2月 21, 2014
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP library, sample app
上级
95a48cea
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
140 addition
and
24 deletion
+140
-24
test_app.qml
test_app.qml
+35
-0
ui/gui.go
ui/gui.go
+25
-3
ui/library.go
ui/library.go
+42
-0
wallet.qml
wallet.qml
+38
-21
未找到文件。
test_app.qml
0 → 100644
浏览文件 @
3e8b27c9
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
GoExtensions
1.0
ApplicationWindow
{
minimumWidth
:
500
maximumWidth
:
500
maximumHeight
:
100
minimumHeight
:
100
title
:
"
Ethereum Dice
"
TextField
{
id
:
textField
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
placeholderText
:
"
Amount
"
}
Label
{
id
:
txHash
anchors.bottom
:
textField
.
top
anchors.bottomMargin
:
5
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Button
{
anchors.top
:
textField
.
bottom
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.topMargin
:
5
text
:
"
Place bet
"
onClicked
:
{
txHash
.
text
=
eth
.
createTx
(
"
e6716f9544a56c530d868e4bfbacb172315bdead
"
,
parseInt
(
textField
.
text
))
}
}
}
ui/gui.go
浏览文件 @
3e8b27c9
...
...
@@ -17,10 +17,15 @@ type Gui struct {
engine
*
qml
.
Engine
component
*
qml
.
Common
eth
*
eth
.
Ethereum
// The Ethereum library
lib
*
EthLib
}
func
New
(
ethereum
*
eth
.
Ethereum
)
*
Gui
{
return
&
Gui
{
eth
:
ethereum
}
lib
:=
&
EthLib
{
blockManager
:
ethereum
.
BlockManager
,
blockChain
:
ethereum
.
BlockManager
.
BlockChain
(),
txPool
:
ethereum
.
TxPool
}
return
&
Gui
{
eth
:
ethereum
,
lib
:
lib
}
}
type
Block
struct
{
...
...
@@ -48,10 +53,10 @@ func (ui *Gui) Start() {
}
ui
.
win
=
component
.
CreateWindow
(
nil
)
root
:=
ui
.
win
.
Root
()
context
:=
ui
.
engine
.
Context
()
context
.
SetVar
(
"tester"
,
&
Tester
{
root
:
root
})
context
.
SetVar
(
"eth"
,
ui
.
lib
)
context
.
SetVar
(
"ui"
,
&
UiLib
{
engine
:
ui
.
engine
})
ui
.
eth
.
BlockManager
.
SecondaryBlockProcessor
=
ui
...
...
@@ -82,6 +87,23 @@ func (ui *Gui) updatePeers() {
}
}
type
UiLib
struct
{
engine
*
qml
.
Engine
}
func
(
ui
*
UiLib
)
Open
(
path
string
)
{
component
,
err
:=
ui
.
engine
.
LoadFile
(
path
[
7
:
])
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Debugln
(
err
)
}
win
:=
component
.
CreateWindow
(
nil
)
go
func
()
{
win
.
Show
()
win
.
Wait
()
}()
}
type
Tester
struct
{
root
qml
.
Object
}
...
...
ui/library.go
0 → 100644
浏览文件 @
3e8b27c9
package
ethui
import
(
"encoding/hex"
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"math/big"
)
type
EthLib
struct
{
blockManager
*
ethchain
.
BlockManager
blockChain
*
ethchain
.
BlockChain
txPool
*
ethchain
.
TxPool
}
func
(
lib
*
EthLib
)
CreateTx
(
receiver
string
,
amount
uint64
)
string
{
hash
,
err
:=
hex
.
DecodeString
(
receiver
)
if
err
!=
nil
{
return
err
.
Error
()
}
tx
:=
ethchain
.
NewTransaction
(
hash
,
big
.
NewInt
(
int64
(
amount
)),
[]
string
{
""
})
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
keyRing
:=
ethutil
.
NewValueFromBytes
(
data
)
tx
.
Sign
(
keyRing
.
Get
(
0
)
.
Bytes
())
lib
.
txPool
.
QueueTransaction
(
tx
)
return
ethutil
.
Hex
(
tx
.
Hash
())
}
func
(
lib
*
EthLib
)
GetBlock
(
hexHash
string
)
*
Block
{
hash
,
err
:=
hex
.
DecodeString
(
hexHash
)
if
err
!=
nil
{
return
nil
}
block
:=
lib
.
blockChain
.
GetBlock
(
hash
)
fmt
.
Println
(
block
)
return
&
Block
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Hex
(
block
.
Hash
())}
}
wallet.qml
浏览文件 @
3e8b27c9
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
QtQuick
.
Dialogs
1.0
;
import
GoExtensions
1.0
ApplicationWindow
{
...
...
@@ -12,6 +13,7 @@ ApplicationWindow {
title
:
"
Ethereal
"
toolBar
:
ToolBar
{
id
:
mainToolbar
...
...
@@ -19,7 +21,7 @@ ApplicationWindow {
width
:
parent
.
width
Button
{
text
:
"
Send
"
onClicked
:
tester
.
compile
(
codeView
)
onClicked
:
console
.
log
(
"
SEND
"
)
}
TextField
{
...
...
@@ -66,35 +68,50 @@ ApplicationWindow {
TableViewColumn
{
role
:
"
hash
"
;
title
:
"
Hash
"
;
width
:
560
}
model
:
blockModel
onDoubleClicked
:
{
console
.
log
(
eth
.
getBlock
(
blockModel
.
get
(
row
).
hash
))
}
}
FileDialog
{
id
:
openAppDialog
title
:
"
Open QML Application
"
onAccepted
:
{
ui
.
open
(
openAppDialog
.
fileUrl
.
toString
())
}
}
statusBar
:
StatusBar
{
RowLayout
{
anchors.fill
:
parent
Label
{
text
:
"
0.0.1
"
}
Label
{
anchors.right
:
peerImage
.
left
anchors.rightMargin
:
5
id
:
peerLabel
font.pixelSize
:
8
text
:
"
0 / 0
"
}
Image
{
id
:
peerImage
anchors.right
:
parent
.
right
width
:
10
;
height
:
10
source
:
"
network.png
"
}
RowLayout
{
anchors.fill
:
parent
Button
{
onClicked
:
openAppDialog
.
open
()
text
:
"
Import App
"
}
Label
{
text
:
"
0.0.1
"
}
Label
{
anchors.right
:
peerImage
.
left
anchors.rightMargin
:
5
id
:
peerLabel
font.pixelSize
:
8
text
:
"
0 / 0
"
}
Image
{
id
:
peerImage
anchors.right
:
parent
.
right
width
:
10
;
height
:
10
source
:
"
network.png
"
}
}
}
function
addBlock
(
block
)
{
blockModel
.
insert
(
0
,
{
number
:
block
.
number
,
hash
:
block
.
hash
})
blockModel
.
insert
(
0
,
{
number
:
block
.
number
,
hash
:
block
.
hash
})
}
function
setPeers
(
text
)
{
peerLabel
.
text
=
text
}
peerLabel
.
text
=
text
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录