Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
fa890c8c
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,发现更多精彩内容 >>
提交
fa890c8c
编写于
10月 29, 2014
作者:
J
Jeffrey Wilcke
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #167 from fjl/feature/split-tx-event
Split TxEvent type for tx pre/post
上级
ce2ec198
6b3f5fb8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
56 deletion
+48
-56
cmd/mist/gui.go
cmd/mist/gui.go
+25
-26
ethchain/events.go
ethchain/events.go
+7
-7
ethchain/state_manager.go
ethchain/state_manager.go
+1
-1
ethchain/transaction_pool.go
ethchain/transaction_pool.go
+2
-7
ethminer/miner.go
ethminer/miner.go
+13
-15
未找到文件。
cmd/mist/gui.go
浏览文件 @
fa890c8c
...
...
@@ -408,7 +408,8 @@ func (gui *Gui) update() {
eth
.
ChainSyncEvent
{},
eth
.
PeerListEvent
{},
ethchain
.
NewBlockEvent
{},
ethchain
.
TxEvent
{},
ethchain
.
TxPreEvent
{},
ethchain
.
TxPostEvent
{},
ethminer
.
Event
{},
)
...
...
@@ -430,40 +431,38 @@ func (gui *Gui) update() {
gui
.
setWalletValue
(
gui
.
eth
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Balance
(),
nil
)
}
case
ethchain
.
TxEvent
:
case
ethchain
.
Tx
Pre
Event
:
tx
:=
ev
.
Tx
if
ev
.
Type
==
ethchain
.
TxPre
{
object
:=
state
.
GetAccount
(
gui
.
address
())
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Balance
(),
unconfirmedFunds
)
gui
.
insertTransaction
(
"pre"
,
tx
)
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
}
else
if
ev
.
Type
==
ethchain
.
TxPost
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
gui
.
setWalletValue
(
object
.
Balance
(),
unconfirmedFunds
)
gui
.
insertTransaction
(
"pre"
,
tx
)
//gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "send")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
case
ethchain
.
TxPostEvent
:
tx
:=
ev
.
Tx
object
:=
state
.
GetAccount
(
gui
.
address
())
//gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "recv")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
gui
.
setWalletValue
(
object
.
Balance
(),
nil
)
//gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "send")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
state
.
UpdateStateObject
(
object
)
//gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "recv")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
gui
.
setWalletValue
(
object
.
Balance
(),
nil
)
state
.
UpdateStateObject
(
object
)
// case object:
// gui.loadAddressBook()
...
...
ethchain/events.go
浏览文件 @
fa890c8c
package
ethchain
type
TxEvent
struct
{
Type
int
// TxPre || TxPost
Tx
*
Transaction
}
// TxPreEvent is posted when a transaction enters the transaction pool.
type
TxPreEvent
struct
{
Tx
*
Transaction
}
type
NewBlockEvent
struct
{
Block
*
Block
}
// TxPostEvent is posted when a transaction has been processed.
type
TxPostEvent
struct
{
Tx
*
Transaction
}
// NewBlockEvent is posted when a block has been imported.
type
NewBlockEvent
struct
{
Block
*
Block
}
ethchain/state_manager.go
浏览文件 @
fa890c8c
...
...
@@ -191,7 +191,7 @@ done:
}
// Notify all subscribers
self
.
eth
.
EventMux
()
.
Post
(
Tx
Event
{
TxPost
,
tx
})
self
.
eth
.
EventMux
()
.
Post
(
Tx
PostEvent
{
tx
})
receipts
=
append
(
receipts
,
receipt
)
handled
=
append
(
handled
,
tx
)
...
...
ethchain/transaction_pool.go
浏览文件 @
fa890c8c
...
...
@@ -14,17 +14,12 @@ import (
var
txplogger
=
ethlog
.
NewLogger
(
"TXP"
)
const
(
txPoolQueueSize
=
50
)
const
txPoolQueueSize
=
50
type
TxPoolHook
chan
*
Transaction
type
TxMsgTy
byte
const
(
TxPre
=
iota
TxPost
minGasPrice
=
1000000
)
...
...
@@ -169,7 +164,7 @@ out:
txplogger
.
Debugf
(
"(t) %x => %x (%v) %x
\n
"
,
tx
.
Sender
()[
:
4
],
tmp
,
tx
.
Value
,
tx
.
Hash
())
// Notify the subscribers
pool
.
Ethereum
.
EventMux
()
.
Post
(
Tx
Event
{
TxPre
,
tx
})
pool
.
Ethereum
.
EventMux
()
.
Post
(
Tx
PreEvent
{
tx
})
}
case
<-
pool
.
quit
:
break
out
...
...
ethminer/miner.go
浏览文件 @
fa890c8c
...
...
@@ -64,7 +64,7 @@ func (miner *Miner) Start() {
miner
.
block
=
miner
.
ethereum
.
ChainManager
()
.
NewBlock
(
miner
.
coinbase
)
mux
:=
miner
.
ethereum
.
EventMux
()
miner
.
events
=
mux
.
Subscribe
(
ethchain
.
NewBlockEvent
{},
ethchain
.
TxEvent
{})
miner
.
events
=
mux
.
Subscribe
(
ethchain
.
NewBlockEvent
{},
ethchain
.
Tx
Pre
Event
{})
// Prepare inital block
//miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State())
...
...
@@ -118,25 +118,23 @@ func (miner *Miner) listener() {
}
miner
.
startMining
()
case
ethchain
.
TxEvent
:
if
event
.
Type
==
ethchain
.
TxPre
{
miner
.
stopMining
()
case
ethchain
.
TxPreEvent
:
miner
.
stopMining
()
found
:=
false
for
_
,
ctx
:=
range
miner
.
txs
{
if
found
=
bytes
.
Compare
(
ctx
.
Hash
(),
event
.
Tx
.
Hash
())
==
0
;
found
{
break
}
}
if
found
==
false
{
// Undo all previous commits
miner
.
block
.
Undo
()
// Apply new transactions
miner
.
txs
=
append
(
miner
.
txs
,
event
.
Tx
)
found
:=
false
for
_
,
ctx
:=
range
miner
.
txs
{
if
found
=
bytes
.
Compare
(
ctx
.
Hash
(),
event
.
Tx
.
Hash
())
==
0
;
found
{
break
}
miner
.
startMining
()
}
if
found
==
false
{
// Undo all previous commits
miner
.
block
.
Undo
()
// Apply new transactions
miner
.
txs
=
append
(
miner
.
txs
,
event
.
Tx
)
}
}
case
<-
miner
.
powDone
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录