aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-15 23:16:27 +0800
committerobscuren <geffobscura@gmail.com>2015-02-15 23:16:27 +0800
commit2c3a014f03390628d329167109f90a30e3c4e4c3 (patch)
tree86455bc3af1cb3aca9e6c940b03b534840f23de9
parentc924a841c7a6661b3a609c16c447231f5ae951c8 (diff)
downloadgo-tangerine-2c3a014f03390628d329167109f90a30e3c4e4c3.tar.gz
go-tangerine-2c3a014f03390628d329167109f90a30e3c4e4c3.tar.zst
go-tangerine-2c3a014f03390628d329167109f90a30e3c4e4c3.zip
Resolved some bugs in the miner
* TODO nonce error sometimes persists * Fixed mining on wrong blocks * Fixed state error & receipt fail
-rw-r--r--cmd/mist/assets/qml/views/transaction.qml2
-rw-r--r--core/chain_manager.go2
-rw-r--r--miner/worker.go21
3 files changed, 12 insertions, 13 deletions
diff --git a/cmd/mist/assets/qml/views/transaction.qml b/cmd/mist/assets/qml/views/transaction.qml
index 62c762956..6637346b5 100644
--- a/cmd/mist/assets/qml/views/transaction.qml
+++ b/cmd/mist/assets/qml/views/transaction.qml
@@ -177,7 +177,7 @@ Rectangle {
mainContractColumn.state = "ERROR"
} else {
txResult.text = "Your transaction has been submitted:\n"
- txOutput.text = res[0].address
+ txOutput.text = res.toString()
mainContractColumn.state = "DONE"
console.log(res)
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 54f1ced8c..922d2a8d8 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -392,7 +392,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
self.setTotalDifficulty(td)
self.insert(block)
- self.transState = state.New(cblock.Root(), self.db) //state.New(cblock.Trie().Copy())
+ self.transState = state.New(cblock.Root(), self.db)
self.eventMux.Post(ChainEvent{block, td})
}
diff --git a/miner/worker.go b/miner/worker.go
index 96c8bdd39..2b64f3210 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -4,6 +4,7 @@ import (
"fmt"
"math/big"
"sort"
+ "sync"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@@ -55,6 +56,7 @@ type Agent interface {
}
type worker struct {
+ mu sync.Mutex
agents []Agent
recv chan Work
mux *event.TypeMux
@@ -115,9 +117,7 @@ out:
select {
case event := <-events.Chan():
switch event.(type) {
- case core.ChainEvent:
- self.commitNewWork()
- case core.TxPreEvent:
+ case core.ChainEvent, core.TxPreEvent:
self.commitNewWork()
}
case <-self.quit:
@@ -163,6 +163,9 @@ func (self *worker) push() {
}
func (self *worker) commitNewWork() {
+ self.mu.Lock()
+ defer self.mu.Unlock()
+
self.current = env(self.chain.NewBlock(self.coinbase), self.eth)
parent := self.chain.GetBlock(self.current.block.ParentHash())
self.current.coinbase.SetGasPool(core.CalcGasLimit(parent, self.current.block))
@@ -176,12 +179,11 @@ func (self *worker) commitNewWork() {
err := self.commitTransaction(tx)
switch {
case core.IsNonceErr(err):
+ // Remove invalid transactions
remove = append(remove, tx)
case core.IsGasLimitErr(err):
// Break on gas limit
break
- default:
- remove = append(remove, tx)
}
if err != nil {
@@ -227,16 +229,13 @@ func (self *worker) commitUncle(uncle *types.Header) error {
func (self *worker) commitTransaction(tx *types.Transaction) error {
snapshot := self.current.state.Copy()
- receipt, txGas, err := self.proc.ApplyTransaction(self.current.coinbase, self.current.state, self.current.block, tx, self.current.totalUsedGas, true)
- if err != nil {
- if core.IsNonceErr(err) || core.IsGasLimitErr(err) {
- self.current.state.Set(snapshot)
- }
+ receipt, _, err := self.proc.ApplyTransaction(self.current.coinbase, self.current.state, self.current.block, tx, self.current.totalUsedGas, true)
+ if err != nil && (core.IsNonceErr(err) || core.IsGasLimitErr(err)) {
+ self.current.state.Set(snapshot)
return err
}
- self.current.totalUsedGas.Add(self.current.totalUsedGas, txGas)
self.current.block.AddTransaction(tx)
self.current.block.AddReceipt(receipt)