OSDN Git Service

Added blockchain struct.
[bytom/bytom.git] / protocol / bc / issuance.go
1 package bc
2
3 import "io"
4
5 // Issuance is a source of new value on a blockchain. It satisfies the
6 // Entry interface.
7 //
8 // (Not to be confused with the deprecated type IssuanceInput.)
9
10 func (Issuance) typ() string { return "issuance1" }
11 func (iss *Issuance) writeForHash(w io.Writer) {
12         mustWriteForHash(w, iss.AnchorId)
13         mustWriteForHash(w, iss.Value)
14         mustWriteForHash(w, iss.Data)
15         mustWriteForHash(w, iss.ExtHash)
16 }
17
18 func (iss *Issuance) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
19         iss.WitnessDestination = &ValueDestination{
20                 Ref:      id,
21                 Value:    val,
22                 Position: pos,
23         }
24 }
25
26 // NewIssuance creates a new Issuance.
27 func NewIssuance(anchorID *Hash, value *AssetAmount, data *Hash, ordinal uint64) *Issuance {
28         return &Issuance{
29                 AnchorId: anchorID,
30                 Value:    value,
31                 Data:     data,
32                 Ordinal:  ordinal,
33         }
34 }