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
6b3f5fb8
Commit
6b3f5fb8
authored
Oct 29, 2014
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/mist, ethchain, ethminer: split TxEvent (#165)
parent
5920aa7b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
56 deletions
+48
-56
gui.go
cmd/mist/gui.go
+25
-26
events.go
ethchain/events.go
+7
-7
state_manager.go
ethchain/state_manager.go
+1
-1
transaction_pool.go
ethchain/transaction_pool.go
+2
-7
miner.go
ethminer/miner.go
+13
-15
No files found.
cmd/mist/gui.go
View file @
6b3f5fb8
...
...
@@ -408,7 +408,8 @@ func (gui *Gui) update() {
eth
.
ChainSyncEvent
{},
eth
.
PeerListEvent
{},
ethchain
.
NewBlockEvent
{},
ethchain
.
TxEvent
{},
ethchain
.
TxPreEvent
{},
ethchain
.
TxPostEvent
{},
ethminer
.
Event
{},
)
...
...
@@ -430,9 +431,8 @@ 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
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
...
...
@@ -442,11 +442,12 @@ func (gui *Gui) update() {
}
gui
.
setWalletValue
(
object
.
Balance
(),
unconfirmedFunds
)
gui
.
insertTransaction
(
"pre"
,
tx
)
}
else
if
ev
.
Type
==
ethchain
.
TxPost
{
case
ethchain
.
TxPostEvent
:
tx
:=
ev
.
Tx
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
...
...
@@ -460,9 +461,7 @@ func (gui *Gui) update() {
}
gui
.
setWalletValue
(
object
.
Balance
(),
nil
)
state
.
UpdateStateObject
(
object
)
}
// case object:
// gui.loadAddressBook()
...
...
ethchain/events.go
View file @
6b3f5fb8
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
View file @
6b3f5fb8
...
...
@@ -190,7 +190,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
View file @
6b3f5fb8
...
...
@@ -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
View file @
6b3f5fb8
...
...
@@ -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())
...
...
@@ -125,8 +125,7 @@ func (miner *Miner) listener() {
}
}
case
ethchain
.
TxEvent
:
if
event
.
Type
==
ethchain
.
TxPre
{
case
ethchain
.
TxPreEvent
:
miner
.
stopMining
()
found
:=
false
...
...
@@ -142,7 +141,6 @@ func (miner *Miner) listener() {
miner
.
txs
=
append
(
miner
.
txs
,
event
.
Tx
)
}
}
}
case
<-
miner
.
powDone
:
miner
.
startMining
()
...
...
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