Sort transactions based on the nonce

* Added a transaction sorter
This commit is contained in:
obscuren
2014-05-28 12:06:09 +02:00
parent 73761f7af6
commit 9988b1a047
2 changed files with 16 additions and 17 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"sort"
)
type Miner struct {
@ -12,7 +13,7 @@ type Miner struct {
ethereum ethchain.EthManager
coinbase []byte
reactChan chan ethutil.React
txs []*ethchain.Transaction
txs ethchain.Transactions
uncles []*ethchain.Block
block *ethchain.Block
powChan chan []byte
@ -132,6 +133,8 @@ func (self *Miner) mineNewBlock() {
self.block.SetUncles(self.uncles)
}
// Sort the transactions by nonce in case of odd network propagation
sort.Sort(ethchain.TxByNonce{self.txs})
// Accumulate all valid transaction and apply them to the new state
receipts, txs := stateManager.ApplyTransactions(self.block.State(), self.block, self.txs)
self.txs = txs