OSDN Git Service

Handle the abnormal exit situation
[bytom/vapor.git] / protocol / bc / dpos.go
1 package bc
2
3 import (
4         "io"
5 )
6
7 func (Dpos) typ() string { return "dpos1" }
8 func (d *Dpos) writeForHash(w io.Writer) {
9         mustWriteForHash(w, d.SpentOutputId)
10         mustWriteForHash(w, d.Type)
11         mustWriteForHash(w, d.From)
12         mustWriteForHash(w, d.To)
13         mustWriteForHash(w, d.Stake)
14 }
15
16 // SetDestination will link the spend to the output
17 func (d *Dpos) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
18         d.WitnessDestination = &ValueDestination{
19                 Ref:      id,
20                 Value:    val,
21                 Position: pos,
22         }
23 }
24
25 // NewDpos creates a new Spend.
26 func NewDpos(spentOutputID *Hash, ordinal uint64, t uint32, stake uint64, from, to, data string) *Dpos {
27         return &Dpos{
28                 SpentOutputId: spentOutputID,
29                 Ordinal:       ordinal,
30                 Type:          t,
31                 From:          from,
32                 To:            to,
33                 Stake:         stake,
34                 Data:          data,
35         }
36 }