OSDN Git Service

add dpos consensus
[bytom/vapor.git] / protocol / bc / blockheader.go
1 package bc
2
3 import "io"
4
5 // BlockHeader contains the header information for a blockchain
6 // block. It satisfies the Entry interface.
7
8 func (BlockHeader) typ() string { return "blockheader" }
9 func (bh *BlockHeader) writeForHash(w io.Writer) {
10         mustWriteForHash(w, bh.Version)
11         mustWriteForHash(w, bh.Height)
12         mustWriteForHash(w, bh.PreviousBlockId)
13         mustWriteForHash(w, bh.Timestamp)
14         //mustWriteForHash(w, bh.Coinbase)
15         mustWriteForHash(w, bh.TransactionsRoot)
16         mustWriteForHash(w, bh.TransactionStatusHash)
17         mustWriteForHash(w, bh.Proof.Sign)
18         mustWriteForHash(w, bh.Proof.ControlProgram)
19         mustWriteForHash(w, bh.Extra)
20 }
21
22 // NewBlockHeader creates a new BlockHeader and populates
23 // its body.
24 func NewBlockHeader(version, height uint64, previousBlockID *Hash, timestamp uint64, transactionsRoot, transactionStatusHash *Hash, proof *Proof, extra []byte, coinbase []byte) *BlockHeader {
25         return &BlockHeader{
26                 Version:               version,
27                 Height:                height,
28                 PreviousBlockId:       previousBlockID,
29                 Timestamp:             timestamp,
30                 TransactionsRoot:      transactionsRoot,
31                 TransactionStatusHash: transactionStatusHash,
32                 TransactionStatus:     nil,
33                 Proof:                 proof,
34                 Extra:                 extra,
35                 Coinbase:              coinbase,
36         }
37 }