- txs := txPool.GetTransactions()
- sort.Sort(byTime(txs))
- for _, txDesc := range txs {
- tx := txDesc.Tx.Tx
- gasOnlyTx := false
-
- if err := c.GetTransactionsUtxo(view, []*bc.Tx{tx}); err != nil {
- blkGenSkipTxForErr(txPool, &tx.ID, err)
- continue
- }
-
- gasStatus, err := validation.ValidateTx(tx, bcBlock)
- if err != nil {
- if !gasStatus.GasValid {
- blkGenSkipTxForErr(txPool, &tx.ID, err)
- continue
- }
- gasOnlyTx = true
- }
-
- if gasUsed+uint64(gasStatus.GasUsed) > consensus.MaxBlockGas {
- break
- }
-
- if err := view.ApplyTransaction(bcBlock, tx, gasOnlyTx); err != nil {
- blkGenSkipTxForErr(txPool, &tx.ID, err)
- continue
- }
-
- if err := txStatus.SetStatus(len(b.Transactions), gasOnlyTx); err != nil {
- return nil, err
- }
-
- b.Transactions = append(b.Transactions, txDesc.Tx)
- txEntries = append(txEntries, tx)
- gasUsed += uint64(gasStatus.GasUsed)
- txFee += txDesc.Fee
-
- if gasUsed == consensus.MaxBlockGas {
- break
- }
- }
- if txFee == 0 {