diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-21 19:04:40 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-21 19:04:40 +0800 |
commit | 86cf69648efc5029abffbf39f1be7308acb1531e (patch) | |
tree | 4999dcb67888e4dcbe56ec5a5df844e1169e61e1 /ethminer | |
parent | 0e9c8568fd689fdee0cce2584ad96ecce60c60d7 (diff) | |
download | go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.gz go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.tar.zst go-tangerine-86cf69648efc5029abffbf39f1be7308acb1531e.zip |
Improved miner so it won't include invalid transactions
Diffstat (limited to 'ethminer')
-rw-r--r-- | ethminer/miner.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/ethminer/miner.go b/ethminer/miner.go index e052d0207..8d6486e90 100644 --- a/ethminer/miner.go +++ b/ethminer/miner.go @@ -105,14 +105,14 @@ func (miner *Miner) listener() { miner.block.Undo() //log.Infoln("[MINER] We did not know about this transaction, adding") miner.txs = append(miner.txs, tx) - miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs) - miner.block.SetTransactions(miner.txs) } else { //log.Infoln("[MINER] We already had this transaction, ignoring") } } default: - ethutil.Config.Log.Infoln("[MINER] Mining on block. Includes", len(miner.txs), "transactions") + stateManager := miner.ethereum.StateManager() + + miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs) // Apply uncles if len(miner.uncles) > 0 { @@ -120,8 +120,19 @@ func (miner *Miner) listener() { } // Apply all transactions to the block - miner.ethereum.StateManager().ApplyTransactions(miner.block.State(), miner.block, miner.block.Transactions()) - miner.ethereum.StateManager().AccumelateRewards(miner.block.State(), miner.block) + txs := miner.txs + miner.txs = nil + for _, tx := range txs { + if err := stateManager.ApplyTransaction(miner.block.State(), miner.block, tx); err == nil { + miner.txs = append(miner.txs, tx) + } + } + miner.block.SetTransactions(miner.txs) + stateManager.AccumelateRewards(miner.block.State(), miner.block) + + ethutil.Config.Log.Infoln("[MINER] Mining on block. Includes", len(miner.txs), "transactions") + + //miner.ethereum.StateManager().ApplyTransactions(miner.block.State(), miner.block, miner.block.Transactions()) // Search the nonce miner.block.Nonce = miner.pow.Search(miner.block, miner.quitChan) |