mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-01 18:57:37 +00:00
refactoring code
This commit is contained in:
parent
cc2cc91e98
commit
7ef8da4fee
1 changed files with 12 additions and 5 deletions
|
|
@ -583,18 +583,21 @@ func (self *worker) commitNewWork() {
|
||||||
if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 {
|
if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 {
|
||||||
misc.ApplyDAOHardFork(work.state)
|
misc.ApplyDAOHardFork(work.state)
|
||||||
}
|
}
|
||||||
specialTxCount := 0
|
|
||||||
// won't grasp txs at checkpoint
|
// won't grasp txs at checkpoint
|
||||||
|
var (
|
||||||
|
txs *types.TransactionsByPriceAndNonce
|
||||||
|
specialTxs types.Transactions
|
||||||
|
)
|
||||||
if self.config.XDPoS != nil && header.Number.Uint64() % self.config.XDPoS.Epoch != 0 {
|
if self.config.XDPoS != nil && header.Number.Uint64() % self.config.XDPoS.Epoch != 0 {
|
||||||
pending, err := self.eth.TxPool().Pending()
|
pending, err := self.eth.TxPool().Pending()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed to fetch pending transactions", "err", err)
|
log.Error("Failed to fetch pending transactions", "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
txs, specialTxs := types.NewTransactionsByPriceAndNonce(self.current.signer, pending, signers)
|
txs, specialTxs = types.NewTransactionsByPriceAndNonce(self.current.signer, pending, signers)
|
||||||
specialTxCount = len(specialTxs)
|
|
||||||
work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase)
|
|
||||||
}
|
}
|
||||||
|
work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase)
|
||||||
|
|
||||||
|
|
||||||
// compute uncles for the new block.
|
// compute uncles for the new block.
|
||||||
var (
|
var (
|
||||||
|
|
@ -626,7 +629,7 @@ func (self *worker) commitNewWork() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if atomic.LoadInt32(&self.mining) == 1 {
|
if atomic.LoadInt32(&self.mining) == 1 {
|
||||||
log.Info("Committing new block", "number", work.Block.Number(), "txs", work.tcount, "special-txs", specialTxCount, "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
|
log.Info("Committing new block", "number", work.Block.Number(), "txs", work.tcount, "special-txs", len(specialTxs), "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
|
||||||
self.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
self.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
||||||
self.lastParentBlockCommit = parent.Hash().Hex()
|
self.lastParentBlockCommit = parent.Hash().Hex()
|
||||||
}
|
}
|
||||||
|
|
@ -702,6 +705,10 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
|
||||||
log.Trace("Not enough gas for further transactions", "gp", gp)
|
log.Trace("Not enough gas for further transactions", "gp", gp)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if txs == nil {
|
||||||
|
log.Info("this block has no transaction")
|
||||||
|
break
|
||||||
|
}
|
||||||
// Retrieve the next transaction and abort if all done
|
// Retrieve the next transaction and abort if all done
|
||||||
tx := txs.Peek()
|
tx := txs.Peek()
|
||||||
if tx == nil {
|
if tx == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue