aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-05-21 19:06:42 +0800
committerMaran <maran.hidskes@gmail.com>2014-05-21 19:06:42 +0800
commit1275e5bdc978d2f22ceb45a61f03d7873f069518 (patch)
tree5e0c2b4b999a754a195be0987b1e3f589c6f852a
parentd658a7f4ab7691783157151912f43c177825b0e8 (diff)
parent86cf69648efc5029abffbf39f1be7308acb1531e (diff)
downloaddexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.tar
dexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.tar.gz
dexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.tar.bz2
dexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.tar.lz
dexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.tar.xz
dexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.tar.zst
dexon-1275e5bdc978d2f22ceb45a61f03d7873f069518.zip
Merge branch 'develop' of github.com:ethereum/eth-go into develop
-rw-r--r--ethchain/state_manager.go12
-rw-r--r--ethminer/miner.go21
-rw-r--r--peer.go1
3 files changed, 23 insertions, 11 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 9fe485b7a..8b56d65bb 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -104,7 +104,7 @@ func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Tra
}
}
-func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transaction) {
+func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transaction) error {
// If there's no recipient, it's a contract
// Check if this is a contract creation traction and if so
// create a contract of this tx.
@@ -115,10 +115,10 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
if contract != nil {
sm.EvalScript(state, contract.Init(), contract, tx, block)
} else {
- ethutil.Config.Log.Infoln("[STATE] Unable to create contract")
+ return fmt.Errorf("[STATE] Unable to create contract")
}
} else {
- ethutil.Config.Log.Infoln("[STATE] contract create:", err)
+ return fmt.Errorf("[STATE] contract create:", err)
}
} else {
err := sm.Ethereum.TxPool().ProcessTransaction(tx, block, false)
@@ -126,9 +126,11 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
if err == nil && contract != nil && len(contract.Script()) > 0 {
sm.EvalScript(state, contract.Script(), contract, tx, block)
} else if err != nil {
- ethutil.Config.Log.Infoln("[STATE] process:", err)
+ return fmt.Errorf("[STATE] process:", err)
}
}
+
+ return nil
}
func (sm *StateManager) Process(block *Block, dontReact bool) error {
@@ -184,7 +186,7 @@ func (sm *StateManager) ProcessBlock(state *State, parent, block *Block, dontRea
//if !sm.compState.Cmp(state) {
if !block.State().Cmp(state) {
- return fmt.Errorf("Invalid merkle root. Expected %x, got %x", block.State().trie.Root, state.trie.Root)
+ return fmt.Errorf("Invalid merkle root.\nrec: %x\nis: %x", block.State().trie.Root, state.trie.Root)
}
// Calculate the new total difficulty and sync back to the db
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)
diff --git a/peer.go b/peer.go
index 5c46b73fb..7f81489b6 100644
--- a/peer.go
+++ b/peer.go
@@ -381,7 +381,6 @@ func (p *Peer) HandleInbound() {
}
case ethwire.MsgTxTy:
- fmt.Println("received tx")
// If the message was a transaction queue the transaction
// in the TxPool where it will undergo validation and
// processing when a new block is found