OSDN Git Service

doc: add cross-chain tx api doc (#154)
[bytom/vapor.git] / proposal / proposal.go
index 364d9ff..46382e2 100644 (file)
@@ -69,7 +69,7 @@ func createCoinbaseTx(accountManager *account.Manager, amount uint64, blockHeigh
 }
 
 // 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) {
+func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager *account.Manager, timestamp uint64) (b *types.Block, err error) {
        view := state.NewUtxoViewpoint()
        txStatus := bc.NewTransactionStatus()
        if err := txStatus.SetStatus(0, false); err != nil {
@@ -89,8 +89,9 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager
                        Version:           1,
                        Height:            nextBlockHeight,
                        PreviousBlockHash: preBlockHash,
-                       Timestamp:         uint64(time.Now().UnixNano() / int64(time.Millisecond)),
+                       Timestamp:         timestamp,
                        BlockCommitment:   types.BlockCommitment{},
+                       BlockWitness:      types.BlockWitness{Witness: make([][]byte, consensus.NumOfConsensusNode)},
                },
        }
        bcBlock := &bc.Block{BlockHeader: &bc.BlockHeader{Height: nextBlockHeight}}
@@ -153,7 +154,7 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager
 
        b.BlockHeader.BlockCommitment.TransactionStatusHash, err = types.TxStatusMerkleRoot(txStatus.VerifyStatus)
 
-       _, err = c.GetBBFT().SignBlock(b)
+       _, err = c.SignBlock(b)
        return b, err
 }