|
|
@ -457,9 +457,42 @@ func (self *worker) commitNewWork() { |
|
|
|
self.makeCurrent(parent, header) |
|
|
|
self.makeCurrent(parent, header) |
|
|
|
work := self.current |
|
|
|
work := self.current |
|
|
|
|
|
|
|
|
|
|
|
// commit transactions for this run.
|
|
|
|
/* //approach 1
|
|
|
|
transactions := self.eth.TxPool().GetTransactions() |
|
|
|
transactions := self.eth.TxPool().GetTransactions() |
|
|
|
sort.Sort(types.TxByNonce{transactions}) |
|
|
|
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.coinbase.SetGasLimit(header.GasLimit) |
|
|
|
work.commitTransactions(transactions, self.gasPrice, self.proc) |
|
|
|
work.commitTransactions(transactions, self.gasPrice, self.proc) |
|
|
|
self.eth.TxPool().RemoveTransactions(work.lowGasTxs) |
|
|
|
self.eth.TxPool().RemoveTransactions(work.lowGasTxs) |
|
|
|