// createCoinbaseTx returns a coinbase transaction paying an appropriate subsidy
// based on the passed block height to the provided address. When the address
// is nil, the coinbase transaction will instead be redeemable by anyone.
func createCoinbaseTx(accountManager *account.Manager, amount uint64, blockHeight uint64) (tx *types.Tx, err error) {
amount += consensus.BlockSubsidy(blockHeight)
// createCoinbaseTx returns a coinbase transaction paying an appropriate subsidy
// based on the passed block height to the provided address. When the address
// is nil, the coinbase transaction will instead be redeemable by anyone.
func createCoinbaseTx(accountManager *account.Manager, amount uint64, blockHeight uint64) (tx *types.Tx, err error) {
amount += consensus.BlockSubsidy(blockHeight)
var script []byte
if accountManager == nil {
script, err = vmutil.DefaultCoinbaseProgram()
} else {
script, err = accountManager.GetCoinbaseControlProgram()
var script []byte
if accountManager == nil {
script, err = vmutil.DefaultCoinbaseProgram()
} else {
script, err = accountManager.GetCoinbaseControlProgram()
}
// NewBlockTemplate returns a new block template that is ready to be solved
func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager *account.Manager) (b *types.Block, err error) {
view := state.NewUtxoViewpoint()
txStatus := bc.NewTransactionStatus()
}
// NewBlockTemplate returns a new block template that is ready to be solved
func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager *account.Manager) (b *types.Block, err error) {
view := state.NewUtxoViewpoint()
txStatus := bc.NewTransactionStatus()
for _, txDesc := range txs {
tx := txDesc.Tx.Tx
gasOnlyTx := false
if err := c.GetTransactionsUtxo(view, []*bc.Tx{tx}); err != nil {
for _, txDesc := range txs {
tx := txDesc.Tx.Tx
gasOnlyTx := false
if err := c.GetTransactionsUtxo(view, []*bc.Tx{tx}); err != nil {
- log.WithField("error", err).Error("mining block generate skip tx due to")
- txPool.RemoveTransaction(&tx.ID)
+ blkGenSkipTxForErr(txPool, &tx.ID, err)
- log.WithField("error", err).Error("mining block generate skip tx due to")
- txPool.RemoveTransaction(&tx.ID)
+ blkGenSkipTxForErr(txPool, &tx.ID, err)
- log.WithField("error", err).Error("mining block generate skip tx due to")
- txPool.RemoveTransaction(&tx.ID)
+ blkGenSkipTxForErr(txPool, &tx.ID, err)
b.Transactions = append(b.Transactions, txDesc.Tx)
txEntries = append(txEntries, tx)
gasUsed += uint64(gasStatus.GasUsed)
b.Transactions = append(b.Transactions, txDesc.Tx)
txEntries = append(txEntries, tx)
gasUsed += uint64(gasStatus.GasUsed)
+
+func blkGenSkipTxForErr(txPool *protocol.TxPool, txHash *bc.Hash, err error) {
+ log.WithFields(log.Fields{"module": logModule, "error": err}).Error("mining block generation: skip tx due to")
+ txPool.RemoveTransaction(txHash)
+}