aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-08-04 03:57:09 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-08-05 23:44:19 +0800
commit35f271b264b8e4a0449eff325fb75a78299cf9a6 (patch)
tree750fe404c14b6f5e8ef03a07cf3357787c6c9683 /miner
parentf12e0161ca7ed2bc5034a7b4904e1b5032e41fe7 (diff)
downloaddexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.tar
dexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.tar.gz
dexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.tar.bz2
dexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.tar.lz
dexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.tar.xz
dexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.tar.zst
dexon-35f271b264b8e4a0449eff325fb75a78299cf9a6.zip
miner, core: sort txs by price, nonce
Diffstat (limited to 'miner')
-rw-r--r--miner/worker.go35
1 files changed, 34 insertions, 1 deletions
diff --git a/miner/worker.go b/miner/worker.go
index 269219ba0..535ce5144 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -457,9 +457,42 @@ func (self *worker) commitNewWork() {
self.makeCurrent(parent, header)
work := self.current
- // commit transactions for this run.
+ /* //approach 1
transactions := self.eth.TxPool().GetTransactions()
sort.Sort(types.TxByNonce{transactions})
+ */
+
+ //approach 2
+ transactions := self.eth.TxPool().GetTransactions()
+ sort.Sort(types.TxByPriceAndNonce{transactions})
+
+ /* // approach 3
+ // commit transactions for this run.
+ txPerOwner := make(map[common.Address]types.Transactions)
+ // Sort transactions by owner
+ for _, tx := range self.eth.TxPool().GetTransactions() {
+ from, _ := tx.From() // we can ignore the sender error
+ txPerOwner[from] = append(txPerOwner[from], tx)
+ }
+ var (
+ singleTxOwner types.Transactions
+ multiTxOwner types.Transactions
+ )
+ // Categorise transactions by
+ // 1. 1 owner tx per block
+ // 2. multi txs owner per block
+ for _, txs := range txPerOwner {
+ if len(txs) == 1 {
+ singleTxOwner = append(singleTxOwner, txs[0])
+ } else {
+ multiTxOwner = append(multiTxOwner, txs...)
+ }
+ }
+ sort.Sort(types.TxByPrice{singleTxOwner})
+ sort.Sort(types.TxByNonce{multiTxOwner})
+ transactions := append(singleTxOwner, multiTxOwner...)
+ */
+
work.coinbase.SetGasLimit(header.GasLimit)
work.commitTransactions(transactions, self.gasPrice, self.proc)
self.eth.TxPool().RemoveTransactions(work.lowGasTxs)