OSDN Git Service

Hulk did something
[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.TransactionsRoot)
15         mustWriteForHash(w, bh.TransactionStatusHash)
16         mustWriteForHash(w, bh.Bits)
17         mustWriteForHash(w, bh.Nonce)
18 }
19
20 // NewBlockHeader creates a new BlockHeader and populates
21 // its body.
22 func NewBlockHeader(version, height uint64, previousBlockID *Hash, timestamp uint64, transactionsRoot, transactionStatusHash *Hash, nonce, bits uint64) *BlockHeader {
23         return &BlockHeader{
24                 Version:               version,
25                 Height:                height,
26                 PreviousBlockId:       previousBlockID,
27                 Timestamp:             timestamp,
28                 TransactionsRoot:      transactionsRoot,
29                 TransactionStatusHash: transactionStatusHash,
30                 TransactionStatus:     nil,
31                 Bits:                  bits,
32                 Nonce:                 nonce,
33         }
34 }