Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
0c132e4c
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,发现更多精彩内容 >>
提交
0c132e4c
编写于
7月 07, 2014
作者:
J
Jeffrey Wilcke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "ethreact - Feature/ethutil refactor"
上级
f9e2e527
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
68 deletion
+64
-68
ethereal/ext_app.go
ethereal/ext_app.go
+4
-5
ethereal/gui.go
ethereal/gui.go
+52
-55
ethereum/javascript_runtime.go
ethereum/javascript_runtime.go
+8
-8
未找到文件。
ethereal/ext_app.go
浏览文件 @
0c132e4c
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
)
...
...
@@ -25,8 +24,8 @@ type AppContainer interface {
type
ExtApplication
struct
{
*
ethpub
.
PEthereum
blockChan
chan
eth
react
.
Even
t
changeChan
chan
eth
react
.
Even
t
blockChan
chan
eth
util
.
Reac
t
changeChan
chan
eth
util
.
Reac
t
quitChan
chan
bool
watcherQuitChan
chan
bool
...
...
@@ -38,8 +37,8 @@ type ExtApplication struct {
func
NewExtApplication
(
container
AppContainer
,
lib
*
UiLib
)
*
ExtApplication
{
app
:=
&
ExtApplication
{
ethpub
.
NewPEthereum
(
lib
.
eth
),
make
(
chan
eth
react
.
Event
),
make
(
chan
eth
react
.
Event
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
bool
),
make
(
chan
bool
),
container
,
...
...
ethereal/gui.go
浏览文件 @
0c132e4c
...
...
@@ -8,7 +8,6 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/go-ethereum/utils"
...
...
@@ -144,7 +143,7 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
gui
.
readPreviousTransactions
()
gui
.
setPeerInfo
()
gui
.
update
()
g
o
g
ui
.
update
()
return
win
,
nil
}
...
...
@@ -267,10 +266,20 @@ func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
func
(
gui
*
Gui
)
update
()
{
reactor
:=
gui
.
eth
.
Reactor
()
blockChan
:=
make
(
chan
ethreact
.
Event
)
txChan
:=
make
(
chan
ethreact
.
Event
)
objectChan
:=
make
(
chan
ethreact
.
Event
)
peerChan
:=
make
(
chan
ethreact
.
Event
)
blockChan
:=
make
(
chan
ethutil
.
React
,
1
)
txChan
:=
make
(
chan
ethutil
.
React
,
1
)
objectChan
:=
make
(
chan
ethutil
.
React
,
1
)
peerChan
:=
make
(
chan
ethutil
.
React
,
1
)
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
reactor
.
Subscribe
(
"newTx:pre"
,
txChan
)
reactor
.
Subscribe
(
"newTx:post"
,
txChan
)
nameReg
:=
ethpub
.
EthereumConfig
(
gui
.
eth
.
StateManager
())
.
NameReg
()
if
nameReg
!=
nil
{
reactor
.
Subscribe
(
"object:"
+
string
(
nameReg
.
Address
()),
objectChan
)
}
reactor
.
Subscribe
(
"peerList"
,
peerChan
)
ticker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
...
...
@@ -279,66 +288,54 @@ func (gui *Gui) update() {
unconfirmedFunds
:=
new
(
big
.
Int
)
gui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
fmt
.
Sprintf
(
"%v"
,
ethutil
.
CurrencyToString
(
state
.
GetAccount
(
gui
.
address
())
.
Amount
)))
go
func
()
{
for
{
select
{
case
b
:=
<-
blockChan
:
block
:=
b
.
Resource
.
(
*
ethchain
.
Block
)
gui
.
processBlock
(
block
,
false
)
if
bytes
.
Compare
(
block
.
Coinbase
,
gui
.
address
())
==
0
{
gui
.
setWalletValue
(
gui
.
eth
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Amount
,
nil
)
}
for
{
select
{
case
b
:=
<-
blockChan
:
block
:=
b
.
Resource
.
(
*
ethchain
.
Block
)
gui
.
processBlock
(
block
,
false
)
if
bytes
.
Compare
(
block
.
Coinbase
,
gui
.
address
())
==
0
{
gui
.
setWalletValue
(
gui
.
eth
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Amount
,
nil
)
}
case
txMsg
:=
<-
txChan
:
tx
:=
txMsg
.
Resource
.
(
*
ethchain
.
Transaction
)
case
txMsg
:=
<-
txChan
:
tx
:=
txMsg
.
Resource
.
(
*
ethchain
.
Transaction
)
if
txMsg
.
Name
==
"newTx:pre"
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
txMsg
.
Event
==
"newTx:pre"
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"send"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"send"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"recv"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"recv"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Amount
,
unconfirmedFunds
)
}
else
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Amount
,
unconfirmedFunds
)
}
else
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Amount
,
nil
)
gui
.
setWalletValue
(
object
.
Amount
,
nil
)
state
.
UpdateStateObject
(
object
)
}
case
<-
objectChan
:
gui
.
loadAddressBook
()
case
<-
peerChan
:
gui
.
setPeerInfo
()
case
<-
ticker
.
C
:
gui
.
setPeerInfo
()
state
.
UpdateStateObject
(
object
)
}
case
<-
objectChan
:
gui
.
loadAddressBook
()
case
<-
peerChan
:
gui
.
setPeerInfo
()
case
<-
ticker
.
C
:
gui
.
setPeerInfo
()
}
}()
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
reactor
.
Subscribe
(
"newTx:pre"
,
txChan
)
reactor
.
Subscribe
(
"newTx:post"
,
txChan
)
nameReg
:=
ethpub
.
EthereumConfig
(
gui
.
eth
.
StateManager
())
.
NameReg
()
if
nameReg
!=
nil
{
reactor
.
Subscribe
(
"object:"
+
string
(
nameReg
.
Address
()),
objectChan
)
}
reactor
.
Subscribe
(
"peerList"
,
peerChan
)
}
func
(
gui
*
Gui
)
setPeerInfo
()
{
...
...
ethereum/javascript_runtime.go
浏览文件 @
0c132e4c
...
...
@@ -6,7 +6,6 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/obscuren/otto"
...
...
@@ -23,8 +22,8 @@ type JSRE struct {
vm
*
otto
.
Otto
lib
*
ethpub
.
PEthereum
blockChan
chan
eth
react
.
Even
t
changeChan
chan
eth
react
.
Even
t
blockChan
chan
eth
util
.
Reac
t
changeChan
chan
eth
util
.
Reac
t
quitChan
chan
bool
objectCb
map
[
string
][]
otto
.
Value
...
...
@@ -49,8 +48,8 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
ethereum
,
otto
.
New
(),
ethpub
.
NewPEthereum
(
ethereum
),
make
(
chan
eth
react
.
Event
),
make
(
chan
eth
react
.
Event
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
bool
),
make
(
map
[
string
][]
otto
.
Value
),
}
...
...
@@ -64,9 +63,6 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
// We have to make sure that, whoever calls this, calls "Stop"
go
re
.
mainLoop
()
// Subscribe to events
reactor
:=
ethereum
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
re
.
blockChan
)
re
.
Bind
(
"eth"
,
&
JSEthereum
{
re
.
lib
,
re
.
vm
})
...
...
@@ -112,6 +108,10 @@ func (self *JSRE) Stop() {
}
func
(
self
*
JSRE
)
mainLoop
()
{
// Subscribe to events
reactor
:=
self
.
ethereum
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
self
.
blockChan
)
out
:
for
{
select
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录