OSDN Git Service

Add the implementation for dppos
[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         if h.Side {
16                 mustWriteForHash(w, h.Data)
17         }
18 }
19
20 // NewTxHeader creates an new TxHeader.
21 func NewTxHeader(version, serializedSize uint64, data *Hash, timeRange uint64, resultIDs []*Hash, side bool) *TxHeader {
22         return &TxHeader{
23                 Version:        version,
24                 SerializedSize: serializedSize,
25                 Data:           data,
26                 TimeRange:      timeRange,
27                 ResultIds:      resultIDs,
28                 Side:           side,
29         }
30 }