OSDN Git Service

Merge pull request #22 from Bytom/dev_tools_for_transaction
[bytom/vapor.git] / protocol / bc / bytom_blockheader.go
1 package bc
2
3 import "io"
4
5 func (BytomBlockHeader) typ() string { return "blockheader" }
6 func (bh *BytomBlockHeader) writeForHash(w io.Writer) {
7         mustWriteForHash(w, bh.Version)
8         mustWriteForHash(w, bh.Height)
9         mustWriteForHash(w, bh.PreviousBlockId)
10         mustWriteForHash(w, bh.Timestamp)
11         mustWriteForHash(w, bh.TransactionsRoot)
12         mustWriteForHash(w, bh.TransactionStatusHash)
13         mustWriteForHash(w, bh.Bits)
14         mustWriteForHash(w, bh.Nonce)
15 }
16
17 // NewBytomBlockHeader creates a new BlockHeader and populates
18 // its body.
19 func NewBytomBlockHeader(version, height uint64, previousBlockID *Hash, timestamp uint64, transactionsRoot, transactionStatusHash *Hash, nonce, bits uint64) *BytomBlockHeader {
20         return &BytomBlockHeader{
21                 Version:               version,
22                 Height:                height,
23                 PreviousBlockId:       previousBlockID,
24                 Timestamp:             timestamp,
25                 TransactionsRoot:      transactionsRoot,
26                 TransactionStatusHash: transactionStatusHash,
27                 TransactionStatus:     nil,
28                 Bits:                  bits,
29                 Nonce:                 nonce,
30         }
31 }