"github.com/vapor/protocol/vm/vmutil"
)
+const logModule = "mining"
+
// 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)
+ amount += consensus.BlockSubsidy(blockHeight)
arbitrary := append([]byte{0x00}, []byte(strconv.FormatUint(blockHeight, 10))...)
var script []byte
if err = builder.AddInput(types.NewCoinbaseInput(arbitrary), &txbuilder.SigningInstruction{}); err != nil {
return nil, err
}
- if err = builder.AddOutput(types.NewTxOutput(*consensus.BTMAssetID, amount, script)); err != nil {
+ if err = builder.AddOutput(types.NewIntraChainOutput(*consensus.BTMAssetID, amount, script)); err != nil {
return nil, err
}
_, txData, err := builder.Build()
Version: 1,
Height: nextBlockHeight,
PreviousBlockHash: preBlockHash,
- Timestamp: uint64(time.Now().Unix()),
+ Timestamp: uint64(time.Now().UnixNano() / int64(time.Millisecond)),
BlockCommitment: types.BlockCommitment{},
},
}
break
}
}
- if txFee == 0 {
- return nil, err
- }
+
// creater coinbase transaction
b.Transactions[0], err = createCoinbaseTx(accountManager, txFee, nextBlockHeight)
if err != nil {
}
func blkGenSkipTxForErr(txPool *protocol.TxPool, txHash *bc.Hash, err error) {
- log.WithField("error", err).Error("mining block generation: skip tx due to")
+ log.WithFields(log.Fields{"module": logModule, "error": err}).Error("mining block generation: skip tx due to")
txPool.RemoveTransaction(txHash)
}