diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-04-07 16:03:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 16:03:11 +0800 |
commit | cc13d576f07fb6803e09fb42880591a67b8b0ef6 (patch) | |
tree | 6b2371c34416e3697443d836aab3a1f7fc32e77a /miner | |
parent | 71fdaa42386173da7bfa13f1728c394aeeb4eb01 (diff) | |
parent | 158d603528d2ba36b633a8f22a2bff8329f69717 (diff) | |
download | go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.gz go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.bz2 go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.lz go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.xz go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.tar.zst go-tangerine-cc13d576f07fb6803e09fb42880591a67b8b0ef6.zip |
Merge pull request #13870 from karalabe/miners-fixes
all: clean up various error handling in core and the miner
Diffstat (limited to 'miner')
-rw-r--r-- | miner/worker.go | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/miner/worker.go b/miner/worker.go index 347de4e08..8a67b12a6 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -279,21 +279,11 @@ func (self *worker) wait() { go self.mux.Post(core.NewMinedBlockEvent{Block: block}) } else { work.state.Commit(self.config.IsEIP158(block.Number())) - parent := self.chain.GetBlock(block.ParentHash(), block.NumberU64()-1) - if parent == nil { - log.Error("Invalid block found during mining") - continue - } - if err := self.engine.VerifyHeader(self.chain, block.Header(), false); err != nil { - log.Error("Invalid header on mined block", "err", err) - continue - } stat, err := self.chain.WriteBlock(block) if err != nil { log.Error("Failed writing block to chain", "err", err) continue } - // update block hash since it is now available and not when the receipt/log of individual transactions were created for _, r := range work.receipts { for _, l := range r.Logs { @@ -513,13 +503,13 @@ func (self *worker) commitNewWork() { func (self *worker) commitUncle(work *Work, uncle *types.Header) error { hash := uncle.Hash() if work.uncles.Has(hash) { - return core.UncleError("uncle not unique") + return fmt.Errorf("uncle not unique") } if !work.ancestors.Has(uncle.ParentHash) { - return core.UncleError(fmt.Sprintf("uncle's parent unknown (%x)", uncle.ParentHash[0:4])) + return fmt.Errorf("uncle's parent unknown (%x)", uncle.ParentHash[0:4]) } if work.family.Has(hash) { - return core.UncleError(fmt.Sprintf("uncle already in family (%x)", hash)) + return fmt.Errorf("uncle already in family (%x)", hash) } work.uncles.Add(uncle.Hash()) return nil @@ -564,23 +554,23 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB env.state.StartRecord(tx.Hash(), common.Hash{}, env.tcount) err, logs := env.commitTransaction(tx, bc, gp) - switch { - case core.IsGasLimitErr(err): + switch err { + case core.ErrGasLimitReached: // Pop the current out-of-gas transaction without shifting in the next from the account log.Trace("Gas limit exceeded for current block", "sender", from) txs.Pop() - case err != nil: - // Pop the current failed transaction without shifting in the next from the account - log.Trace("Transaction failed, will be removed", "hash", tx.Hash(), "err", err) - env.failedTxs = append(env.failedTxs, tx) - txs.Pop() - - default: + case nil: // Everything ok, collect the logs and shift in the next transaction from the same account coalescedLogs = append(coalescedLogs, logs...) env.tcount++ txs.Shift() + + default: + // Pop the current failed transaction without shifting in the next from the account + log.Trace("Transaction failed, will be removed", "hash", tx.Hash(), "err", err) + env.failedTxs = append(env.failedTxs, tx) + txs.Pop() } } |