From 9988b1a04710e03ce7ed4b23393e2e90f06889f9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 May 2014 12:06:09 +0200 Subject: Sort transactions based on the nonce * Added a transaction sorter --- ethminer/miner.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ethminer') diff --git a/ethminer/miner.go b/ethminer/miner.go index 00e04cde2..9396d33f9 100644 --- a/ethminer/miner.go +++ b/ethminer/miner.go @@ -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 -- cgit v1.2.3