OSDN Git Service

Add the basic framework for voting processing for dpos
[bytom/vapor.git] / consensus / consensus / dpos / vote_type.go
1 package dpos
2
3 import (
4         "github.com/vapor/crypto/ed25519/chainkd"
5         chainjson "github.com/vapor/encoding/json"
6         "github.com/vapor/protocol/vm"
7 )
8
9 // serflag variables for input types.
10 const (
11         DelegateInfoType uint8 = iota
12         RegisterType
13         VoteType
14         CancelVoteType
15 )
16
17 type TypedData interface {
18         DataType() uint8
19 }
20
21 type DposMsg struct {
22         Type vm.Op
23         Data []byte
24 }
25
26 // DELEGATE_IDS PUBKEY SIG(block.time)
27 type DelegateInfoList struct {
28         Delegate DelegateInfo       `json:"delegate"`
29         Xpub     chainkd.XPub       `json:"xpub"`
30         SigTime  chainjson.HexBytes `json:"sig_time"`
31 }
32
33 func (d *DelegateInfoList) DataType() uint8 { return DelegateInfoType }
34
35 type RegisterForgerData struct {
36         Name string `json:"name"`
37 }
38
39 func (d *RegisterForgerData) DataType() uint8 { return RegisterType }
40
41 type VoteForgerData struct {
42         Forgers []string `json:"forgers"`
43 }
44
45 func (d *VoteForgerData) DataType() uint8 { return VoteType }
46
47 type CancelVoteForgerData struct {
48         Forgers []string `json:"forgers"`
49 }
50
51 func (d *CancelVoteForgerData) DataType() uint8 { return CancelVoteType }