github.com/lino-network/lino@v0.6.11/x/validator/model/ir.go (about) 1 package model 2 3 import ( 4 abci "github.com/tendermint/tendermint/abci/types" 5 "github.com/tendermint/tendermint/crypto" 6 tmtypes "github.com/tendermint/tendermint/types" 7 8 "github.com/lino-network/lino/types" 9 ) 10 11 // ABCIPubKeyIR. 12 type ABCIPubKeyIR struct { 13 Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` 14 Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` 15 } 16 17 func NewABCIPubKeyIRFromTM(pubkey crypto.PubKey) ABCIPubKeyIR { 18 key := tmtypes.TM2PB.PubKey(pubkey) 19 return ABCIPubKeyIR{ 20 Type: key.Type, 21 Data: key.Data, 22 } 23 } 24 25 func (pubkey ABCIPubKeyIR) ToTM() crypto.PubKey { 26 rst, err := tmtypes.PB2TM.PubKey(abci.PubKey{ 27 Type: pubkey.Type, 28 Data: pubkey.Data, 29 }) 30 if err != nil { 31 panic(err) 32 } 33 return rst 34 } 35 36 // ABCIValidatorIR. 37 type ABCIValidatorIR struct { 38 Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` 39 Power int64 `protobuf:"varint,3,opt,name=power,proto3" json:"power,omitempty"` 40 } 41 42 // ValidatorIR 43 type ValidatorIR struct { 44 ABCIValidator ABCIValidatorIR `json:"abci_validator"` 45 PubKey ABCIPubKeyIR `json:"pub_key"` 46 Username types.AccountKey `json:"username"` 47 ReceivedVotes types.Coin `json:"received_votes"` 48 HasRevoked bool `json:"has_revoked"` 49 AbsentCommit int64 `json:"absent_commit"` 50 ProducedBlocks int64 `json:"produced_blocks"` 51 Link string `json:"link"` 52 } 53 54 type ElectionVoteIR struct { 55 ValidatorName types.AccountKey `json:"validator_name"` 56 Vote types.Coin `json:"votes"` 57 } 58 59 type ElectionVoteListIR struct { 60 Username types.AccountKey `json:"username"` 61 ElectionVotes []ElectionVoteIR `json:"election_votes"` 62 } 63 64 // ValidatorList 65 type ValidatorListIR struct { 66 Oncall []types.AccountKey `json:"oncall"` 67 Standby []types.AccountKey `json:"standby"` 68 Candidates []types.AccountKey `json:"candidates"` 69 Jail []types.AccountKey `json:"jail"` 70 PreBlockValidators []types.AccountKey `json:"pre_block_validators"` 71 LowestOncallVotes types.Coin `json:"lowest_oncall_votes"` 72 LowestOncall types.AccountKey `json:"lowest_oncall"` 73 LowestStandbyVotes types.Coin `json:"lowest_standby_votes"` 74 LowestStandby types.AccountKey `json:"lowest_standby"` 75 } 76 77 // ValidatorTablesIR - Validators changed. 78 type ValidatorTablesIR struct { 79 Version int `json:"version"` 80 Validators []ValidatorIR `json:"validators"` 81 Votes []ElectionVoteListIR `json:"votes"` 82 List ValidatorListIR `json:"list"` 83 }