OSDN Git Service

Handle the abnormal exit situation
[bytom/vapor.git] / protocol / bc / types / dpos.go
1 package types
2
3 import (
4         "github.com/vapor/protocol/bc"
5 )
6
7 type DposTx struct {
8         SpendCommitmentSuffix []byte
9         Type                  TxType
10         From                  string
11         To                    string
12         Amount                uint64
13         Stake                 uint64
14         Arguments             [][]byte
15         Info                  string
16         SpendCommitment
17 }
18
19 func NewDpos(arguments [][]byte, from, to string, sourceID bc.Hash, assetID bc.AssetID, stake, amount, sourcePos uint64, controlProgram []byte, t TxType, height uint64) *TxInput {
20         var vote string
21
22         sc := SpendCommitment{
23                 AssetAmount: bc.AssetAmount{
24                         AssetId: &assetID,
25                         Amount:  amount,
26                 },
27                 SourceID:       sourceID,
28                 SourcePosition: sourcePos,
29                 VMVersion:      1,
30                 ControlProgram: controlProgram,
31         }
32
33         return &TxInput{
34                 AssetVersion: 1,
35                 TypedInput: &DposTx{
36                         SpendCommitment: sc,
37                         Type:            t,
38                         Amount:          amount,
39                         Arguments:       arguments,
40                         Info:            vote,
41                         Stake:           stake,
42                         From:            from,
43                         To:              to,
44                 },
45         }
46 }
47
48 // InputType is the interface function for return the input type.
49 func (si *DposTx) InputType() uint8 { return DposInputType }