diff options
author | Péter Szilágyi <peterke@gmail.com> | 2018-08-22 14:46:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-22 14:46:13 +0800 |
commit | 6a8b47c880fc55d8095a2894cd00f7984de6090b (patch) | |
tree | 553f970ffc21ac1a43d49948920da989a74d74d9 /miner | |
parent | b2c644ffb5c283a171ddf3889693673939917541 (diff) | |
parent | e0d0e64ce22111a2d5492fe6f6d6a0023477e51f (diff) | |
download | dexon-6a8b47c880fc55d8095a2894cd00f7984de6090b.tar.gz dexon-6a8b47c880fc55d8095a2894cd00f7984de6090b.tar.zst dexon-6a8b47c880fc55d8095a2894cd00f7984de6090b.zip |
Merge pull request #17472 from karalabe/txpool-locals
cmd, core, miner: add --txpool.locals and priority mining
Diffstat (limited to 'miner')
-rw-r--r-- | miner/worker.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/miner/worker.go b/miner/worker.go index c299ff9dc..8c3337ba4 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -877,11 +877,26 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool) { w.updateSnapshot() return } - txs := types.NewTransactionsByPriceAndNonce(w.current.signer, pending) - if w.commitTransactions(txs, w.coinbase, interrupt) { - return + // Split the pending transactions into locals and remotes + localTxs, remoteTxs := make(map[common.Address]types.Transactions), pending + for _, account := range w.eth.TxPool().Locals() { + if txs := remoteTxs[account]; len(txs) > 0 { + delete(remoteTxs, account) + localTxs[account] = txs + } + } + if len(localTxs) > 0 { + txs := types.NewTransactionsByPriceAndNonce(w.current.signer, localTxs) + if w.commitTransactions(txs, w.coinbase, interrupt) { + return + } + } + if len(remoteTxs) > 0 { + txs := types.NewTransactionsByPriceAndNonce(w.current.signer, remoteTxs) + if w.commitTransactions(txs, w.coinbase, interrupt) { + return + } } - w.commit(uncles, w.fullTaskHook, true, tstart) } |