OSDN Git Service

048ef73b83991e28f11d3096e9fb46a1e8c0524a
[bytom/vapor.git] / protocol / bc / txheader.go
1 package bc
2
3 import "io"
4
5 // TxHeader contains header information for a transaction. Every
6 // transaction on a blockchain contains exactly one TxHeader. The ID
7 // of the TxHeader is the ID of the transaction. TxHeader satisfies
8 // the Entry interface.
9
10 func (TxHeader) typ() string { return "txheader" }
11 func (h *TxHeader) writeForHash(w io.Writer) {
12         mustWriteForHash(w, h.Version)
13         mustWriteForHash(w, h.TimeRange)
14         mustWriteForHash(w, h.ResultIds)
15         mustWriteForHash(w, h.Data)
16 }
17
18 // NewTxHeader creates an new TxHeader.
19 func NewTxHeader(version, serializedSize uint64, data *Hash, timeRange uint64, resultIDs []*Hash) *TxHeader {
20         return &TxHeader{
21                 Version:        version,
22                 SerializedSize: serializedSize,
23                 Data:           data,
24                 TimeRange:      timeRange,
25                 ResultIds:      resultIDs,
26         }
27 }