Commit 1c6d4f4b authored by 张振华's avatar 张振华

update

parent 1d227a8a
......@@ -6,6 +6,7 @@ package dpos
import (
"bytes"
"encoding/hex"
"fmt"
"github.com/33cn/chain33/common/address"
"os"
......@@ -455,7 +456,25 @@ func (client *Client)QueryCandidators()([]*dty.Candidator, error) {
return nil, err
}
res = *result.(*dty.CandidatorReply)
return res.GetCandidators(), nil
var cands []*dty.Candidator
for _, val := range res.GetCandidators() {
bPubkey, err := hex.DecodeString(val.Pubkey)
if err != nil {
return nil, err
}
cand := &dty.Candidator{
Pubkey: bPubkey,
Address: val.Address,
Ip: val.Ip,
Votes: val.Votes,
Status: val.Status,
}
cands = append(cands, cand)
}
return cands, nil
}
func (client *Client)MonitorCandidators() {
......
......@@ -171,16 +171,16 @@ func addCancelVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("pubkey", "k", "", "pubkey of a candidator")
cmd.MarkFlagRequired("pubkey")
cmd.Flags().Int64P("votes", "v", 0, "votes")
cmd.MarkFlagRequired("votes")
cmd.Flags().Int64P("index", "i", 0, "index")
cmd.MarkFlagRequired("index")
}
func cancelVote(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
votes, _ := cmd.Flags().GetInt64("votes")
index, _ := cmd.Flags().GetInt64("index")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"votes\":\"%d\"}", pubkey, votes)
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"index\":\"%d\"}", pubkey, index)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateCancelVoteTx,
......@@ -358,7 +358,7 @@ func vrfM(cmd *cobra.Command, args []string) {
cycle, _ := cmd.Flags().GetInt64("cycle")
m, _ := cmd.Flags().GetString("m")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"cycle\":\"%d\", \"m\":\"%X\"}", pubkey, cycle, m)
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"cycle\":\"%d\", \"m\":\"%s\"}", pubkey, cycle, m)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateRegistVrfMTx,
......@@ -399,10 +399,10 @@ func vrfRP(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
pubkey, _ := cmd.Flags().GetString("pubkey")
cycle, _ := cmd.Flags().GetInt64("cycle")
r, _ := cmd.Flags().GetString("r")
p, _ := cmd.Flags().GetString("p")
hash, _ := cmd.Flags().GetString("hash")
proof, _ := cmd.Flags().GetString("proof")
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"cycle\":\"%d\", \"r\":\"%s\", \"p\":\"%s\"}", pubkey, cycle, r, p)
payload := fmt.Sprintf("{\"pubkey\":\"%s\", \"cycle\":\"%d\", \"r\":\"%s\", \"p\":\"%s\"}", pubkey, cycle, hash, proof)
params := &rpctypes.CreateTxIn{
Execer: types.ExecName(dty.DPosX),
ActionName: dty.CreateRegistVrfRPTx,
......@@ -433,6 +433,7 @@ func addVrfQueryFlags(cmd *cobra.Command) {
cmd.Flags().Int64P("timestamp", "s", 0, "time stamp from 1970-1-1")
cmd.Flags().Int64P("cycle", "c", 0, "cycle,one time point belongs to a cycle")
cmd.Flags().StringP("pubkeys", "k", "", "pubkeys")
}
func vrfQuery(cmd *cobra.Command, args []string) {
......@@ -441,6 +442,7 @@ func vrfQuery(cmd *cobra.Command, args []string) {
dtime, _ := cmd.Flags().GetString("time")
timestamp, _ := cmd.Flags().GetInt64("timestamp")
cycle, _ := cmd.Flags().GetInt64("cycle")
pubkeys, _ := cmd.Flags().GetString("pubkeys")
var params rpctypes.Query4Jrpc
params.Execer = dty.DPosX
......@@ -497,5 +499,45 @@ func vrfQuery(cmd *cobra.Command, args []string) {
var res dty.DposVrfReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
case "topN":
if cycle <= 0 {
fmt.Println("err cycle:", cycle)
return
}
req := &dty.DposVrfQuery{
Ty: dty.QueryVrfByCycleForTopN,
Cycle: cycle,
}
params.FuncName = dty.FuncNameQueryVrfByCycleForTopN
params.Payload = types.MustPBToJSON(req)
var res dty.DposVrfReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
case "pubkeys":
if cycle <= 0 {
fmt.Println("err cycle:", cycle)
return
}
req := &dty.DposVrfQuery{
Ty: dty.QueryVrfByCycleForPubkeys,
Cycle: cycle,
}
keys := strings.Split(pubkeys, ";")
for _, key := range keys {
req.Pubkeys = append(req.Pubkeys, key)
}
params.FuncName = dty.FuncNameQueryVrfByCycleForPubkeys
params.Payload = types.MustPBToJSON(req)
var res dty.DposVrfReply
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run()
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ package executor
/*
该合约主要是配合Dpos共识,完成(1)候选节点的注册、去注册、投票及查询管理。(2)Dpos共识运行过程中,得票数TopN(N为约定的受托节点数量)受托节点的VRF相关信息的分阶段发布管理。
主要过程:
(1)系统初始运行时,会有默认的几个受托节点进行共识运行。
(2)系统运行后,可以重新选举受托节点,各个候选节点需要抵押10000个币(暂未实现),注册成为候选节点。
(3)候选节点可以在社区宣传,让大家为自己投票。
......
......@@ -86,13 +86,136 @@ func queryVrfByTime(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error)
}
cycleInfo := calcCycleByTime(req.Timestamp)
req.Ty = dty.QueryVrfByTime
req.Ty = dty.QueryVrfByCycle
req.Cycle = cycleInfo.cycle
return queryVrfByCycle(kvdb, req)
}
//queryVrfByCycle 根据Cycle信息,查询TopN的受托节点的VRF信息
func queryVrfByCycle(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error) {
if req.Ty != dty.QueryVrfByCycle {
func getJsonVrfs(vrfs [] *dty.VrfInfo) [] *dty.JsonVrfInfo{
var jsonVrfs [] *dty.JsonVrfInfo
for i := 0; i < len(vrfs); i++ {
jsonVrf := &dty.JsonVrfInfo{
Index: vrfs[i].Index,
Pubkey: hex.EncodeToString(vrfs[i].Pubkey),
Cycle: vrfs[i].Cycle,
Height: vrfs[i].Height,
M: string(vrfs[i].M),
R: hex.EncodeToString(vrfs[i].R),
P: hex.EncodeToString(vrfs[i].P),
Time: vrfs[i].Time,
}
jsonVrfs = append(jsonVrfs, jsonVrf)
}
return jsonVrfs
}
func getVrfInfoFromVrfRP(vrfRP *dty.DposVrfRP) *dty.VrfInfo{
if nil == vrfRP {
return nil
}
vrf := &dty.VrfInfo{
Index: vrfRP.Index,
Pubkey: vrfRP.Pubkey,
Cycle: vrfRP.Cycle,
Height: vrfRP.Height,
M: vrfRP.M,
R: vrfRP.R,
P: vrfRP.P,
Time: vrfRP.Time,
}
return vrf
}
func isRecordExist(vrfM *dty.DposVrfM, vrfs [] *dty.VrfInfo) bool {
if nil == vrfM || nil == vrfs || 0 == len(vrfs) {
return false
}
for i := 0; i < len(vrfs); i++ {
if vrfM.Cycle == vrfs[i].Cycle && bytes.Equal(vrfM.Pubkey, vrfs[i].Pubkey) {
return true
}
}
return false
}
func getVrfInfoFromVrfM(vrfM *dty.DposVrfM) *dty.VrfInfo{
if nil == vrfM {
return nil
}
vrf := &dty.VrfInfo{
Index: vrfM.Index,
Pubkey: vrfM.Pubkey,
Cycle: vrfM.Cycle,
Height: vrfM.Height,
M: vrfM.M,
Time: vrfM.Time,
}
return vrf
}
//queryVrfByCycleAndPubkeys 根据Cycle、Pubkeys信息,查询受托节点的VRF信息
func queryVrfByCycleAndPubkeys(kvdb db.KVDB, pubkeys []string, cycle int64) [] *dty.VrfInfo {
VrfRPTable := dty.NewDposVrfRPTable(kvdb)
query := VrfRPTable.GetQuery(kvdb)
var tempPubkeys [] string
var vrfs [] *dty.VrfInfo
for i := 0; i < len(pubkeys); i ++ {
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%s:%018d", pubkeys[i], cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf RP failed", "pubkey", pubkeys[i], "cycle", cycle)
tempPubkeys = append(tempPubkeys, pubkeys[i])
continue
}
vrfRP := rows[0].Data.(*dty.DposVrfRP)
vrf := getVrfInfoFromVrfRP(vrfRP)
vrfs = append(vrfs, vrf)
}
if tempPubkeys == nil || len(tempPubkeys) == 0 {
return vrfs
}
vrfMTable := dty.NewDposVrfMTable(kvdb)
query = vrfMTable.GetQuery(kvdb)
for i := 0; i < len(tempPubkeys); i++ {
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%s:%018d", tempPubkeys[i], cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf M failed", "pubkey", tempPubkeys[i], "cycle", cycle)
continue
}
vrfM := rows[0].Data.(*dty.DposVrfM)
vrf := getVrfInfoFromVrfM(vrfM)
vrfs = append(vrfs, vrf)
}
return vrfs
}
//queryVrfByCycleForPubkeys 根据Cycle、Pubkeys信息,查询受托节点的VRF信息
func queryVrfByCycleForPubkeys(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error) {
if req.Ty != dty.QueryVrfByCycleForPubkeys {
return nil, types.ErrInvalidParam
}
vrfs := queryVrfByCycleAndPubkeys(kvdb, req.Pubkeys, req.Cycle)
return &dty.DposVrfReply{Vrf: getJsonVrfs(vrfs)}, nil
}
//queryVrfByCycleForTopN 根据Cycle信息,查询TopN的受托节点的VRF信息
func queryVrfByCycleForTopN(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error) {
if req.Ty != dty.QueryVrfByCycleForTopN {
return nil, types.ErrInvalidParam
}
......@@ -107,64 +230,96 @@ func queryVrfByCycle(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error)
return nil, dty.ErrCandidatorNotEnough
}
var pubkeys []string
for i := 0; i < len(res.Candidators); i++ {
pubkeys = append(pubkeys, res.Candidators[i].Pubkey)
//zzh
logger.Info("queryVrfByCycleForTopN", "pubkey", pubkeys[i])
}
vrfs := queryVrfByCycleAndPubkeys(kvdb, pubkeys, req.Cycle)
/*
VrfRPTable := dty.NewDposVrfRPTable(kvdb)
query := VrfRPTable.GetQuery(kvdb)
var tempCands [] *dty.Candidator
var tempCands [] *dty.JsonCandidator
var vrfs [] *dty.VrfInfo
for i := 0; i < len(res.Candidators); i ++ {
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", res.Candidators[i].Pubkey, req.Cycle)), nil, 1, 0)
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%s:%018d", res.Candidators[i].Pubkey, req.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf RP failed", "pubkey", fmt.Sprintf("%X", res.Candidators[i].Pubkey), "cycle", req.Cycle)
logger.Error("queryVrf RP failed", "pubkey", res.Candidators[i].Pubkey, "cycle", req.Cycle)
tempCands = append(tempCands, res.Candidators[i])
continue
}
vrfRP := rows[0].Data.(*dty.DposVrfRP)
vrf := &dty.VrfInfo{
Index: vrfRP.Index,
Pubkey: vrfRP.Pubkey,
Cycle: vrfRP.Cycle,
Height: vrfRP.Height,
M: vrfRP.M,
R: vrfRP.R,
P: vrfRP.P,
Time: vrfRP.Time,
}
vrf := getVrfInfoFromVrfRP(vrfRP)
vrfs = append(vrfs, vrf)
}
if tempCands == nil || len(tempCands) == 0 {
return &dty.DposVrfReply{Vrf: vrfs}, nil
return &dty.DposVrfReply{Vrf: getJsonVrfs(vrfs)}, nil
}
vrfMTable := dty.NewDposVrfMTable(kvdb)
query = vrfMTable.GetQuery(kvdb)
for i := 0; i < len(tempCands); i++ {
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", tempCands[i].Pubkey, req.Cycle)), nil, 1, 0)
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%s:%018d", tempCands[i].Pubkey, req.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf M failed", "pubkey", fmt.Sprintf("%X", res.Candidators[i].Pubkey), "cycle", req.Cycle)
logger.Error("queryVrf M failed", "pubkey", res.Candidators[i].Pubkey, "cycle", req.Cycle)
continue
}
vrfM := rows[0].Data.(*dty.DposVrfM)
vrf := &dty.VrfInfo{
Index: vrfM.Index,
Pubkey: vrfM.Pubkey,
Cycle: vrfM.Cycle,
Height: vrfM.Height,
M: vrfM.M,
Time: vrfM.Time,
}
vrf := getVrfInfoFromVrfM(vrfM)
vrfs = append(vrfs, vrf)
}
*/
return &dty.DposVrfReply{Vrf: vrfs}, nil
return &dty.DposVrfReply{Vrf: getJsonVrfs(vrfs)}, nil
}
//queryVrfByCycle 根据Cycle信息,查询所有受托节点的VRF信息
func queryVrfByCycle(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error) {
if req.Ty != dty.QueryVrfByCycle {
return nil, types.ErrInvalidParam
}
VrfRPTable := dty.NewDposVrfRPTable(kvdb)
query := VrfRPTable.GetQuery(kvdb)
var vrfs [] *dty.VrfInfo
rows, err := query.ListIndex("cycle", []byte(fmt.Sprintf("%018d", req.Cycle)), nil, 0, 0)
if err != nil {
logger.Error("queryVrf RP failed", "cycle", req.Cycle)
} else {
for i := 0; i < len(rows); i++ {
vrfRP := rows[i].Data.(*dty.DposVrfRP)
vrf := getVrfInfoFromVrfRP(vrfRP)
vrfs = append(vrfs, vrf)
}
}
vrfMTable := dty.NewDposVrfMTable(kvdb)
query = vrfMTable.GetQuery(kvdb)
rows, err = query.ListIndex("cycle", []byte(fmt.Sprintf("%018d", req.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("queryVrf M failed", "cycle", req.Cycle)
} else {
for i := 0; i < len(rows); i++ {
vrfM := rows[i].Data.(*dty.DposVrfM)
if !isRecordExist(vrfM, vrfs) {
vrf := getVrfInfoFromVrfM(vrfM)
vrfs = append(vrfs, vrf)
}
}
}
return &dty.DposVrfReply{Vrf: getJsonVrfs(vrfs)}, nil
}
//queryCands 根据候选节点的Pubkey下旬候选节点信息,得票数、状态等
func queryCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, error) {
var cands []*dty.Candidator
var cands []*dty.JsonCandidator
candTable := dty.NewDposCandidatorTable(kvdb)
query := candTable.GetQuery(kvdb)
......@@ -176,8 +331,8 @@ func queryCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, error) {
}
candInfo := rows[0].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
cand := &dty.JsonCandidator{
Pubkey: strings.ToUpper(hex.EncodeToString(candInfo.Pubkey)),
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
......@@ -190,7 +345,7 @@ func queryCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, error) {
//queryTopNCands 查询得票数TopN的候选节点信息,包括得票数,状态等
func queryTopNCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, error) {
var cands []*dty.Candidator
var cands []*dty.JsonCandidator
candTable := dty.NewDposCandidatorTable(kvdb)
query := candTable.GetQuery(kvdb)
......@@ -199,8 +354,8 @@ func queryTopNCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, erro
if err == nil {
for index := 0; index < len(rows); index++ {
candInfo := rows[index].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
cand := &dty.JsonCandidator{
Pubkey: strings.ToUpper(hex.EncodeToString(candInfo.Pubkey)),
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
......@@ -220,8 +375,8 @@ func queryTopNCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, erro
if err == nil {
for index := 0; index < len(rows); index++ {
candInfo := rows[index].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
cand := &dty.JsonCandidator{
Pubkey: strings.ToUpper(hex.EncodeToString(candInfo.Pubkey)),
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
......@@ -239,8 +394,8 @@ func queryTopNCands(kvdb db.KVDB, req *dty.CandidatorQuery) (types.Message, erro
if err == nil {
for index := 0; index < len(rows); index++ {
candInfo := rows[index].Data.(*dty.CandidatorInfo)
cand := &dty.Candidator{
Pubkey: candInfo.Pubkey,
cand := &dty.JsonCandidator{
Pubkey: strings.ToUpper(hex.EncodeToString(candInfo.Pubkey)),
Address: candInfo.Address,
Ip: candInfo.Ip,
Votes: candInfo.Votes,
......@@ -278,7 +433,7 @@ func isValidPubkey(pubkeys []string, pubkey string) bool{
//queryVote 根据用户地址信息查询用户的投票情况
func queryVote(kvdb db.KVDB, req *dty.DposVoteQuery) (types.Message, error) {
var voters []*dty.DposVoter
var voters []*dty.JsonDposVoter
voteTable := dty.NewDposVoteTable(kvdb)
query := voteTable.GetQuery(kvdb)
......@@ -289,7 +444,14 @@ func queryVote(kvdb db.KVDB, req *dty.DposVoteQuery) (types.Message, error) {
for index := 0; index < len(rows); index++ {
voter := rows[index].Data.(*dty.DposVoter)
voters = append(voters, voter)
jsonVoter := &dty.JsonDposVoter{
FromAddr: voter.FromAddr,
Pubkey: strings.ToUpper(hex.EncodeToString(voter.Pubkey)),
Votes: voter.Votes,
Index: voter.Index,
Time: voter.Time,
}
voters = append(voters, jsonVoter)
}
//如果不指定pubkeys,则返回所有;否则,需要判断pubkey是否为指定的值之一。
......@@ -299,7 +461,7 @@ func queryVote(kvdb db.KVDB, req *dty.DposVoteQuery) (types.Message, error) {
reply := &dty.DposVoteReply{}
for index := 0; index < len(voters); index ++ {
strPubkey := hex.EncodeToString(voters[index].Pubkey)
strPubkey := voters[index].Pubkey
if isValidPubkey(req.Pubkeys, strPubkey) {
reply.Votes = append(reply.Votes, voters[index])
}
......@@ -324,7 +486,7 @@ func (action *Action) getIndex() int64 {
}
//getReceiptLog 根据候选节点信息及投票信息生成收据信息
func (action *Action) getReceiptLog(candInfo *dty.CandidatorInfo, statusChange bool, voted bool, vote *dty.DposVote) *types.ReceiptLog {
func (action *Action) getReceiptLog(candInfo *dty.CandidatorInfo, statusChange bool, voteType int32, vote *dty.DposVoter) *types.ReceiptLog {
log := &types.ReceiptLog{}
r := &dty.ReceiptCandicator{}
//r.StartIndex = can.StartIndex
......@@ -347,14 +509,17 @@ func (action *Action) getReceiptLog(candInfo *dty.CandidatorInfo, statusChange b
r.PreStatus = candInfo.PreStatus
r.Address = candInfo.Address
r.Pubkey = candInfo.Pubkey
r.Voted = voted
if voted {
r.Votes = vote.Votes
r.FromAddr = vote.FromAddr
if r.Votes < 0 {
r.VoteType = voteType
switch (voteType) {
case dty.VoteTypeNone :
case dty.VoteTypeVote:
r.Vote = vote
case dty.VoteTypeCancelVote:
log.Ty = dty.TyLogCandicatorCancelVoted
r.Vote = vote
case dty.VoteTypeCancelAllVote:
}
}
r.CandInfo = candInfo
log.Log = types.Encode(r)
return log
......@@ -435,7 +600,7 @@ func (action *Action) Regist(regist *dty.DposCandidatorRegist) (*types.Receipt,
candInfo.StartTxHash = common.ToHex(action.txhash)
candInfo.PreIndex = 0
receiptLog := action.getReceiptLog(candInfo, false, false, nil)
receiptLog := action.getReceiptLog(candInfo, false, dty.VoteTypeNone, nil)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
......@@ -494,8 +659,11 @@ func (action *Action) ReRegist(regist *dty.DposCandidatorRegist) (*types.Receipt
candInfo.Index = candInfo.StartIndex
candInfo.StartTxHash = common.ToHex(action.txhash)
candInfo.PreIndex = 0
candInfo.Votes = 0
candInfo.Voters = nil
receiptLog := action.getReceiptLog(candInfo, false, dty.VoteTypeNone, nil)
receiptLog := action.getReceiptLog(candInfo, false, false, nil)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
......@@ -563,8 +731,12 @@ func (action *Action) CancelRegist(req *dty.DposCandidatorCancelRegist) (*types.
candInfo.Status = dty.CandidatorStatusCancelRegist
candInfo.PreIndex = candInfo.Index
candInfo.Index = action.getIndex()
receiptLog := action.getReceiptLog(candInfo, true, dty.VoteTypeCancelAllVote, nil)
candInfo.Votes = 0
candInfo.Voters = nil
receiptLog := action.getReceiptLog(candInfo, true, false, nil)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
......@@ -596,8 +768,7 @@ func (action *Action) Vote(vote *dty.DposVote) (*types.Receipt, error) {
return nil, types.ErrInvalidParam
}
logger.Info("vote", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator",
candInfo.String())
logger.Info("vote", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator", candInfo.String())
statusChange := false
if candInfo.Status == dty.CandidatorStatusRegist || candInfo.Status == dty.CandidatorStatusReRegist{
......@@ -632,7 +803,7 @@ func (action *Action) Vote(vote *dty.DposVote) (*types.Receipt, error) {
candInfo.PreIndex = candInfo.Index
candInfo.Index = action.getIndex()
receiptLog := action.getReceiptLog(candInfo, statusChange, true, vote)
receiptLog := action.getReceiptLog(candInfo, statusChange, dty.VoteTypeVote, voter)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
......@@ -663,67 +834,37 @@ func (action *Action) CancelVote(vote *dty.DposCancelVote) (*types.Receipt, erro
return nil, types.ErrInvalidParam
}
logger.Info("CancelVote", "addr", action.fromaddr, "execaddr", action.execaddr, "candicator",
candInfo.String())
votes := vote.Votes
availVotes := int64(0)
enoughVotes := false
for _, voter := range candInfo.Voters {
if voter.FromAddr == action.fromaddr && bytes.Equal(voter.Pubkey, bPubkey){
//if action.blocktime - voter.Time >= dty.VoteFrozenTime {
availVotes += voter.Votes
if availVotes >= votes {
enoughVotes = true
break
}
//}
}
}
if !enoughVotes {
logger.Error("RevokeVote failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not enough avail votes",
availVotes, "revoke votes", vote.Votes)
return nil, dty.ErrNotEnoughVotes
}
logger.Info("CancelVote", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey", vote.Pubkey, "index", vote.Index)
findVote := false
var oriVote *dty.DposVoter
for index, voter := range candInfo.Voters {
if voter.FromAddr == action.fromaddr && bytes.Equal(voter.Pubkey, bPubkey){
//if action.blocktime - voter.Time >= dty.VoteFrozenTime {
if voter.Votes > votes {
voter.Votes -= votes
break
} else if voter.Votes == votes {
candInfo.Voters = append(candInfo.Voters[:index], candInfo.Voters[index+1:]...)
if voter.FromAddr == action.fromaddr && bytes.Equal(voter.Pubkey, bPubkey) && voter.Index == vote.Index{
oriVote = voter
findVote = true
candInfo.Voters = append(candInfo.Voters[0:index], candInfo.Voters[index+1:]...)
break
} else {
candInfo.Voters = append(candInfo.Voters[:index], candInfo.Voters[index+1:]...)
votes = votes - voter.Votes
}
//}
}
if !findVote {
logger.Error("CancelVote failed", "addr", action.fromaddr, "execaddr", action.execaddr, vote.Pubkey, "index", vote.Index)
return nil, dty.ErrNoSuchVote
}
checkValue := vote.Votes
receipt, err := action.coinsAccount.ExecActive(action.fromaddr, action.execaddr, checkValue)
receipt, err := action.coinsAccount.ExecActive(action.fromaddr, action.execaddr, oriVote.Votes)
if err != nil {
logger.Error("ExecActive failed", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", checkValue, "err", err.Error())
logger.Error("ExecActive failed", "addr", action.fromaddr, "execaddr", action.execaddr, "amount", oriVote.Votes, "err", err.Error())
return nil, err
}
logs = append(logs, receipt.Logs...)
kv = append(kv, receipt.KV...)
candInfo.Votes -= vote.Votes
vote2 := &dty.DposVote{
FromAddr: action.fromaddr,
Pubkey: vote.Pubkey,
Votes: (-1) * vote.Votes,
}
candInfo.Votes -= oriVote.Votes
candInfo.PreIndex = candInfo.Index
candInfo.Index = action.getIndex()
receiptLog := action.getReceiptLog(candInfo, false, true, vote2)
receiptLog := action.getReceiptLog(candInfo, false, dty.VoteTypeCancelVote, oriVote)
logs = append(logs, receiptLog)
kv = append(kv, action.saveCandicator(candInfo)...)
......@@ -743,46 +884,53 @@ func (action *Action) RegistVrfM(vrfMReg *dty.DposVrfMRegist) (*types.Receipt, e
return nil, types.ErrInvalidParam
}
/*
bM, err := hex.DecodeString(vrfMReg.M)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "M is not correct",
vrfMReg.M)
return nil, types.ErrInvalidParam
}
}*/
bM := []byte(vrfMReg.M)
req := &dty.CandidatorQuery{}
req.Pubkeys = append(req.Pubkeys, vrfMReg.Pubkey)
req := &dty.CandidatorQuery{
TopN: int32(dposDelegateNum),
}
reply, err := queryTopNCands(action.localDB, req)
reply, err := queryCands(action.localDB, req)
res := reply.(*dty.CandidatorReply)
if err != nil || len(res.Candidators) < int(dposDelegateNum){
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not enough Candidators",
dposDelegateNum)
return nil, dty.ErrCandidatorNotEnough
if err != nil || len(res.Candidators) != 1 || res.Candidators[0].Status == dty.CandidatorStatusCancelRegist{
logger.Error("RegistVrfM failed for no valid Candidators", "addr", action.fromaddr, "execaddr", action.execaddr)
return nil, dty.ErrCandidatorNotExist
}
legalCand := false
for i := 0; i < len(res.Candidators); i++ {
if bytes.Equal(bPubkey, res.Candidators[i].Pubkey) && action.fromaddr == res.Candidators[i].Address {
if (strings.ToUpper(vrfMReg.Pubkey) == res.Candidators[0].Pubkey) && (action.fromaddr == res.Candidators[0].Address) {
legalCand = true
}
}
if !legalCand {
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not legal Candidators",
res.String())
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "not legal Candidator",
res.Candidators[0].String())
return nil, dty.ErrCandidatorNotLegal
}
cycleInfo := calcCycleByTime(action.blocktime)
middleTime := cycleInfo.cycleStart + (cycleInfo.cycleStop - cycleInfo.cycleStart) / 2
if vrfMReg.Cycle != cycleInfo.cycle {
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "cycle is not the same with current blocktime",
vrfMReg.String())
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "cycle is not correct",
vrfMReg.String(), "current cycle info", fmt.Sprintf("cycle:%d,start:%d,stop:%d,time:%d", cycleInfo.cycle, cycleInfo.cycleStart, cycleInfo.cycleStop, action.blocktime))
return nil, types.ErrInvalidParam
}else if action.blocktime > middleTime{
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "time is not allowed, over the middle of this cycle",
action.blocktime, "allow time", fmt.Sprintf("cycle:%d,start:%d,middle:%d,stop:%d", cycleInfo.cycle, cycleInfo.cycleStart, middleTime, cycleInfo.cycleStop))
return nil, types.ErrInvalidParam
}
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey", vrfMReg.Pubkey, "cycle", vrfMReg.Cycle, "M", vrfMReg.M, "now", action.blocktime,
"info", fmt.Sprintf("cycle:%d,start:%d,middle:%d,stop:%d", cycleInfo.cycle, cycleInfo.cycleStart, middleTime, cycleInfo.cycleStop))
//todo 还需要检查是否针对这个cycle已经有注册过M了,如果注册过了,也需要提示失败
vrfMTable := dty.NewDposVrfMTable(action.localDB)
query := vrfMTable.GetQuery(action.localDB)
......@@ -802,6 +950,9 @@ func (action *Action) RegistVrfM(vrfMReg *dty.DposVrfMRegist) (*types.Receipt, e
r.Height = action.mainHeight
r.M = bM
r.Time = action.blocktime
r.CycleStart = cycleInfo.cycleStart
r.CycleStop = cycleInfo.cycleStop
r.CycleMiddle = middleTime
log.Ty = dty.TyLogVrfMRegist
log.Log = types.Encode(r)
......@@ -818,44 +969,53 @@ func (action *Action) RegistVrfRP(vrfRPReg *dty.DposVrfRPRegist) (*types.Receipt
bPubkey, err := hex.DecodeString(vrfRPReg.Pubkey)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
logger.Info("RegistVrfRP", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey is not correct",
vrfRPReg.Pubkey)
return nil, types.ErrInvalidParam
}
bR, err := hex.DecodeString(vrfRPReg.R)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "M is not correct",
logger.Info("RegistVrfRP", "addr", action.fromaddr, "execaddr", action.execaddr, "R is not correct",
vrfRPReg.R)
return nil, types.ErrInvalidParam
}
bP, err := hex.DecodeString(vrfRPReg.P)
if err != nil {
logger.Info("RegistVrfM", "addr", action.fromaddr, "execaddr", action.execaddr, "M is not correct",
logger.Info("RegistVrfRP", "addr", action.fromaddr, "execaddr", action.execaddr, "P is not correct",
vrfRPReg.P)
return nil, types.ErrInvalidParam
}
//todo 从localdb中查找对应的pubkey:cycle的信息,如果没找到,说明对应的M没有发布出来,则也不允许发布R,P。
vrfMTable := dty.NewDposVrfMTable(action.localDB)
query := vrfMTable.GetQuery(action.localDB)
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfRPReg.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "VrfM is not exist",
vrfRPReg.String())
return nil, dty.ErrVrfMNotRegisted
}
//对于可以注册的R、P,则允许。
cycleInfo := calcCycleByTime(action.blocktime)
middleTime := cycleInfo.cycleStart + (cycleInfo.cycleStop - cycleInfo.cycleStart) / 2
//对于cycle不一致的情况,则不允许注册
if vrfRPReg.Cycle != cycleInfo.cycle {
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "cycle is not the same with current blocktime",
vrfRPReg.String())
return nil, types.ErrInvalidParam
} else if action.blocktime < middleTime{
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "time is not allowed, not over the middle of this cycle",
action.blocktime, "allow time", fmt.Sprintf("cycle:%d,start:%d,middle:%d,stop:%d", cycleInfo.cycle, cycleInfo.cycleStart, middleTime, cycleInfo.cycleStop))
return nil, types.ErrInvalidParam
}
logger.Info("RegistVrfRP", "addr", action.fromaddr, "execaddr", action.execaddr, "pubkey", vrfRPReg.Pubkey, "cycle", vrfRPReg.Cycle, "R", vrfRPReg.R, "P", vrfRPReg.P,
"now", action.blocktime, "info", fmt.Sprintf("cycle:%d,start:%d,middle:%d,stop:%d", cycleInfo.cycle, cycleInfo.cycleStart, middleTime, cycleInfo.cycleStop))
//从localdb中查找对应的pubkey:cycle的信息,如果没找到,说明对应的M没有发布出来,则也不允许发布R,P。
vrfMTable := dty.NewDposVrfMTable(action.localDB)
query := vrfMTable.GetQuery(action.localDB)
rows, err := query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfRPReg.Cycle)), nil, 1, 0)
if err != nil {
logger.Error("RegistVrfRP failed", "addr", action.fromaddr, "execaddr", action.execaddr, "VrfM is not registered",
vrfRPReg.String())
return nil, dty.ErrVrfMNotRegisted
}
//对于可以注册的R、P,则允许。
//todo 还需要检查是否针对这个cycle已经有注册过R、P了,如果注册过了,也需要提示失败
VrfRPTable := dty.NewDposVrfRPTable(action.localDB)
query = VrfRPTable.GetQuery(action.localDB)
......@@ -877,6 +1037,9 @@ func (action *Action) RegistVrfRP(vrfRPReg *dty.DposVrfRPRegist) (*types.Receipt
r.P = bP
r.M = rows[0].Data.(*dty.DposVrfM).M
r.Time = action.blocktime
r.CycleStart = cycleInfo.cycleStart
r.CycleStop = cycleInfo.cycleStop
r.CycleMiddle = middleTime
log.Ty = dty.TyLogVrfRPRegist
log.Log = types.Encode(r)
......
......@@ -5,6 +5,7 @@
package executor
import (
"bytes"
"fmt"
"github.com/33cn/chain33/types"
......@@ -23,23 +24,16 @@ func (d *DPos) rollbackCand(cand *dty.CandidatorInfo, log *dty.ReceiptCandicator
}
//如果投票了,则需要把投票回滚
if log.Voted {
cand.Votes -= log.Votes
if log.Votes > 0 {
//如果是投票,则回滚时将投票删除。
cand.Voters = cand.Voters[:len(cand.Voters)-1]
} else {
//如果是撤销投票,则回滚时,将删除的投票还回来
voter := &dty.DposVoter{
FromAddr: log.FromAddr,
Pubkey: log.Pubkey,
Votes: -log.Votes,
Index: log.Index,
Time: log.Time - dty.VoteFrozenTime,
}
cand.Voters = append(cand.Voters, voter)
if log.VoteType == dty.VoteTypeVote {
for i := 0; i < len(cand.Voters); i++{
if cand.Voters[i].Index == log.Vote.Index && cand.Voters[i].FromAddr == log.Vote.FromAddr && bytes.Equal(cand.Voters[i].Pubkey, log.Vote.Pubkey){
cand.Voters = append(cand.Voters[0:i], cand.Voters[i+1:]...)
break
}
}
} else if log.VoteType == dty.VoteTypeCancelVote {
cand.Voters = append(cand.Voters, log.Vote)
}
}
func (d *DPos) rollbackCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue, err error) {
......@@ -74,11 +68,17 @@ func (d *DPos) rollbackCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyVal
return nil, err
}
//删除投票信息
if log.VoteType == dty.VoteTypeVote {
err = voterTable.Del([]byte(fmt.Sprintf("%018d", log.Index)))
if err != nil {
return nil, err
}
} else if log.VoteType == dty.VoteTypeCancelVote {
err = voterTable.Add(log.Vote)
if err != nil {
return nil, err
}
}
kvs2, err := voterTable.Save()
if err != nil {
......@@ -86,7 +86,7 @@ func (d *DPos) rollbackCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyVal
}
kvs = append(kvs1, kvs2...)
} else if log.Status == dty.CandidatorStatusCancelVoted {
} else if log.Status == dty.CandidatorStatusCancelRegist {
//撤销投票回滚,需要将撤销的投票还回来
candInfo := log.CandInfo
log.CandInfo = nil
......@@ -103,11 +103,14 @@ func (d *DPos) rollbackCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyVal
return nil, err
}
//删除投票信息
err = voterTable.Del([]byte(fmt.Sprintf("%018d", log.Index)))
if log.VoteType == dty.VoteTypeCancelAllVote {
for i := 0; i < len(candInfo.Voters); i++ {
err = voterTable.Add(candInfo.Voters[i])
if err != nil {
return nil, err
}
}
}
kvs2, err := voterTable.Save()
if err != nil {
......@@ -115,6 +118,14 @@ func (d *DPos) rollbackCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyVal
}
kvs = append(kvs1, kvs2...)
} else if log.Status == dty.CandidatorStatusReRegist {
//注册回滚,cand表删除记录
err = candTable.Del(log.Pubkey)
if err != nil {
return nil, err
}
kvs, err = candTable.Save()
return kvs, err
}
return kvs, nil
......@@ -153,7 +164,7 @@ func (d *DPos) execDelLocal(receipt *types.ReceiptData) (*types.LocalDBSet, erro
for _, log := range receipt.Logs {
switch log.GetTy() {
case dty.CandidatorStatusRegist, dty.CandidatorStatusVoted, dty.CandidatorStatusCancelVoted, dty.CandidatorStatusCancelRegist:
case dty.TyLogCandicatorRegist, dty.TyLogCandicatorVoted, dty.TyLogCandicatorCancelVoted, dty.TyLogCandicatorCancelRegist, dty.TyLogCandicatorReRegist:
receiptLog := &dty.ReceiptCandicator{}
if err := types.Decode(log.Log, receiptLog); err != nil {
return nil, err
......
......@@ -7,16 +7,17 @@ package executor
import (
"github.com/33cn/chain33/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
"fmt"
)
func (d *DPos) updateCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue, err error) {
voteTable := dty.NewDposVoteTable(d.GetLocalDB())
canTable := dty.NewDposCandidatorTable(d.GetLocalDB())
if log.Status == dty.CandidatorStatusRegist {
candInfo := log.CandInfo
log.CandInfo = nil
if log.Status == dty.CandidatorStatusRegist {
err = canTable.Add(candInfo)
if err != nil {
return nil, err
......@@ -27,9 +28,7 @@ func (d *DPos) updateCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue
return nil, err
}
} else if log.Status == dty.CandidatorStatusVoted {
candInfo := log.CandInfo
log.CandInfo = nil
voter := candInfo.Voters[len(candInfo.Voters)-1]
voter := log.Vote
err = canTable.Replace(candInfo)
if err != nil {
......@@ -41,10 +40,17 @@ func (d *DPos) updateCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue
return nil, err
}
if log.VoteType == dty.VoteTypeVote {
err = voteTable.Add(voter)
if err != nil {
return nil, err
}
} else if log.VoteType == dty.VoteTypeCancelVote {
err = voteTable.Del([]byte(fmt.Sprintf("%018d", voter.Index)))
if err != nil {
return nil, err
}
}
kvs2, err := voteTable.Save()
if err != nil {
......@@ -52,51 +58,40 @@ func (d *DPos) updateCandVote(log *dty.ReceiptCandicator) (kvs []*types.KeyValue
}
kvs = append(kvs1, kvs2...)
} else if log.Status == dty.CandidatorStatusCancelVoted {
candInfo := log.CandInfo
log.CandInfo = nil
voter := &dty.DposVoter{
FromAddr: log.FromAddr,
Pubkey: log.Pubkey,
Votes: log.Votes,
Index: log.Index,
Time: log.Time,
}
} else if log.Status == dty.CandidatorStatusReRegist {
err = canTable.Replace(candInfo)
if err != nil {
return nil, err
}
kvs1, err := canTable.Save()
kvs, err = canTable.Save()
if err != nil {
return nil, err
}
err = voteTable.Add(voter)
} else if log.Status == dty.CandidatorStatusCancelRegist {
err = canTable.Replace(candInfo)
if err != nil {
return nil, err
}
kvs2, err := voteTable.Save()
kvs1, err := canTable.Save()
if err != nil {
return nil, err
}
kvs = append(kvs1, kvs2...)
} else if log.Status == dty.CandidatorStatusReRegist || log.Status == dty.CandidatorStatusCancelRegist{
candInfo := log.CandInfo
log.CandInfo = nil
err = canTable.Replace(candInfo)
for i := 0; i < len(candInfo.Voters); i++ {
err = voteTable.Del([]byte(fmt.Sprintf("%018d", candInfo.Voters[i].Index)))
if err != nil {
return nil, err
}
}
kvs, err = canTable.Save()
kvs2, err := voteTable.Save()
if err != nil {
return nil, err
}
kvs = append(kvs1, kvs2...)
}
return kvs, nil
......@@ -112,6 +107,9 @@ func (d *DPos) updateVrf(log *dty.ReceiptVrf) (kvs []*types.KeyValue, err error)
Height: log.Height,
M: log.M,
Time: log.Time,
CycleStart: log.CycleStart,
CycleMiddle: log.CycleMiddle,
CycleStop: log.CycleStop,
}
err = vrfMTable.Add(vrfM)
......@@ -134,6 +132,9 @@ func (d *DPos) updateVrf(log *dty.ReceiptVrf) (kvs []*types.KeyValue, err error)
P: log.P,
M: log.M,
Time: log.Time,
CycleStart: log.CycleStart,
CycleMiddle: log.CycleMiddle,
CycleStop: log.CycleStop,
}
err = VrfRPTable.Add(vrfRP)
......@@ -211,11 +212,11 @@ func (d *DPos) ExecLocal_CancelVote(payload *dty.DposCancelVote, tx *types.Trans
}
//ExecLocal_VrfMRegist method
func (d *DPos) ExecLocal_VrfMRegist(payload *dty.DposVrfMRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (d *DPos) ExecLocal_RegistVrfM(payload *dty.DposVrfMRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
//ExecLocal_VrfRPRegist method
func (d *DPos) ExecLocal_VrfRPRegist(payload *dty.DposVrfRPRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (d *DPos) ExecLocal_RegistVrfRP(payload *dty.DposVrfRPRegist, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return d.execLocal(receiptData)
}
\ No newline at end of file
......@@ -33,3 +33,13 @@ func (d *DPos) Query_QueryVrfByTime(in *dty.DposVrfQuery) (types.Message, error)
func (d *DPos) Query_QueryVrfByCycle(in *dty.DposVrfQuery) (types.Message, error) {
return queryVrfByCycle(d.GetLocalDB(), in)
}
//Query_QueryVrfByCycleForTopN method
func (d *DPos) Query_QueryVrfByCycleForTopN(in *dty.DposVrfQuery) (types.Message, error) {
return queryVrfByCycleForTopN(d.GetLocalDB(), in)
}
//Query_QueryVrfByCycleForPubkeys method
func (d *DPos) Query_QueryVrfByCycleForPubkeys(in *dty.DposVrfQuery) (types.Message, error) {
return queryVrfByCycleForPubkeys(d.GetLocalDB(), in)
}
\ No newline at end of file
......@@ -59,7 +59,7 @@ message DposVote{
//DposCancelVote 撤销为Dpos候选节点投票
message DposCancelVote{
string pubkey = 1; //候选节点的公钥
int64 votes = 2; //撤销投给候选节点的票数,不超过之前投给该候选节点的总票数,投票3天之后才可以撤销投票
int64 index = 3;
}
//DposVoteAction DposVote动作
......@@ -85,8 +85,18 @@ message CandidatorQuery{
int32 ty = 3; //1:按公钥集合查询,2:按topN票数查询
}
//Candidator 候选节点信息
message JsonCandidator {
string pubkey = 1; //候选节点的公钥
string address = 2; //后续节点的地址
string ip = 3; //候选节点的运行IP
int64 votes = 4; //候选节点的投票数
int64 status = 5; //候选节点的状态,0:注册,1:当选,2:取消注册
}
message CandidatorReply{
repeated Candidator candidators = 1; //候选节点
repeated JsonCandidator candidators = 1; //候选节点
}
message DposVoteQuery{
......@@ -94,8 +104,16 @@ message DposVoteQuery{
string addr = 2; //要查询的地址
}
message JsonDposVoter{
string fromAddr = 1;
string pubkey = 2; //候选节点的公钥
int64 votes = 3; //投给候选节点的票数,不能超过锁在合约中的未使用票数
int64 index = 4;
int64 time = 5;
}
message DposVoteReply{
repeated DposVoter votes = 1; //某地址对具体候选节点的投票情况
repeated JsonDposVoter votes = 1; //某地址对具体候选节点的投票情况
}
//ReceiptCandicator 候选者收据信息
......@@ -106,8 +124,8 @@ message ReceiptCandicator {
int64 status = 4;
int64 preStatus = 5;
bool statusChange = 6;
bool voted = 7;
int64 votes = 8;
int32 voteType = 7;
DposVoter vote = 8;
string fromAddr = 9;
CandidatorInfo candInfo = 10;
int64 time = 11;
......@@ -120,6 +138,9 @@ message DposVrfM{
int64 height = 4;
bytes m = 5; //vrf的输入
int64 time = 6;
int64 cycleStart = 7;
int64 cycleMiddle = 8;
int64 cycleStop = 9;
}
message DposVrfRP{
......@@ -131,6 +152,9 @@ message DposVrfRP{
bytes r = 6; //vrf的hash
bytes p = 7; //vrf的hash的proof
int64 time = 8;
int64 cycleStart = 9;
int64 cycleMiddle = 10;
int64 cycleStop = 11;
}
message DposVrfMRegist{
......@@ -158,6 +182,9 @@ message ReceiptVrf {
bytes r = 7;
bytes p = 8;
int64 time = 9;
int64 cycleStart = 10;
int64 cycleMiddle = 11;
int64 cycleStop = 12;
}
......@@ -173,11 +200,23 @@ message VrfInfo {
}
message DposVrfQuery{
int64 ty = 1;
int64 timestamp = 2;
int64 cycle = 3;
repeated string pubkeys = 1;
int64 ty = 2;
int64 timestamp = 3;
int64 cycle = 4;
}
message JsonVrfInfo {
int64 Index = 1;
string pubkey = 2;
int64 cycle = 4;
int64 height = 5;
string m = 6;
string r = 7;
string p = 8;
int64 time = 9;
}
message DposVrfReply{
repeated VrfInfo vrf = 1;
repeated JsonVrfInfo vrf = 1;
}
\ No newline at end of file
......@@ -38,6 +38,11 @@ const (
const (
VoteFrozenTime = 3 * 24 * 3600
RegistFrozenCoins = 1000000000000
VoteTypeNone int32 = 1
VoteTypeVote int32 = 2
VoteTypeCancelVote int32 = 3
VoteTypeCancelAllVote int32 = 4
)
//包的名字可以通过配置文件来配置
//建议用github的组织名称,或者用户名字开头, 再加上自己的插件的名字
......@@ -60,6 +65,12 @@ const (
//FuncNameQueryVrfByCycle func name
FuncNameQueryVrfByCycle = "QueryVrfByCycle"
//FuncNameQueryVrfByCycleForTopN func name
FuncNameQueryVrfByCycleForTopN = "QueryVrfByCycleForTopN"
//FuncNameQueryVrfByCycleForPubkeys func name
FuncNameQueryVrfByCycleForPubkeys = "QueryVrfByCycleForPubkeys"
//FuncNameQueryVote func name
FuncNameQueryVote = "QueryVote"
......@@ -84,9 +95,15 @@ const (
//CreateRegistVrfRPTx 创建注册Vrf的R/P信息的交易
CreateRegistVrfRPTx = "RegistVrfRP"
//QueryVrfByTime 创建根据time查询Vrf信息查询
//QueryVrfByTime 创建根据time查询Vrf信息
QueryVrfByTime = 1
//QueryVrfByCycle 创建根据cycle查询Vrf信息查询
//QueryVrfByCycle 创建根据cycle查询Vrf信息
QueryVrfByCycle = 2
//QueryVrfByCycleForTopN 创建根据cycle查询当前topN的候选节点的Vrf信息
QueryVrfByCycleForTopN = 3
//QueryVrfByCycleForPubkeys 创建根据cycle查询指定pubkey的多个候选节点的Vrf信息
QueryVrfByCycleForPubkeys = 4
)
......@@ -17,8 +17,10 @@ It has these top-level messages:
DposCancelVote
DposVoteAction
CandidatorQuery
JsonCandidator
CandidatorReply
DposVoteQuery
JsonDposVoter
DposVoteReply
ReceiptCandicator
DposVrfM
......@@ -28,6 +30,7 @@ It has these top-level messages:
ReceiptVrf
VrfInfo
DposVrfQuery
JsonVrfInfo
DposVrfReply
*/
package types
......@@ -351,7 +354,7 @@ func (m *DposVote) GetVotes() int64 {
// DposCancelVote 撤销为Dpos候选节点投票
type DposCancelVote struct {
Pubkey string `protobuf:"bytes,1,opt,name=pubkey" json:"pubkey,omitempty"`
Votes int64 `protobuf:"varint,2,opt,name=votes" json:"votes,omitempty"`
Index int64 `protobuf:"varint,3,opt,name=index" json:"index,omitempty"`
}
func (m *DposCancelVote) Reset() { *m = DposCancelVote{} }
......@@ -366,9 +369,9 @@ func (m *DposCancelVote) GetPubkey() string {
return ""
}
func (m *DposCancelVote) GetVotes() int64 {
func (m *DposCancelVote) GetIndex() int64 {
if m != nil {
return m.Votes
return m.Index
}
return 0
}
......@@ -783,16 +786,65 @@ func (m *CandidatorQuery) GetTy() int32 {
return 0
}
// Candidator 候选节点信息
type JsonCandidator struct {
Pubkey string `protobuf:"bytes,1,opt,name=pubkey" json:"pubkey,omitempty"`
Address string `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
Ip string `protobuf:"bytes,3,opt,name=ip" json:"ip,omitempty"`
Votes int64 `protobuf:"varint,4,opt,name=votes" json:"votes,omitempty"`
Status int64 `protobuf:"varint,5,opt,name=status" json:"status,omitempty"`
}
func (m *JsonCandidator) Reset() { *m = JsonCandidator{} }
func (m *JsonCandidator) String() string { return proto.CompactTextString(m) }
func (*JsonCandidator) ProtoMessage() {}
func (*JsonCandidator) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *JsonCandidator) GetPubkey() string {
if m != nil {
return m.Pubkey
}
return ""
}
func (m *JsonCandidator) GetAddress() string {
if m != nil {
return m.Address
}
return ""
}
func (m *JsonCandidator) GetIp() string {
if m != nil {
return m.Ip
}
return ""
}
func (m *JsonCandidator) GetVotes() int64 {
if m != nil {
return m.Votes
}
return 0
}
func (m *JsonCandidator) GetStatus() int64 {
if m != nil {
return m.Status
}
return 0
}
type CandidatorReply struct {
Candidators []*Candidator `protobuf:"bytes,1,rep,name=candidators" json:"candidators,omitempty"`
Candidators []*JsonCandidator `protobuf:"bytes,1,rep,name=candidators" json:"candidators,omitempty"`
}
func (m *CandidatorReply) Reset() { *m = CandidatorReply{} }
func (m *CandidatorReply) String() string { return proto.CompactTextString(m) }
func (*CandidatorReply) ProtoMessage() {}
func (*CandidatorReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (*CandidatorReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
func (m *CandidatorReply) GetCandidators() []*Candidator {
func (m *CandidatorReply) GetCandidators() []*JsonCandidator {
if m != nil {
return m.Candidators
}
......@@ -807,7 +859,7 @@ type DposVoteQuery struct {
func (m *DposVoteQuery) Reset() { *m = DposVoteQuery{} }
func (m *DposVoteQuery) String() string { return proto.CompactTextString(m) }
func (*DposVoteQuery) ProtoMessage() {}
func (*DposVoteQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
func (*DposVoteQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
func (m *DposVoteQuery) GetPubkeys() []string {
if m != nil {
......@@ -823,16 +875,64 @@ func (m *DposVoteQuery) GetAddr() string {
return ""
}
type JsonDposVoter struct {
FromAddr string `protobuf:"bytes,1,opt,name=fromAddr" json:"fromAddr,omitempty"`
Pubkey string `protobuf:"bytes,2,opt,name=pubkey" json:"pubkey,omitempty"`
Votes int64 `protobuf:"varint,3,opt,name=votes" json:"votes,omitempty"`
Index int64 `protobuf:"varint,4,opt,name=index" json:"index,omitempty"`
Time int64 `protobuf:"varint,5,opt,name=time" json:"time,omitempty"`
}
func (m *JsonDposVoter) Reset() { *m = JsonDposVoter{} }
func (m *JsonDposVoter) String() string { return proto.CompactTextString(m) }
func (*JsonDposVoter) ProtoMessage() {}
func (*JsonDposVoter) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
func (m *JsonDposVoter) GetFromAddr() string {
if m != nil {
return m.FromAddr
}
return ""
}
func (m *JsonDposVoter) GetPubkey() string {
if m != nil {
return m.Pubkey
}
return ""
}
func (m *JsonDposVoter) GetVotes() int64 {
if m != nil {
return m.Votes
}
return 0
}
func (m *JsonDposVoter) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
func (m *JsonDposVoter) GetTime() int64 {
if m != nil {
return m.Time
}
return 0
}
type DposVoteReply struct {
Votes []*DposVoter `protobuf:"bytes,1,rep,name=votes" json:"votes,omitempty"`
Votes []*JsonDposVoter `protobuf:"bytes,1,rep,name=votes" json:"votes,omitempty"`
}
func (m *DposVoteReply) Reset() { *m = DposVoteReply{} }
func (m *DposVoteReply) String() string { return proto.CompactTextString(m) }
func (*DposVoteReply) ProtoMessage() {}
func (*DposVoteReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
func (*DposVoteReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
func (m *DposVoteReply) GetVotes() []*DposVoter {
func (m *DposVoteReply) GetVotes() []*JsonDposVoter {
if m != nil {
return m.Votes
}
......@@ -847,8 +947,8 @@ type ReceiptCandicator struct {
Status int64 `protobuf:"varint,4,opt,name=status" json:"status,omitempty"`
PreStatus int64 `protobuf:"varint,5,opt,name=preStatus" json:"preStatus,omitempty"`
StatusChange bool `protobuf:"varint,6,opt,name=statusChange" json:"statusChange,omitempty"`
Voted bool `protobuf:"varint,7,opt,name=voted" json:"voted,omitempty"`
Votes int64 `protobuf:"varint,8,opt,name=votes" json:"votes,omitempty"`
VoteType int32 `protobuf:"varint,7,opt,name=voteType" json:"voteType,omitempty"`
Vote *DposVoter `protobuf:"bytes,8,opt,name=vote" json:"vote,omitempty"`
FromAddr string `protobuf:"bytes,9,opt,name=fromAddr" json:"fromAddr,omitempty"`
CandInfo *CandidatorInfo `protobuf:"bytes,10,opt,name=candInfo" json:"candInfo,omitempty"`
Time int64 `protobuf:"varint,11,opt,name=time" json:"time,omitempty"`
......@@ -857,7 +957,7 @@ type ReceiptCandicator struct {
func (m *ReceiptCandicator) Reset() { *m = ReceiptCandicator{} }
func (m *ReceiptCandicator) String() string { return proto.CompactTextString(m) }
func (*ReceiptCandicator) ProtoMessage() {}
func (*ReceiptCandicator) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
func (*ReceiptCandicator) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
func (m *ReceiptCandicator) GetIndex() int64 {
if m != nil {
......@@ -901,18 +1001,18 @@ func (m *ReceiptCandicator) GetStatusChange() bool {
return false
}
func (m *ReceiptCandicator) GetVoted() bool {
func (m *ReceiptCandicator) GetVoteType() int32 {
if m != nil {
return m.Voted
return m.VoteType
}
return false
return 0
}
func (m *ReceiptCandicator) GetVotes() int64 {
func (m *ReceiptCandicator) GetVote() *DposVoter {
if m != nil {
return m.Votes
return m.Vote
}
return 0
return nil
}
func (m *ReceiptCandicator) GetFromAddr() string {
......@@ -943,12 +1043,15 @@ type DposVrfM struct {
Height int64 `protobuf:"varint,4,opt,name=height" json:"height,omitempty"`
M []byte `protobuf:"bytes,5,opt,name=m,proto3" json:"m,omitempty"`
Time int64 `protobuf:"varint,6,opt,name=time" json:"time,omitempty"`
CycleStart int64 `protobuf:"varint,7,opt,name=cycleStart" json:"cycleStart,omitempty"`
CycleMiddle int64 `protobuf:"varint,8,opt,name=cycleMiddle" json:"cycleMiddle,omitempty"`
CycleStop int64 `protobuf:"varint,9,opt,name=cycleStop" json:"cycleStop,omitempty"`
}
func (m *DposVrfM) Reset() { *m = DposVrfM{} }
func (m *DposVrfM) String() string { return proto.CompactTextString(m) }
func (*DposVrfM) ProtoMessage() {}
func (*DposVrfM) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
func (*DposVrfM) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
func (m *DposVrfM) GetIndex() int64 {
if m != nil {
......@@ -992,6 +1095,27 @@ func (m *DposVrfM) GetTime() int64 {
return 0
}
func (m *DposVrfM) GetCycleStart() int64 {
if m != nil {
return m.CycleStart
}
return 0
}
func (m *DposVrfM) GetCycleMiddle() int64 {
if m != nil {
return m.CycleMiddle
}
return 0
}
func (m *DposVrfM) GetCycleStop() int64 {
if m != nil {
return m.CycleStop
}
return 0
}
type DposVrfRP struct {
Index int64 `protobuf:"varint,1,opt,name=Index" json:"Index,omitempty"`
Pubkey []byte `protobuf:"bytes,2,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
......@@ -1001,12 +1125,15 @@ type DposVrfRP struct {
R []byte `protobuf:"bytes,6,opt,name=r,proto3" json:"r,omitempty"`
P []byte `protobuf:"bytes,7,opt,name=p,proto3" json:"p,omitempty"`
Time int64 `protobuf:"varint,8,opt,name=time" json:"time,omitempty"`
CycleStart int64 `protobuf:"varint,9,opt,name=cycleStart" json:"cycleStart,omitempty"`
CycleMiddle int64 `protobuf:"varint,10,opt,name=cycleMiddle" json:"cycleMiddle,omitempty"`
CycleStop int64 `protobuf:"varint,11,opt,name=cycleStop" json:"cycleStop,omitempty"`
}
func (m *DposVrfRP) Reset() { *m = DposVrfRP{} }
func (m *DposVrfRP) String() string { return proto.CompactTextString(m) }
func (*DposVrfRP) ProtoMessage() {}
func (*DposVrfRP) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
func (*DposVrfRP) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} }
func (m *DposVrfRP) GetIndex() int64 {
if m != nil {
......@@ -1064,6 +1191,27 @@ func (m *DposVrfRP) GetTime() int64 {
return 0
}
func (m *DposVrfRP) GetCycleStart() int64 {
if m != nil {
return m.CycleStart
}
return 0
}
func (m *DposVrfRP) GetCycleMiddle() int64 {
if m != nil {
return m.CycleMiddle
}
return 0
}
func (m *DposVrfRP) GetCycleStop() int64 {
if m != nil {
return m.CycleStop
}
return 0
}
type DposVrfMRegist struct {
Pubkey string `protobuf:"bytes,1,opt,name=pubkey" json:"pubkey,omitempty"`
Cycle int64 `protobuf:"varint,2,opt,name=cycle" json:"cycle,omitempty"`
......@@ -1073,7 +1221,7 @@ type DposVrfMRegist struct {
func (m *DposVrfMRegist) Reset() { *m = DposVrfMRegist{} }
func (m *DposVrfMRegist) String() string { return proto.CompactTextString(m) }
func (*DposVrfMRegist) ProtoMessage() {}
func (*DposVrfMRegist) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
func (*DposVrfMRegist) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} }
func (m *DposVrfMRegist) GetPubkey() string {
if m != nil {
......@@ -1106,7 +1254,7 @@ type DposVrfRPRegist struct {
func (m *DposVrfRPRegist) Reset() { *m = DposVrfRPRegist{} }
func (m *DposVrfRPRegist) String() string { return proto.CompactTextString(m) }
func (*DposVrfRPRegist) ProtoMessage() {}
func (*DposVrfRPRegist) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} }
func (*DposVrfRPRegist) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} }
func (m *DposVrfRPRegist) GetPubkey() string {
if m != nil {
......@@ -1147,12 +1295,15 @@ type ReceiptVrf struct {
R []byte `protobuf:"bytes,7,opt,name=r,proto3" json:"r,omitempty"`
P []byte `protobuf:"bytes,8,opt,name=p,proto3" json:"p,omitempty"`
Time int64 `protobuf:"varint,9,opt,name=time" json:"time,omitempty"`
CycleStart int64 `protobuf:"varint,10,opt,name=cycleStart" json:"cycleStart,omitempty"`
CycleMiddle int64 `protobuf:"varint,11,opt,name=cycleMiddle" json:"cycleMiddle,omitempty"`
CycleStop int64 `protobuf:"varint,12,opt,name=cycleStop" json:"cycleStop,omitempty"`
}
func (m *ReceiptVrf) Reset() { *m = ReceiptVrf{} }
func (m *ReceiptVrf) String() string { return proto.CompactTextString(m) }
func (*ReceiptVrf) ProtoMessage() {}
func (*ReceiptVrf) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} }
func (*ReceiptVrf) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} }
func (m *ReceiptVrf) GetIndex() int64 {
if m != nil {
......@@ -1217,6 +1368,27 @@ func (m *ReceiptVrf) GetTime() int64 {
return 0
}
func (m *ReceiptVrf) GetCycleStart() int64 {
if m != nil {
return m.CycleStart
}
return 0
}
func (m *ReceiptVrf) GetCycleMiddle() int64 {
if m != nil {
return m.CycleMiddle
}
return 0
}
func (m *ReceiptVrf) GetCycleStop() int64 {
if m != nil {
return m.CycleStop
}
return 0
}
type VrfInfo struct {
Index int64 `protobuf:"varint,1,opt,name=Index" json:"Index,omitempty"`
Pubkey []byte `protobuf:"bytes,2,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
......@@ -1231,7 +1403,7 @@ type VrfInfo struct {
func (m *VrfInfo) Reset() { *m = VrfInfo{} }
func (m *VrfInfo) String() string { return proto.CompactTextString(m) }
func (*VrfInfo) ProtoMessage() {}
func (*VrfInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} }
func (*VrfInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} }
func (m *VrfInfo) GetIndex() int64 {
if m != nil {
......@@ -1290,15 +1462,23 @@ func (m *VrfInfo) GetTime() int64 {
}
type DposVrfQuery struct {
Ty int64 `protobuf:"varint,1,opt,name=ty" json:"ty,omitempty"`
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"`
Cycle int64 `protobuf:"varint,3,opt,name=cycle" json:"cycle,omitempty"`
Pubkeys []string `protobuf:"bytes,1,rep,name=pubkeys" json:"pubkeys,omitempty"`
Ty int64 `protobuf:"varint,2,opt,name=ty" json:"ty,omitempty"`
Timestamp int64 `protobuf:"varint,3,opt,name=timestamp" json:"timestamp,omitempty"`
Cycle int64 `protobuf:"varint,4,opt,name=cycle" json:"cycle,omitempty"`
}
func (m *DposVrfQuery) Reset() { *m = DposVrfQuery{} }
func (m *DposVrfQuery) String() string { return proto.CompactTextString(m) }
func (*DposVrfQuery) ProtoMessage() {}
func (*DposVrfQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} }
func (*DposVrfQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} }
func (m *DposVrfQuery) GetPubkeys() []string {
if m != nil {
return m.Pubkeys
}
return nil
}
func (m *DposVrfQuery) GetTy() int64 {
if m != nil {
......@@ -1321,16 +1501,88 @@ func (m *DposVrfQuery) GetCycle() int64 {
return 0
}
type JsonVrfInfo struct {
Index int64 `protobuf:"varint,1,opt,name=Index" json:"Index,omitempty"`
Pubkey string `protobuf:"bytes,2,opt,name=pubkey" json:"pubkey,omitempty"`
Cycle int64 `protobuf:"varint,4,opt,name=cycle" json:"cycle,omitempty"`
Height int64 `protobuf:"varint,5,opt,name=height" json:"height,omitempty"`
M string `protobuf:"bytes,6,opt,name=m" json:"m,omitempty"`
R string `protobuf:"bytes,7,opt,name=r" json:"r,omitempty"`
P string `protobuf:"bytes,8,opt,name=p" json:"p,omitempty"`
Time int64 `protobuf:"varint,9,opt,name=time" json:"time,omitempty"`
}
func (m *JsonVrfInfo) Reset() { *m = JsonVrfInfo{} }
func (m *JsonVrfInfo) String() string { return proto.CompactTextString(m) }
func (*JsonVrfInfo) ProtoMessage() {}
func (*JsonVrfInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} }
func (m *JsonVrfInfo) GetIndex() int64 {
if m != nil {
return m.Index
}
return 0
}
func (m *JsonVrfInfo) GetPubkey() string {
if m != nil {
return m.Pubkey
}
return ""
}
func (m *JsonVrfInfo) GetCycle() int64 {
if m != nil {
return m.Cycle
}
return 0
}
func (m *JsonVrfInfo) GetHeight() int64 {
if m != nil {
return m.Height
}
return 0
}
func (m *JsonVrfInfo) GetM() string {
if m != nil {
return m.M
}
return ""
}
func (m *JsonVrfInfo) GetR() string {
if m != nil {
return m.R
}
return ""
}
func (m *JsonVrfInfo) GetP() string {
if m != nil {
return m.P
}
return ""
}
func (m *JsonVrfInfo) GetTime() int64 {
if m != nil {
return m.Time
}
return 0
}
type DposVrfReply struct {
Vrf []*VrfInfo `protobuf:"bytes,1,rep,name=vrf" json:"vrf,omitempty"`
Vrf []*JsonVrfInfo `protobuf:"bytes,1,rep,name=vrf" json:"vrf,omitempty"`
}
func (m *DposVrfReply) Reset() { *m = DposVrfReply{} }
func (m *DposVrfReply) String() string { return proto.CompactTextString(m) }
func (*DposVrfReply) ProtoMessage() {}
func (*DposVrfReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} }
func (*DposVrfReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} }
func (m *DposVrfReply) GetVrf() []*VrfInfo {
func (m *DposVrfReply) GetVrf() []*JsonVrfInfo {
if m != nil {
return m.Vrf
}
......@@ -1347,8 +1599,10 @@ func init() {
proto.RegisterType((*DposCancelVote)(nil), "types.DposCancelVote")
proto.RegisterType((*DposVoteAction)(nil), "types.DposVoteAction")
proto.RegisterType((*CandidatorQuery)(nil), "types.CandidatorQuery")
proto.RegisterType((*JsonCandidator)(nil), "types.JsonCandidator")
proto.RegisterType((*CandidatorReply)(nil), "types.CandidatorReply")
proto.RegisterType((*DposVoteQuery)(nil), "types.DposVoteQuery")
proto.RegisterType((*JsonDposVoter)(nil), "types.JsonDposVoter")
proto.RegisterType((*DposVoteReply)(nil), "types.DposVoteReply")
proto.RegisterType((*ReceiptCandicator)(nil), "types.ReceiptCandicator")
proto.RegisterType((*DposVrfM)(nil), "types.DposVrfM")
......@@ -1358,73 +1612,82 @@ func init() {
proto.RegisterType((*ReceiptVrf)(nil), "types.ReceiptVrf")
proto.RegisterType((*VrfInfo)(nil), "types.VrfInfo")
proto.RegisterType((*DposVrfQuery)(nil), "types.DposVrfQuery")
proto.RegisterType((*JsonVrfInfo)(nil), "types.JsonVrfInfo")
proto.RegisterType((*DposVrfReply)(nil), "types.DposVrfReply")
}
func init() { proto.RegisterFile("dposvote.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 992 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02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
0x0a, 0xa1, 0xa9, 0xe8, 0x4a, 0x6b, 0x25, 0x4c, 0xbb, 0xde, 0x09, 0xd5, 0x10, 0x71, 0x55, 0x9d,
0x6c, 0x4a, 0xd5, 0xbc, 0xf6, 0xe0, 0xea, 0xd9, 0x8d, 0x3f, 0xd1, 0x35, 0xa5, 0x2e, 0xce, 0xc0,
0xb9, 0xe0, 0x2b, 0xa5, 0x8a, 0x13, 0xb5, 0xea, 0x8a, 0x1a, 0x2a, 0x5c, 0xaf, 0x47, 0xf8, 0x7f,
0xc5, 0x93, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x81, 0x84, 0xc9, 0x2d, 0x69, 0x0c, 0x00, 0x00,
// 1117 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x51, 0x8f, 0xdb, 0xc4,
0x13, 0x8f, 0xed, 0x38, 0x89, 0xc7, 0xbe, 0xdc, 0xff, 0xbf, 0xa4, 0x95, 0x55, 0x10, 0x0a, 0x56,
0x91, 0x22, 0x1e, 0x4e, 0x6a, 0x28, 0x42, 0x80, 0x40, 0x6a, 0x0f, 0x89, 0xb4, 0xa2, 0xa5, 0x6c,
0x4f, 0x27, 0x24, 0x9e, 0x5c, 0x7b, 0x73, 0x67, 0x91, 0xc4, 0xd6, 0xda, 0x77, 0x6a, 0x24, 0x24,
0x90, 0x10, 0x5f, 0x83, 0x17, 0x1e, 0xf8, 0x4e, 0x7c, 0x00, 0xc4, 0x87, 0xe0, 0x01, 0xed, 0xec,
0x66, 0xbd, 0xf6, 0x5d, 0xee, 0xc8, 0x41, 0xfb, 0x96, 0x99, 0xd9, 0x19, 0xcf, 0xfc, 0x7e, 0xbb,
0x33, 0x13, 0x18, 0xa6, 0x45, 0x5e, 0x9e, 0xe7, 0x15, 0x3b, 0x28, 0x78, 0x5e, 0xe5, 0xc4, 0xad,
0xd6, 0x05, 0x2b, 0xa3, 0x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 0x0c, 0xae, 0x18, 0x61, 0x72, 0x98, 0xcb, 0xfb,
0x61, 0x57, 0x6b, 0x51, 0xbd, 0x88, 0x50, 0x56, 0xf1, 0xb2, 0x50, 0x34, 0xd6, 0x8a, 0xcb, 0x6b,
0x88, 0x7e, 0xb3, 0xc0, 0x17, 0x83, 0x64, 0x17, 0x5c, 0xbc, 0x7f, 0x8b, 0x8b, 0xd7, 0xc0, 0xc5,
0x6b, 0xe0, 0xe2, 0x6d, 0xc3, 0xe5, 0xbe, 0xc6, 0x45, 0x4e, 0xc5, 0xbb, 0xe0, 0x9c, 0xf3, 0xb9,
0x9a, 0x89, 0xc4, 0x98, 0x89, 0xaa, 0x14, 0x2a, 0xcc, 0x2f, 0x7a, 0xf8, 0x37, 0xfb, 0xfd, 0xbf,
0x03, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x64, 0xcc, 0x30, 0x78, 0x0f, 0x00, 0x00,
}
......@@ -8,6 +8,7 @@ import "errors"
// Errors for Dpos
var (
ErrNoSuchVote = errors.New("ErrNoSuchVote")
ErrNotEnoughVotes = errors.New("ErrNotEnoughVotes")
ErrCandidatorExist = errors.New("ErrCandidatorExist")
ErrCandidatorInvalidStatus = errors.New("ErrCandidatorInvalidStatus")
......
......@@ -126,7 +126,7 @@ var opt_dpos_vrfm = &table.Option{
Prefix: "LODB-dpos",
Name: "vrfm",
Primary: "index",
Index: []string{"pubkey_cycle"},
Index: []string{"pubkey_cycle","cycle"},
}
//NewDposVrfMTable 新建表
......@@ -169,6 +169,8 @@ func (tx *DposVrfMRow) Get(key string) ([]byte, error) {
return []byte(fmt.Sprintf("%018d", tx.Index)), nil
} else if key == "pubkey_cycle" {
return []byte(fmt.Sprintf("%X:%018d", tx.Pubkey, tx.Cycle)), nil
} else if key == "cycle" {
return []byte(fmt.Sprintf("%018d", tx.Cycle)), nil
}
return nil, types.ErrNotFound
......@@ -179,7 +181,7 @@ var opt_dpos_vrfrp = &table.Option{
Prefix: "LODB-dpos",
Name: "vrfrp",
Primary: "index",
Index: []string{"pubkey_cycle"},
Index: []string{"pubkey_cycle", "cycle"},
}
//NewDposVrfRPTable 新建表
......@@ -222,6 +224,8 @@ func (tx *DposVrfRPRow) Get(key string) ([]byte, error) {
return []byte(fmt.Sprintf("%018d", tx.Index)), nil
} else if key == "pubkey_cycle" {
return []byte(fmt.Sprintf("%X:%018d", tx.Pubkey, tx.Cycle)), nil
} else if key == "cycle" {
return []byte(fmt.Sprintf("%018d", tx.Cycle)), nil
}
return nil, types.ErrNotFound
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment