From 10782c5aae51a766ab583a9d563cb2ff8a64e89d Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 27 Oct 2014 17:02:31 +0100 Subject: [PATCH] Added removal off erroneous txs. Fixed pipeline --- ethminer/miner.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ethminer/miner.go b/ethminer/miner.go index 9fca9961a8..e0bef078b2 100644 --- a/ethminer/miner.go +++ b/ethminer/miner.go @@ -81,18 +81,19 @@ func (miner *Miner) Stop() { } func (miner *Miner) listener() { - for { - miner.startMining() + miner.startMining() + for { select { case event, isopen := <-miner.events.Chan(): - miner.stopMining() if !isopen { return } switch event := event.(type) { case ethchain.NewBlockEvent: + miner.stopMining() + block := event.Block //logger.Infoln("Got new block via Reactor") if bytes.Compare(miner.ethereum.ChainManager().CurrentBlock.Hash(), block.Hash()) == 0 { @@ -126,6 +127,8 @@ func (miner *Miner) listener() { case ethchain.TxEvent: if event.Type == ethchain.TxPre { + miner.stopMining() + found := false for _, ctx := range miner.txs { if found = bytes.Compare(ctx.Hash(), event.Tx.Hash()) == 0; found { @@ -142,7 +145,7 @@ func (miner *Miner) listener() { } case <-miner.powDone: - // next iteration will start mining again + miner.startMining() } } } @@ -178,10 +181,11 @@ func (self *Miner) mineNewBlock() { parent := self.ethereum.ChainManager().GetBlock(self.block.PrevHash) coinbase := self.block.State().GetOrNewStateObject(self.block.Coinbase) coinbase.SetGasPool(self.block.CalcGasLimit(parent)) - receipts, txs, unhandledTxs, err := stateManager.ProcessTransactions(coinbase, self.block.State(), self.block, self.block, self.txs) + receipts, txs, unhandledTxs, erroneous, err := stateManager.ProcessTransactions(coinbase, self.block.State(), self.block, self.block, self.txs) if err != nil { logger.Debugln(err) } + self.ethereum.TxPool().RemoveSet(erroneous) self.txs = append(txs, unhandledTxs...) self.block.SetTxHash(receipts)