OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / bytom / protocol / bc / txheader.go
diff --git a/vendor/github.com/bytom/protocol/bc/txheader.go b/vendor/github.com/bytom/protocol/bc/txheader.go
new file mode 100644 (file)
index 0000000..ab24728
--- /dev/null
@@ -0,0 +1,25 @@
+package bc
+
+import "io"
+
+// TxHeader contains header information for a transaction. Every
+// transaction on a blockchain contains exactly one TxHeader. The ID
+// of the TxHeader is the ID of the transaction. TxHeader satisfies
+// the Entry interface.
+
+func (TxHeader) typ() string { return "txheader" }
+func (h *TxHeader) writeForHash(w io.Writer) {
+       mustWriteForHash(w, h.Version)
+       mustWriteForHash(w, h.TimeRange)
+       mustWriteForHash(w, h.ResultIds)
+}
+
+// NewTxHeader creates an new TxHeader.
+func NewTxHeader(version, serializedSize, timeRange uint64, resultIDs []*Hash) *TxHeader {
+       return &TxHeader{
+               Version:        version,
+               SerializedSize: serializedSize,
+               TimeRange:      timeRange,
+               ResultIds:      resultIDs,
+       }
+}