OSDN Git Service

9646db9300e098bc31e9b7cc6c245a69fa7f703a
[bytom/vapor.git] / protocol / bc / types / dpos.go
1 package types
2
3 import (
4         "github.com/vapor/protocol/bc"
5 )
6
7 /*
8 const (
9         LoginCandidate DposType = iota
10         LogoutCandidate
11         Delegate
12         UnDelegate
13 )
14 */
15
16 type DposTx struct {
17         SpendCommitmentSuffix []byte
18         Type                  TxType
19         From                  string
20         To                    string
21         Amount                uint64
22         Stake                 uint64
23         PaymentAmount         uint64
24         Arguments             [][]byte
25         Info                  string
26         SpendCommitment
27 }
28
29 func NewDpos(arguments [][]byte, from, to string, sourceID bc.Hash, assetID bc.AssetID, stake, amount, sourcePos uint64, controlProgram []byte, t TxType) *TxInput {
30         var vote string
31         switch t {
32         case LoginCandidate:
33         case LogoutCandidate:
34         case Delegate:
35                 vote = "vapor:1:event:vote"
36         case UnDelegate:
37         }
38         sc := SpendCommitment{
39                 AssetAmount: bc.AssetAmount{
40                         AssetId: &assetID,
41                         Amount:  amount,
42                 },
43                 SourceID:       sourceID,
44                 SourcePosition: sourcePos,
45                 VMVersion:      1,
46                 ControlProgram: controlProgram,
47         }
48
49         return &TxInput{
50                 AssetVersion: 1,
51                 TypedInput: &DposTx{
52                         SpendCommitment: sc,
53                         Type:            t,
54                         Amount:          amount,
55                         Arguments:       arguments,
56                         Info:            vote,
57                         Stake:           stake,
58                         From:            from,
59                         To:              to,
60                 },
61         }
62 }
63
64 // InputType is the interface function for return the input type.
65 func (si *DposTx) InputType() uint8 { return DposInputType }