aboutsummaryrefslogtreecommitdiffstats
path: root/ethminer/miner.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <obscuren@users.noreply.github.com>2014-10-30 04:10:04 +0800
committerJeffrey Wilcke <obscuren@users.noreply.github.com>2014-10-30 04:10:04 +0800
commitfa890c8c0140dac1e02038a6134db0d83bb85af9 (patch)
tree806fb16adbbec3bcd3ff93b8dfbdcdb73290fabb /ethminer/miner.go
parentce2ec1980bbc97fb9b2acc27c6249be1249fa44c (diff)
parent6b3f5fb82b0304f477a1c36b68b0d07232405aff (diff)
downloaddexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar
dexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.gz
dexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.bz2
dexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.lz
dexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.xz
dexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.zst
dexon-fa890c8c0140dac1e02038a6134db0d83bb85af9.zip
Merge pull request #167 from fjl/feature/split-tx-event
Split TxEvent type for tx pre/post
Diffstat (limited to 'ethminer/miner.go')
-rw-r--r--ethminer/miner.go28
1 files changed, 13 insertions, 15 deletions
diff --git a/ethminer/miner.go b/ethminer/miner.go
index 24af7fbcb..57cf0cd57 100644
--- a/ethminer/miner.go
+++ b/ethminer/miner.go
@@ -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.TxPreEvent{})
// 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: