Commit 60f2071b authored by jiangpeng's avatar jiangpeng

dapp/vote:update

parent d42515f7
...@@ -23,7 +23,7 @@ func Cmd() *cobra.Command { ...@@ -23,7 +23,7 @@ func Cmd() *cobra.Command {
cmd.AddCommand( cmd.AddCommand(
//create tx //create tx
createGroupCMD(), createGroupCMD(),
updateMemberCMD(), updateGroupCMD(),
createVoteCMD(), createVoteCMD(),
commitVoteCMD(), commitVoteCMD(),
//query rpc //query rpc
......
...@@ -3,6 +3,7 @@ package commands ...@@ -3,6 +3,7 @@ package commands
import ( import (
"fmt" "fmt"
"os" "os"
"time"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
vty "github.com/33cn/plugin/plugin/dapp/vote/types" vty "github.com/33cn/plugin/plugin/dapp/vote/types"
...@@ -22,7 +23,7 @@ func createGroupCMD() *cobra.Command { ...@@ -22,7 +23,7 @@ func createGroupCMD() *cobra.Command {
func createGroupFlags(cmd *cobra.Command) { func createGroupFlags(cmd *cobra.Command) {
cmd.Flags().StringP("name", "n", "", "group name") cmd.Flags().StringP("name", "n", "", "group name")
cmd.Flags().StringArrayP("admins", "a", nil, "group admin address array") cmd.Flags().StringArrayP("admins", "a", nil, "group admin address array, default set creator as admin")
cmd.Flags().StringArrayP("members", "m", nil, "group member address array") cmd.Flags().StringArrayP("members", "m", nil, "group member address array")
cmd.Flags().UintSliceP("weights", "w", nil, "member vote weight array") cmd.Flags().UintSliceP("weights", "w", nil, "member vote weight array")
markRequired(cmd, "name") markRequired(cmd, "name")
...@@ -37,12 +38,14 @@ func createGroup(cmd *cobra.Command, args []string) { ...@@ -37,12 +38,14 @@ func createGroup(cmd *cobra.Command, args []string) {
if name == "" { if name == "" {
fmt.Fprintf(os.Stderr, "ErrNilGroupName") fmt.Fprintf(os.Stderr, "ErrNilGroupName")
return
} }
if len(weights) == 0 { if len(weights) == 0 {
weights = make([]uint, len(memberAddrs)) weights = make([]uint, len(memberAddrs))
} }
if len(weights) != len(memberAddrs) { if len(weights) != len(memberAddrs) {
fmt.Fprintf(os.Stderr, "member address array length should equal with vote weight array length") fmt.Fprintf(os.Stderr, "member address array length should equal with vote weight array length")
return
} }
members := make([]*vty.GroupMember, 0) members := make([]*vty.GroupMember, 0)
...@@ -58,40 +61,46 @@ func createGroup(cmd *cobra.Command, args []string) { ...@@ -58,40 +61,46 @@ func createGroup(cmd *cobra.Command, args []string) {
sendCreateTxRPC(cmd, vty.NameCreateGroupAction, params) sendCreateTxRPC(cmd, vty.NameCreateGroupAction, params)
} }
func updateMemberCMD() *cobra.Command { func updateGroupCMD() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "updateMember", Use: "updateGroup",
Short: "create tx(update group members)", Short: "create tx(update group members or admin)",
Run: updateMember, Run: updateGroup,
Example: "updateMember -g=id -a=addMember1 -a=addMember2 -r=removeMember1 ...", Example: "updateGroup -g=id -a=addMember1 -a=addMember2 -r=removeMember1 ...",
} }
updateMemberFlags(cmd) updateGroupFlags(cmd)
return cmd return cmd
} }
func updateMemberFlags(cmd *cobra.Command) { func updateGroupFlags(cmd *cobra.Command) {
cmd.Flags().StringP("groupID", "g", "", "group id") cmd.Flags().StringP("groupID", "g", "", "group id")
cmd.Flags().StringArrayP("addMembers", "a", nil, "group member address array for adding") cmd.Flags().StringArrayP("addMembers", "a", nil, "group member address array for adding")
cmd.Flags().UintSliceP("weights", "w", nil, "member vote weight array for adding") cmd.Flags().UintSliceP("weights", "w", nil, "member vote weight array for adding")
cmd.Flags().StringArrayP("removeMembers", "r", nil, "group member address array for removing") cmd.Flags().StringArrayP("removeMembers", "r", nil, "group member address array for removing")
cmd.Flags().StringArrayP("addAdmins", "d", nil, "group admin address array for adding")
cmd.Flags().StringArrayP("removeAdmins", "m", nil, "group admin address array for removing")
markRequired(cmd, "groupID") markRequired(cmd, "groupID")
} }
func updateMember(cmd *cobra.Command, args []string) { func updateGroup(cmd *cobra.Command, args []string) {
groupID, _ := cmd.Flags().GetString("groupID") groupID, _ := cmd.Flags().GetString("groupID")
addAddrs, _ := cmd.Flags().GetStringArray("addMembers") addAddrs, _ := cmd.Flags().GetStringArray("addMembers")
weights, _ := cmd.Flags().GetUintSlice("weights") weights, _ := cmd.Flags().GetUintSlice("weights")
removeAddrs, _ := cmd.Flags().GetStringArray("removeMembers") removeAddrs, _ := cmd.Flags().GetStringArray("removeMembers")
addAdmins, _ := cmd.Flags().GetStringArray("addAdmins")
removeAdmins, _ := cmd.Flags().GetStringArray("removeAdmins")
if groupID == "" { if groupID == "" {
fmt.Fprintf(os.Stderr, "ErrNilGroupID") fmt.Fprintf(os.Stderr, "ErrNilGroupID")
return
} }
if len(weights) == 0 { if len(weights) == 0 {
weights = make([]uint, len(addAddrs)) weights = make([]uint, len(addAddrs))
} }
if len(weights) != len(addAddrs) { if len(weights) != len(addAddrs) {
fmt.Fprintf(os.Stderr, "member address array length should equal with vote weight array length") fmt.Fprintf(os.Stderr, "member address array length should equal with vote weight array length")
return
} }
addMembers := make([]*vty.GroupMember, 0) addMembers := make([]*vty.GroupMember, 0)
...@@ -99,12 +108,14 @@ func updateMember(cmd *cobra.Command, args []string) { ...@@ -99,12 +108,14 @@ func updateMember(cmd *cobra.Command, args []string) {
addMembers = append(addMembers, &vty.GroupMember{Addr: addr, VoteWeight: uint32(weights[i])}) addMembers = append(addMembers, &vty.GroupMember{Addr: addr, VoteWeight: uint32(weights[i])})
} }
params := &vty.UpdateMember{ params := &vty.UpdateGroup{
GroupID: groupID, GroupID: groupID,
RemoveMemberAddrs: removeAddrs, RemoveMembers: removeAddrs,
AddMembers: addMembers, AddMembers: addMembers,
AddAdmins: addAdmins,
RemoveAdmins: removeAdmins,
} }
sendCreateTxRPC(cmd, vty.NameUpdateMemberAction, params) sendCreateTxRPC(cmd, vty.NameUpdateGroupAction, params)
} }
func createVoteCMD() *cobra.Command { func createVoteCMD() *cobra.Command {
...@@ -119,40 +130,47 @@ func createVoteCMD() *cobra.Command { ...@@ -119,40 +130,47 @@ func createVoteCMD() *cobra.Command {
func createVoteFlags(cmd *cobra.Command) { func createVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("name", "n", "", "vote name") cmd.Flags().StringP("name", "n", "", "vote name")
cmd.Flags().StringArrayP("groupIDs", "g", nil, "related group id array") cmd.Flags().StringP("groupID", "g", "", "belonging group id")
cmd.Flags().StringArrayP("options", "o", nil, "vote option array") cmd.Flags().StringArrayP("options", "o", nil, "vote option array")
cmd.Flags().Int64P("beginTime", "b", 0, "vote begin unix timestamp, default set now time") cmd.Flags().Int64P("beginTime", "b", 0, "vote begin unix timestamp, default set current time")
cmd.Flags().Int64P("endTime", "e", 0, "vote end unix timestamp, default set beginTime + 300 seconds") cmd.Flags().StringP("duration", "d", "24h", "vote duration time, such as(10s, 10m, 10h), default 24h")
markRequired(cmd, "name", "groupIDs", "options") markRequired(cmd, "name", "groupID", "options")
} }
func createVote(cmd *cobra.Command, args []string) { func createVote(cmd *cobra.Command, args []string) {
name, _ := cmd.Flags().GetString("name") name, _ := cmd.Flags().GetString("name")
groupIDs, _ := cmd.Flags().GetStringArray("groupIDs") groupID, _ := cmd.Flags().GetString("groupID")
options, _ := cmd.Flags().GetStringArray("options") options, _ := cmd.Flags().GetStringArray("options")
beginTime, _ := cmd.Flags().GetInt64("beginTime") beginTime, _ := cmd.Flags().GetInt64("beginTime")
endTime, _ := cmd.Flags().GetInt64("endTime") duration, _ := cmd.Flags().GetString("duration")
if name == "" { if name == "" {
fmt.Fprintf(os.Stderr, "ErrNilVoteName") fmt.Fprintf(os.Stderr, "ErrNilVoteName")
return
} }
if len(groupIDs) == 0 { if len(groupID) == 0 {
fmt.Fprintf(os.Stderr, "ErrNilGroupIDs") fmt.Fprintf(os.Stderr, "ErrNilGroupID")
return
} }
if len(options) == 0 { if len(options) == 0 {
fmt.Fprintf(os.Stderr, "ErrNilOptions") fmt.Fprintf(os.Stderr, "ErrNilOptions")
return
} }
if beginTime == 0 { if beginTime == 0 {
beginTime = types.Now().Unix() beginTime = types.Now().Unix()
} }
if endTime == 0 {
endTime = beginTime + 300 dt, err := time.ParseDuration(duration)
if err != nil {
fmt.Fprintf(os.Stderr, "InvalidDurationTime:"+err.Error())
return
} }
endTime := beginTime + int64(dt/time.Second)
params := &vty.CreateVote{ params := &vty.CreateVote{
Name: name, Name: name,
VoteGroups: groupIDs, GroupID: groupID,
VoteOptions: options, VoteOptions: options,
BeginTimestamp: beginTime, BeginTimestamp: beginTime,
EndTimestamp: endTime, EndTimestamp: endTime,
...@@ -172,26 +190,77 @@ func commitVoteCMD() *cobra.Command { ...@@ -172,26 +190,77 @@ func commitVoteCMD() *cobra.Command {
func commitVoteFlags(cmd *cobra.Command) { func commitVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("voteID", "v", "", "vote id") cmd.Flags().StringP("voteID", "v", "", "vote id")
cmd.Flags().StringP("groupID", "g", "", "belonging group id")
cmd.Flags().Uint32P("optionIndex", "o", 0, "voting option index in option array") cmd.Flags().Uint32P("optionIndex", "o", 0, "voting option index in option array")
markRequired(cmd, "voteID", "groupID", "optionIndex") markRequired(cmd, "voteID", "optionIndex")
} }
func commitVote(cmd *cobra.Command, args []string) { func commitVote(cmd *cobra.Command, args []string) {
voteID, _ := cmd.Flags().GetString("voteID") voteID, _ := cmd.Flags().GetString("voteID")
groupID, _ := cmd.Flags().GetString("groupID")
optionIndex, _ := cmd.Flags().GetUint32("optionIndex") optionIndex, _ := cmd.Flags().GetUint32("optionIndex")
if voteID == "" { if voteID == "" {
fmt.Fprintf(os.Stderr, "ErrNilVoteID") fmt.Fprintf(os.Stderr, "ErrNilVoteID")
} return
if len(groupID) == 0 {
fmt.Fprintf(os.Stderr, "ErrNilGroupID")
} }
params := &vty.CommitVote{ params := &vty.CommitVote{
VoteID: voteID, VoteID: voteID,
GroupID: groupID,
OptionIndex: optionIndex, OptionIndex: optionIndex,
} }
sendCreateTxRPC(cmd, vty.NameCommitVoteAction, params) sendCreateTxRPC(cmd, vty.NameCommitVoteAction, params)
} }
func closeVoteCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "closeVote",
Short: "create tx(close vote)",
Run: closeVote,
}
closeVoteFlags(cmd)
return cmd
}
func closeVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("voteID", "v", "", "vote id")
markRequired(cmd, "voteID")
}
func closeVote(cmd *cobra.Command, args []string) {
voteID, _ := cmd.Flags().GetString("voteID")
if voteID == "" {
fmt.Fprintf(os.Stderr, "ErrNilVoteID")
return
}
params := &vty.CloseVote{
VoteID: voteID,
}
sendCreateTxRPC(cmd, vty.NameCloseVoteAction, params)
}
func updateMemberCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "updateMember",
Short: "create tx(update member name)",
Run: updateMember,
}
updateMemberFlags(cmd)
return cmd
}
func updateMemberFlags(cmd *cobra.Command) {
cmd.Flags().StringP("name", "n", "", "member name")
markRequired(cmd, "name")
}
func updateMember(cmd *cobra.Command, args []string) {
name, _ := cmd.Flags().GetString("name")
if name == "" {
fmt.Fprintf(os.Stderr, "ErrNilMemberName")
return
}
params := &vty.UpdateMember{
Name: name,
}
sendCreateTxRPC(cmd, vty.NameUpdateMemberAction, params)
}
...@@ -11,36 +11,38 @@ import ( ...@@ -11,36 +11,38 @@ import (
func groupInfoCMD() *cobra.Command { func groupInfoCMD() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "groupInfo", Use: "groupInfo",
Short: "show group info", Short: "get group infos",
Run: groupInfo, Run: groupInfo,
Example: "groupInfo -g=id1 -g=id2...",
} }
groupInfoFlags(cmd) groupInfoFlags(cmd)
return cmd return cmd
} }
func groupInfoFlags(cmd *cobra.Command) { func groupInfoFlags(cmd *cobra.Command) {
cmd.Flags().StringP("groupID", "g", "", "group id") cmd.Flags().StringArrayP("groupIDs", "g", nil, "group id array")
markRequired(cmd, "groupID") markRequired(cmd, "groupIDs")
} }
func groupInfo(cmd *cobra.Command, args []string) { func groupInfo(cmd *cobra.Command, args []string) {
groupID, _ := cmd.Flags().GetString("groupID") groupIDs, _ := cmd.Flags().GetStringArray("groupIDs")
if len(groupID) == 0 { if len(groupIDs) == 0 {
fmt.Fprintf(os.Stderr, "ErrNilGroupID") fmt.Fprintf(os.Stderr, "ErrNilGroupIDs")
return
} }
params := &types.ReqString{ params := &vty.ReqStrings{
Data: groupID, Items: groupIDs,
} }
info := &vty.GroupVoteInfo{} info := &vty.GroupInfos{}
sendQueryRPC(cmd, "GetGroup", params, info) sendQueryRPC(cmd, "GetGroups", params, info)
} }
func voteInfoCMD() *cobra.Command { func voteInfoCMD() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "voteInfo", Use: "voteInfo",
Short: "show vote info", Short: "get vote info",
Run: voteInfo, Run: voteInfo,
} }
voteInfoFlags(cmd) voteInfoFlags(cmd)
...@@ -48,27 +50,28 @@ func voteInfoCMD() *cobra.Command { ...@@ -48,27 +50,28 @@ func voteInfoCMD() *cobra.Command {
} }
func voteInfoFlags(cmd *cobra.Command) { func voteInfoFlags(cmd *cobra.Command) {
cmd.Flags().StringP("voteID", "v", "", "vote id") cmd.Flags().StringArrayP("voteIDs", "v", nil, "vote id array")
markRequired(cmd, "voteID") markRequired(cmd, "voteID")
} }
func voteInfo(cmd *cobra.Command, args []string) { func voteInfo(cmd *cobra.Command, args []string) {
voteID, _ := cmd.Flags().GetString("voteID") voteIDs, _ := cmd.Flags().GetStringArray("voteIDs")
if len(voteID) == 0 { if len(voteIDs) == 0 {
fmt.Fprintf(os.Stderr, "ErrNilVoteID") fmt.Fprintf(os.Stderr, "ErrNilVoteID")
return
} }
params := &types.ReqString{ params := &vty.ReqStrings{
Data: voteID, Items: voteIDs,
} }
info := &vty.VoteInfo{} info := &vty.ReplyVoteList{}
sendQueryRPC(cmd, "GetVote", params, info) sendQueryRPC(cmd, "GetVotes", params, info)
} }
func memberInfoCMD() *cobra.Command { func memberInfoCMD() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "memberInfo", Use: "memberInfo",
Short: "show member info", Short: "get member info",
Run: memberInfo, Run: memberInfo,
} }
memberInfoFlags(cmd) memberInfoFlags(cmd)
...@@ -76,21 +79,22 @@ func memberInfoCMD() *cobra.Command { ...@@ -76,21 +79,22 @@ func memberInfoCMD() *cobra.Command {
} }
func memberInfoFlags(cmd *cobra.Command) { func memberInfoFlags(cmd *cobra.Command) {
cmd.Flags().StringP("addr", "a", "", "member address") cmd.Flags().StringArrayP("addrs", "a", nil, "member address array")
markRequired(cmd, "addr") markRequired(cmd, "addr")
} }
func memberInfo(cmd *cobra.Command, args []string) { func memberInfo(cmd *cobra.Command, args []string) {
addr, _ := cmd.Flags().GetString("addr") addrs, _ := cmd.Flags().GetStringArray("addr")
if len(addr) == 0 { if len(addrs) == 0 {
fmt.Fprintf(os.Stderr, "ErrNilAddress") fmt.Fprintf(os.Stderr, "ErrNilAddress")
return
} }
params := &types.ReqString{ params := &vty.ReqStrings{
Data: addr, Items: addrs,
} }
info := &vty.MemberInfo{} info := &vty.MemberInfos{}
sendQueryRPC(cmd, "GetMember", params, info) sendQueryRPC(cmd, "GetMembers", params, info)
} }
func listGroupCMD() *cobra.Command { func listGroupCMD() *cobra.Command {
...@@ -104,7 +108,7 @@ func listGroupCMD() *cobra.Command { ...@@ -104,7 +108,7 @@ func listGroupCMD() *cobra.Command {
} }
func listGroup(cmd *cobra.Command, args []string) { func listGroup(cmd *cobra.Command, args []string) {
runListCMD(cmd, args, "ListGroup", &vty.GroupVoteInfos{}) runListCMD(cmd, "ListGroup", &vty.GroupInfos{})
} }
func listVoteCMD() *cobra.Command { func listVoteCMD() *cobra.Command {
...@@ -113,12 +117,22 @@ func listVoteCMD() *cobra.Command { ...@@ -113,12 +117,22 @@ func listVoteCMD() *cobra.Command {
Short: "show vote list", Short: "show vote list",
Run: listVote, Run: listVote,
} }
listCmdFlags(cmd) listVoteFlags(cmd)
return cmd return cmd
} }
func listVoteFlags(cmd *cobra.Command) {
cmd.Flags().StringP("groupID", "g", "", "list vote belongs to specified group, list all if not set")
listCmdFlags(cmd)
}
func listVote(cmd *cobra.Command, args []string) { func listVote(cmd *cobra.Command, args []string) {
runListCMD(cmd, args, "ListVote", &vty.VoteInfos{}) groupID, _ := cmd.Flags().GetString("groupID")
listReq := getListReq(cmd)
req := &vty.ReqListVote{
GroupID: groupID,
ListReq: listReq,
}
sendQueryRPC(cmd, "ListVote", req, &vty.ReplyVoteList{})
} }
func listMemberCMD() *cobra.Command { func listMemberCMD() *cobra.Command {
...@@ -132,23 +146,28 @@ func listMemberCMD() *cobra.Command { ...@@ -132,23 +146,28 @@ func listMemberCMD() *cobra.Command {
} }
func listMember(cmd *cobra.Command, args []string) { func listMember(cmd *cobra.Command, args []string) {
runListCMD(cmd, args, "ListMember", &vty.MemberInfos{}) runListCMD(cmd, "ListMember", &vty.MemberInfos{})
} }
func listCmdFlags(cmd *cobra.Command) { func listCmdFlags(cmd *cobra.Command) {
cmd.Flags().StringP("startItem", "s", "", "list start item id, default nil value") cmd.Flags().StringP("startItem", "s", "", "list start item id, default nil value")
cmd.Flags().Uint32P("count", "c", 10, "list count, default 10") cmd.Flags().Uint32P("count", "c", 10, "list count, default 10")
cmd.Flags().Uint32P("direction", "d", 0, "list direction, default 1 (Ascending order)") cmd.Flags().Uint32P("direction", "d", 1, "list direction, default 1 (Ascending order)")
}
func runListCMD(cmd *cobra.Command, funcName string, reply types.Message) {
req := getListReq(cmd)
sendQueryRPC(cmd, funcName, req, reply)
} }
func runListCMD(cmd *cobra.Command, args []string, funcName string, reply types.Message) { func getListReq(cmd *cobra.Command) *vty.ReqListItem {
startID, _ := cmd.Flags().GetString("startItem") startID, _ := cmd.Flags().GetString("startItem")
count, _ := cmd.Flags().GetUint32("count") count, _ := cmd.Flags().GetUint32("count")
direction, _ := cmd.Flags().GetUint32("direction") direction, _ := cmd.Flags().GetUint32("direction")
params := &vty.ReqListItem{ req := &vty.ReqListItem{
StartItemID: startID, StartItemID: startID,
Count: int32(count), Count: int32(count),
Direction: int32(direction), Direction: int32(direction),
} }
sendQueryRPC(cmd, funcName, params, reply) return req
} }
...@@ -3,6 +3,8 @@ package executor ...@@ -3,6 +3,8 @@ package executor
import ( import (
"encoding/hex" "encoding/hex"
"github.com/33cn/chain33/system/dapp"
dbm "github.com/33cn/chain33/common/db" dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
vty "github.com/33cn/plugin/plugin/dapp/vote/types" vty "github.com/33cn/plugin/plugin/dapp/vote/types"
...@@ -51,14 +53,15 @@ func (a *action) createGroup(create *vty.CreateGroup) (*types.Receipt, error) { ...@@ -51,14 +53,15 @@ func (a *action) createGroup(create *vty.CreateGroup) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk} receipt := &types.Receipt{Ty: types.ExecOk}
xhash := hex.EncodeToString(a.txHash)
group := &vty.GroupInfo{} group := &vty.GroupInfo{}
group.Name = create.Name group.Name = create.Name
group.ID = formatGroupID(xhash) group.ID = formatGroupID(dapp.HeightIndexStr(a.height, int64(a.index)))
//添加创建者作为默认管理员 //添加创建者作为默认管理员
group.Admins = append(group.Admins, create.Admins...) group.Admins = append(group.Admins, a.fromAddr)
if !checkSliceItemExist(a.fromAddr, create.Admins) { for _, addr := range create.GetAdmins() {
group.Admins = append(group.Admins, a.fromAddr) if addr != a.fromAddr {
group.Admins = append(group.Admins, addr)
}
} }
group.Members = create.Members group.Members = create.Members
...@@ -77,13 +80,13 @@ func (a *action) createGroup(create *vty.CreateGroup) (*types.Receipt, error) { ...@@ -77,13 +80,13 @@ func (a *action) createGroup(create *vty.CreateGroup) (*types.Receipt, error) {
return receipt, nil return receipt, nil
} }
func (a *action) updateMember(update *vty.UpdateMember) (*types.Receipt, error) { func (a *action) updateGroup(update *vty.UpdateGroup) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk} receipt := &types.Receipt{Ty: types.ExecOk}
group, err := a.getGroupInfo(update.GroupID) group, err := a.getGroupInfo(update.GroupID)
if err != nil { if err != nil {
elog.Error("vote exec updateMember", "txHash", a.txHash, "err", err) elog.Error("vote exec updateGroup", "txHash", a.txHash, "err", err)
return nil, errStateDBGet return nil, errStateDBGet
} }
addrMap := make(map[string]int) addrMap := make(map[string]int)
...@@ -91,20 +94,43 @@ func (a *action) updateMember(update *vty.UpdateMember) (*types.Receipt, error) ...@@ -91,20 +94,43 @@ func (a *action) updateMember(update *vty.UpdateMember) (*types.Receipt, error)
addrMap[member.Addr] = index addrMap[member.Addr] = index
} }
// remove members // remove members
for _, addr := range update.GetRemoveMemberAddrs() { for _, addr := range update.GetRemoveMembers() {
if index, ok := addrMap[addr]; ok { if index, ok := addrMap[addr]; ok {
group.Members = append(group.Members[:index], group.Members[index+1:]...) group.Members = append(group.Members[:index], group.Members[index+1:]...)
delete(addrMap, addr)
} }
} }
// add members // add members
for _, member := range update.GetAddMembers() { for _, member := range update.GetAddMembers() {
group.Members = append(group.Members, member) if _, ok := addrMap[member.Addr]; !ok {
group.Members = append(group.Members, member)
}
}
adminMap := make(map[string]int)
for index, addr := range group.Admins {
adminMap[addr] = index
}
// remove admins
for _, addr := range update.GetRemoveAdmins() {
if index, ok := adminMap[addr]; ok {
group.Admins = append(group.Admins[:index], group.Admins[index+1:]...)
delete(adminMap, addr)
}
}
// add admins
for _, addr := range update.GetAddAdmins() {
if _, ok := adminMap[addr]; !ok {
group.Admins = append(group.Admins, addr)
}
} }
groupValue := types.Encode(group) groupValue := types.Encode(group)
receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(group.ID), Value: groupValue}) receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(group.ID), Value: groupValue})
receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyUpdateMemberLog, Log: groupValue}) receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyUpdateGroupLog, Log: groupValue})
return receipt, nil return receipt, nil
} }
...@@ -114,17 +140,17 @@ func (a *action) createVote(create *vty.CreateVote) (*types.Receipt, error) { ...@@ -114,17 +140,17 @@ func (a *action) createVote(create *vty.CreateVote) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk} receipt := &types.Receipt{Ty: types.ExecOk}
vote := &vty.VoteInfo{} vote := &vty.VoteInfo{}
vote.ID = formatVoteID(hex.EncodeToString(a.txHash)) vote.ID = formatVoteID(dapp.HeightIndexStr(a.height, int64(a.index)))
vote.BeginTimestamp = create.BeginTimestamp vote.BeginTimestamp = create.BeginTimestamp
vote.EndTimestamp = create.EndTimestamp vote.EndTimestamp = create.EndTimestamp
vote.Name = create.Name vote.Name = create.Name
vote.VoteGroups = create.VoteGroups vote.GroupID = create.GroupID
vote.VoteOptions = make([]*vty.VoteOption, 0) vote.VoteOptions = make([]*vty.VoteOption, 0)
for _, option := range create.VoteOptions { for _, option := range create.VoteOptions {
vote.VoteOptions = append(vote.VoteOptions, &vty.VoteOption{Option: option}) vote.VoteOptions = append(vote.VoteOptions, &vty.VoteOption{Option: option})
} }
vote.Creator = a.fromAddr
voteValue := types.Encode(vote) voteValue := types.Encode(vote)
receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(vote.ID), Value: voteValue}) receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(vote.ID), Value: voteValue})
receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyCreateVoteLog, Log: voteValue}) receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyCreateVoteLog, Log: voteValue})
...@@ -136,9 +162,13 @@ func (a *action) commitVote(commit *vty.CommitVote) (*types.Receipt, error) { ...@@ -136,9 +162,13 @@ func (a *action) commitVote(commit *vty.CommitVote) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk} receipt := &types.Receipt{Ty: types.ExecOk}
vote, err := a.getVoteInfo(commit.VoteID) vote, err := a.getVoteInfo(commit.VoteID)
group, err1 := a.getGroupInfo(commit.GroupID) if err != nil {
if err != nil || err1 != nil { elog.Error("vote exec commitVote", "txHash", a.txHash, "get vote err", err)
elog.Error("vote exec commitVote", "txHash", a.txHash, "err", err, "err1", err1) return nil, errStateDBGet
}
group, err := a.getGroupInfo(vote.GroupID)
if err != nil {
elog.Error("vote exec commitVote", "txHash", a.txHash, "get group err", err)
return nil, errStateDBGet return nil, errStateDBGet
} }
...@@ -147,10 +177,34 @@ func (a *action) commitVote(commit *vty.CommitVote) (*types.Receipt, error) { ...@@ -147,10 +177,34 @@ func (a *action) commitVote(commit *vty.CommitVote) (*types.Receipt, error) {
vote.VoteOptions[commit.OptionIndex].Score += member.VoteWeight vote.VoteOptions[commit.OptionIndex].Score += member.VoteWeight
} }
} }
vote.VotedMembers = append(vote.VotedMembers, a.fromAddr) info := &vty.CommitInfo{Addr: a.fromAddr}
vote.CommitInfos = append(vote.CommitInfos, info)
voteValue := types.Encode(vote) voteValue := types.Encode(vote)
info.TxHash = hex.EncodeToString(a.txHash)
receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(vote.ID), Value: voteValue}) receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(vote.ID), Value: voteValue})
receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyCommitVoteLog, Log: voteValue}) receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyCommitVoteLog, Log: types.Encode(info)})
return receipt, nil return receipt, nil
} }
func (a *action) closeVote(close *vty.CloseVote) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk}
vote, err := a.getVoteInfo(close.VoteID)
if err != nil {
elog.Error("vote exec commitVote", "txHash", a.txHash, "get vote err", err)
return nil, errStateDBGet
}
vote.Status = voteStatusClosed
voteValue := types.Encode(vote)
receipt.KV = append(receipt.KV, &types.KeyValue{Key: formatStateIDKey(vote.ID), Value: voteValue})
receipt.Logs = append(receipt.Logs, &types.ReceiptLog{Ty: vty.TyCloseVoteLog, Log: voteValue})
return receipt, nil
}
func (a *action) updateMember(update *vty.UpdateMember) (*types.Receipt, error) {
receipt := &types.Receipt{Ty: types.ExecOk}
return receipt, nil
}
...@@ -20,12 +20,16 @@ func (v *vote) CheckTx(tx *types.Transaction, index int) error { ...@@ -20,12 +20,16 @@ func (v *vote) CheckTx(tx *types.Transaction, index int) error {
} }
if action.Ty == vty.TyCreateGroupAction { if action.Ty == vty.TyCreateGroupAction {
err = v.checkCreateGroup(action.GetCreateGroup()) err = v.checkCreateGroup(action.GetCreateGroup())
} else if action.Ty == vty.TyUpdateMemberAction { } else if action.Ty == vty.TyUpdateGroupAction {
err = v.checkUpdateMember(action.GetUpdateMember()) err = v.checkUpdateGroup(action.GetUpdateGroup(), tx, index)
} else if action.Ty == vty.TyCreateVoteAction { } else if action.Ty == vty.TyCreateVoteAction {
err = v.checkCreateVote(action.GetCreateVote()) err = v.checkCreateVote(action.GetCreateVote(), tx, index)
} else if action.Ty == vty.TyCommitVoteAction { } else if action.Ty == vty.TyCommitVoteAction {
err = v.checkCommitVote(action.GetCommitVote(), tx, index) err = v.checkCommitVote(action.GetCommitVote(), tx, index)
} else if action.Ty == vty.TyCloseVoteAction {
err = v.checkCloseVote(action.GetCloseVote(), tx, index)
} else if action.Ty == vty.TyUpdateMemberAction {
err = v.checkUpdateMember(action.GetUpdateMember())
} else { } else {
err = types.ErrActionNotSupport err = types.ErrActionNotSupport
} }
...@@ -68,19 +72,35 @@ func (v *vote) checkCreateGroup(create *vty.CreateGroup) error { ...@@ -68,19 +72,35 @@ func (v *vote) checkCreateGroup(create *vty.CreateGroup) error {
return nil return nil
} }
func (v *vote) checkUpdateMember(update *vty.UpdateMember) error { func (v *vote) checkUpdateGroup(update *vty.UpdateGroup, tx *types.Transaction, index int) error {
action := newAction(v, tx, index)
groupInfo, err := action.getGroupInfo(update.GetGroupID())
if err != nil {
return err
}
if !checkSliceItemExist(action.fromAddr, groupInfo.GetAdmins()) {
return errAddrPermissionDenied
}
if len(update.GetGroupID()) != IDLen { //防止将管理员全部删除
return errInvalidGroupID if len(update.RemoveAdmins) >= len(update.AddAdmins)+len(groupInfo.GetAdmins()) {
return errAddrPermissionDenied
} }
addrs := make([]string, 0, len(update.RemoveMembers)+len(update.AddAdmins)+len(update.RemoveAdmins))
addrs = append(addrs, update.RemoveMembers...)
addrs = append(addrs, update.AddAdmins...)
addrs = append(addrs, update.RemoveAdmins...)
for _, member := range update.AddMembers { for _, member := range update.AddMembers {
if len(member.Addr) != addrLen { if len(member.Addr) != addrLen {
return types.ErrInvalidAddress return types.ErrInvalidAddress
} }
} }
for _, addr := range update.RemoveMemberAddrs { for _, addr := range addrs {
if len(addr) != addrLen { if len(addr) != addrLen {
elog.Error("checkUpdateGroup", "invalid addr", addr)
return types.ErrInvalidAddress return types.ErrInvalidAddress
} }
} }
...@@ -88,12 +108,21 @@ func (v *vote) checkUpdateMember(update *vty.UpdateMember) error { ...@@ -88,12 +108,21 @@ func (v *vote) checkUpdateMember(update *vty.UpdateMember) error {
return nil return nil
} }
func (v *vote) checkCreateVote(create *vty.CreateVote) error { func (v *vote) checkCreateVote(create *vty.CreateVote, tx *types.Transaction, index int) error {
if create.GetName() == "" { if create.GetName() == "" {
return errEmptyName return errEmptyName
} }
action := newAction(v, tx, index)
groupInfo, err := action.getGroupInfo(create.GetGroupID())
if err != nil {
return err
}
if !checkSliceItemExist(action.fromAddr, groupInfo.GetAdmins()) {
return errAddrPermissionDenied
}
if create.GetEndTimestamp() <= v.GetBlockTime() || create.EndTimestamp <= create.BeginTimestamp { if create.GetEndTimestamp() <= v.GetBlockTime() || create.EndTimestamp <= create.BeginTimestamp {
return errInvalidVoteTime return errInvalidVoteTime
} }
...@@ -102,29 +131,13 @@ func (v *vote) checkCreateVote(create *vty.CreateVote) error { ...@@ -102,29 +131,13 @@ func (v *vote) checkCreateVote(create *vty.CreateVote) error {
return errInvalidVoteOption return errInvalidVoteOption
} }
if len(create.VoteGroups) == 0 {
return errEmptyVoteGroup
}
if checkSliceItemDuplicate(create.VoteGroups) {
return errDuplicateGroup
}
return nil return nil
} }
func (v *vote) checkCommitVote(commit *vty.CommitVote, tx *types.Transaction, index int) error { func (v *vote) checkCommitVote(commit *vty.CommitVote, tx *types.Transaction, index int) error {
voteID := commit.GetVoteID()
groupID := commit.GetGroupID()
if len(voteID) != IDLen {
return errInvalidVoteID
}
if len(groupID) != IDLen {
return errInvalidGroupID
}
action := newAction(v, tx, index) action := newAction(v, tx, index)
voteInfo, err := action.getVoteInfo(voteID) voteInfo, err := action.getVoteInfo(commit.GetVoteID())
if err != nil { if err != nil {
return err return err
} }
...@@ -133,29 +146,52 @@ func (v *vote) checkCommitVote(commit *vty.CommitVote, tx *types.Transaction, in ...@@ -133,29 +146,52 @@ func (v *vote) checkCommitVote(commit *vty.CommitVote, tx *types.Transaction, in
return errVoteAlreadyFinished return errVoteAlreadyFinished
} }
if voteInfo.Status == voteStatusClosed {
return errVoteAlreadyClosed
}
if commit.OptionIndex >= uint32(len(voteInfo.VoteOptions)) { if commit.OptionIndex >= uint32(len(voteInfo.VoteOptions)) {
return errInvalidOptionIndex return errInvalidOptionIndex
} }
//check group validity groupInfo, err := action.getGroupInfo(voteInfo.GroupID)
if !checkSliceItemExist(commit.GroupID, voteInfo.VoteGroups) { if err != nil {
return errInvalidGroupID return err
} }
// check if exist in group members
if !checkMemberExist(action.fromAddr, groupInfo.Members) {
return errAddrPermissionDenied
}
// check if already vote // check if already vote
if checkSliceItemExist(action.fromAddr, voteInfo.VotedMembers) { for _, info := range voteInfo.GetCommitInfos() {
return errAlreadyVoted if action.fromAddr == info.Addr {
return errAlreadyVoted
}
} }
groupInfo, err := action.getGroupInfo(commit.GroupID) return nil
}
func (v *vote) checkCloseVote(close *vty.CloseVote, tx *types.Transaction, index int) error {
action := newAction(v, tx, index)
voteInfo, err := action.getVoteInfo(close.GetVoteID())
if err != nil { if err != nil {
return err return err
} }
if voteInfo.Creator != action.fromAddr {
// check if exist in group members return errAddrPermissionDenied
if !checkMemberExist(action.fromAddr, groupInfo.Members) { }
return errInvalidGroupMember if voteInfo.Status == voteStatusClosed {
return errVoteAlreadyClosed
} }
return nil
}
func (v *vote) checkUpdateMember(update *vty.UpdateMember) error {
if update.GetName() == "" {
return errEmptyName
}
return nil return nil
} }
...@@ -21,4 +21,6 @@ var ( ...@@ -21,4 +21,6 @@ var (
errAlreadyVoted = errors.New("errAlreadyVoted") errAlreadyVoted = errors.New("errAlreadyVoted")
errInvalidGroupMember = errors.New("errInvalidGroupMember") errInvalidGroupMember = errors.New("errInvalidGroupMember")
errVoteAlreadyFinished = errors.New("errVoteAlreadyFinished") errVoteAlreadyFinished = errors.New("errVoteAlreadyFinished")
errVoteAlreadyClosed = errors.New("errVoteAlreadyClosed")
errAddrPermissionDenied = errors.New("errAddrPermissionDenied")
) )
...@@ -15,9 +15,9 @@ func (v *vote) Exec_CreateGroup(payload *votetypes.CreateGroup, tx *types.Transa ...@@ -15,9 +15,9 @@ func (v *vote) Exec_CreateGroup(payload *votetypes.CreateGroup, tx *types.Transa
return action.createGroup(payload) return action.createGroup(payload)
} }
func (v *vote) Exec_UpdateMember(payload *votetypes.UpdateMember, tx *types.Transaction, index int) (*types.Receipt, error) { func (v *vote) Exec_UpdateGroup(payload *votetypes.UpdateGroup, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(v, tx, index) action := newAction(v, tx, index)
return action.updateMember(payload) return action.updateGroup(payload)
} }
func (v *vote) Exec_CreateVote(payload *votetypes.CreateVote, tx *types.Transaction, index int) (*types.Receipt, error) { func (v *vote) Exec_CreateVote(payload *votetypes.CreateVote, tx *types.Transaction, index int) (*types.Receipt, error) {
...@@ -29,3 +29,13 @@ func (v *vote) Exec_CommitVote(payload *votetypes.CommitVote, tx *types.Transact ...@@ -29,3 +29,13 @@ func (v *vote) Exec_CommitVote(payload *votetypes.CommitVote, tx *types.Transact
action := newAction(v, tx, index) action := newAction(v, tx, index)
return action.commitVote(payload) return action.commitVote(payload)
} }
func (v *vote) Exec_CloseVote(payload *votetypes.CloseVote, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(v, tx, index)
return action.closeVote(payload)
}
func (v *vote) Exec_UpdateMember(payload *votetypes.UpdateMember, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newAction(v, tx, index)
return action.updateMember(payload)
}
...@@ -17,7 +17,7 @@ func (v *vote) ExecLocal_CreateGroup(payload *vty.CreateGroup, tx *types.Transac ...@@ -17,7 +17,7 @@ func (v *vote) ExecLocal_CreateGroup(payload *vty.CreateGroup, tx *types.Transac
groupInfo := decodeGroupInfo(receiptData.Logs[0].Log) groupInfo := decodeGroupInfo(receiptData.Logs[0].Log)
table := newGroupTable(v.GetLocalDB()) table := newGroupTable(v.GetLocalDB())
err := table.Add(&vty.GroupVoteInfo{GroupInfo: groupInfo}) err := table.Add(groupInfo)
if err != nil { if err != nil {
elog.Error("execLocal createGroup", "txHash", hex.EncodeToString(tx.Hash()), "table add", err) elog.Error("execLocal createGroup", "txHash", hex.EncodeToString(tx.Hash()), "table add", err)
return nil, err return nil, err
...@@ -40,31 +40,31 @@ func (v *vote) ExecLocal_CreateGroup(payload *vty.CreateGroup, tx *types.Transac ...@@ -40,31 +40,31 @@ func (v *vote) ExecLocal_CreateGroup(payload *vty.CreateGroup, tx *types.Transac
return v.addAutoRollBack(tx, dbSet.KV), nil return v.addAutoRollBack(tx, dbSet.KV), nil
} }
func (v *vote) ExecLocal_UpdateMember(update *vty.UpdateMember, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (v *vote) ExecLocal_UpdateGroup(update *vty.UpdateGroup, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
groupInfo := decodeGroupInfo(receiptData.Logs[0].Log) groupInfo := decodeGroupInfo(receiptData.Logs[0].Log)
table := newGroupTable(v.GetLocalDB()) table := newGroupTable(v.GetLocalDB())
err := table.Replace(&vty.GroupVoteInfo{GroupInfo: groupInfo}) err := table.Replace(groupInfo)
if err != nil { if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "groupID", groupInfo.ID, "table replace", err) elog.Error("execLocal UpdateGroup", "txHash", hex.EncodeToString(tx.Hash()), "groupID", groupInfo.ID, "table replace", err)
return nil, err return nil, err
} }
kvs, err := table.Save() kvs, err := table.Save()
if err != nil { if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "groupID", groupInfo.ID, "table save", err) elog.Error("execLocal UpdateGroup", "txHash", hex.EncodeToString(tx.Hash()), "groupID", groupInfo.ID, "table save", err)
return nil, err return nil, err
} }
dbSet.KV = kvs dbSet.KV = kvs
kvs, err = v.addGroupMember(groupInfo.GetID(), update.AddMembers) kvs, err = v.addGroupMember(groupInfo.GetID(), update.AddMembers)
if err != nil { if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "addMemberErr", err) elog.Error("execLocal UpdateGroup", "txHash", hex.EncodeToString(tx.Hash()), "addMemberErr", err)
return nil, err return nil, err
} }
dbSet.KV = append(dbSet.KV, kvs...) dbSet.KV = append(dbSet.KV, kvs...)
kvs, err = v.removeGroupMember(groupInfo.GetID(), update.RemoveMemberAddrs) kvs, err = v.removeGroupMember(groupInfo.GetID(), update.RemoveMembers)
if err != nil { if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "removeMemberErr", err) elog.Error("execLocal UpdateGroup", "txHash", hex.EncodeToString(tx.Hash()), "removeMemberErr", err)
return nil, err return nil, err
} }
dbSet.KV = append(dbSet.KV, kvs...) dbSet.KV = append(dbSet.KV, kvs...)
...@@ -87,47 +87,97 @@ func (v *vote) ExecLocal_CreateVote(payload *vty.CreateVote, tx *types.Transacti ...@@ -87,47 +87,97 @@ func (v *vote) ExecLocal_CreateVote(payload *vty.CreateVote, tx *types.Transacti
return nil, err return nil, err
} }
dbSet.KV = kvs dbSet.KV = kvs
//auto gen for localdb auto rollback
return v.addAutoRollBack(tx, dbSet.KV), nil
}
// 在关联的投票组表中记录voteID信息 func (v *vote) ExecLocal_CommitVote(payload *vty.CommitVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
table = newGroupTable(v.GetLocalDB()) dbSet := &types.LocalDBSet{}
for _, groupID := range voteInfo.VoteGroups { //implement code, add customize kv to dbSet...
row, err := table.GetData([]byte(groupID)) commitInfo := decodeCommitInfo(receiptData.Logs[0].Log)
if err != nil { table := newVoteTable(v.GetLocalDB())
continue row, err := table.GetData([]byte(formatVoteID(payload.GetVoteID())))
} if err != nil {
if info, ok := row.Data.(*vty.GroupVoteInfo); ok { elog.Error("execLocal commitVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable get", err)
info.VoteIDs = append(info.VoteIDs, voteInfo.ID) return nil, err
err = table.Replace(info)
if err != nil {
elog.Error("execLocal createVote", "txHash", hex.EncodeToString(tx.Hash()),
"groupID", groupID, "groupTable replace", err)
return nil, err
}
}
} }
kvs, err = table.Save() voteInfo, ok := row.Data.(*vty.VoteInfo)
if !ok {
elog.Error("execLocal commitVote", "txHash", hex.EncodeToString(tx.Hash()), "voteInfo type asset", err)
return nil, types.ErrTypeAsset
}
voteInfo.CommitInfos = append(voteInfo.CommitInfos, commitInfo)
err = table.Replace(voteInfo)
if err != nil { if err != nil {
elog.Error("execLocal createVote", "txHash", hex.EncodeToString(tx.Hash()), "groupTable save", err) elog.Error("execLocal commitVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable replace", err)
return nil, err return nil, err
} }
dbSet.KV = append(dbSet.KV, kvs...) kvs, err := table.Save()
if err != nil {
elog.Error("execLocal commitVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable save", err)
return nil, err
}
dbSet.KV = kvs
//auto gen for localdb auto rollback //auto gen for localdb auto rollback
return v.addAutoRollBack(tx, dbSet.KV), nil return v.addAutoRollBack(tx, dbSet.KV), nil
} }
func (v *vote) ExecLocal_CommitVote(payload *vty.CommitVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (v *vote) ExecLocal_CloseVote(payload *vty.CloseVote, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
//implement code, add customize kv to dbSet...
voteInfo := decodeVoteInfo(receiptData.Logs[0].Log)
table := newVoteTable(v.GetLocalDB()) table := newVoteTable(v.GetLocalDB())
err := table.Replace(voteInfo) row, err := table.GetData([]byte(formatVoteID(payload.GetVoteID())))
if err != nil { if err != nil {
elog.Error("execLocal commitVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable add", err) elog.Error("execLocal closeVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable get", err)
return nil, err
}
voteInfo, ok := row.Data.(*vty.VoteInfo)
if !ok {
elog.Error("execLocal closeVote", "txHash", hex.EncodeToString(tx.Hash()), "voteInfo type asset", err)
return nil, types.ErrTypeAsset
}
voteInfo.Status = voteStatusClosed
err = table.Replace(voteInfo)
if err != nil {
elog.Error("execLocal closeVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable replace", err)
return nil, err return nil, err
} }
kvs, err := table.Save() kvs, err := table.Save()
if err != nil { if err != nil {
elog.Error("execLocal commitVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable save", err) elog.Error("execLocal closeVote", "txHash", hex.EncodeToString(tx.Hash()), "voteTable save", err)
return nil, err
}
dbSet.KV = kvs
//auto gen for localdb auto rollback
return v.addAutoRollBack(tx, dbSet.KV), nil
}
func (v *vote) ExecLocal_UpdateMember(payload *vty.UpdateMember, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
table := newMemberTable(v.GetLocalDB())
row, err := table.GetData([]byte(tx.From()))
if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "memberTable get", err)
return nil, err
}
memberInfo, ok := row.Data.(*vty.MemberInfo)
if !ok {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "memberInfo type asset", err)
return nil, types.ErrTypeAsset
}
memberInfo.Name = payload.GetName()
err = table.Replace(memberInfo)
if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "memberTable replace", err)
return nil, err
}
kvs, err := table.Save()
if err != nil {
elog.Error("execLocal updateMember", "txHash", hex.EncodeToString(tx.Hash()), "memberTable save", err)
return nil, err return nil, err
} }
dbSet.KV = kvs dbSet.KV = kvs
......
...@@ -5,36 +5,48 @@ import ( ...@@ -5,36 +5,48 @@ import (
vty "github.com/33cn/plugin/plugin/dapp/vote/types" vty "github.com/33cn/plugin/plugin/dapp/vote/types"
) )
// Query_GroupInfo query group info func (v *vote) getGroup(groupID string) (*vty.GroupInfo, error) {
func (v *vote) Query_GetGroup(in *types.ReqString) (types.Message, error) {
if len(in.GetData()) != IDLen { if len(groupID) != IDLen {
return nil, errInvalidGroupID return nil, errInvalidGroupID
} }
groupID := in.Data
table := newGroupTable(v.GetLocalDB()) table := newGroupTable(v.GetLocalDB())
row, err := table.GetData([]byte(groupID)) row, err := table.GetData([]byte(groupID))
if err != nil { if err != nil {
elog.Error("query getGroup", "id", groupID, "err", err) elog.Error("query getGroup", "groupID", groupID, "err", err)
return nil, err return nil, err
} }
info, ok := row.Data.(*vty.GroupVoteInfo) info, ok := row.Data.(*vty.GroupInfo)
if !ok { if !ok {
return nil, types.ErrTypeAsset return nil, types.ErrTypeAsset
} }
return info, nil return info, nil
} }
func (v *vote) Query_GetVote(in *types.ReqString) (types.Message, error) { // Query_GroupInfo query group info
func (v *vote) Query_GetGroups(in *vty.ReqStrings) (types.Message, error) {
if len(in.GetData()) != IDLen { if in == nil {
return nil, types.ErrInvalidParam
}
infos := &vty.GroupInfos{GroupList: make([]*vty.GroupInfo, 0, len(in.GetItems()))}
for _, id := range in.GetItems() {
info, err := v.getGroup(id)
if err != nil {
return nil, err
}
infos.GroupList = append(infos.GroupList, info)
}
return infos, nil
}
func (v *vote) getVote(voteID string) (*vty.VoteInfo, error) {
if len(voteID) != IDLen {
return nil, errInvalidVoteID return nil, errInvalidVoteID
} }
voteID := in.Data
table := newVoteTable(v.GetLocalDB()) table := newVoteTable(v.GetLocalDB())
row, err := table.GetData([]byte(voteID)) row, err := table.GetData([]byte(voteID))
...@@ -49,15 +61,30 @@ func (v *vote) Query_GetVote(in *types.ReqString) (types.Message, error) { ...@@ -49,15 +61,30 @@ func (v *vote) Query_GetVote(in *types.ReqString) (types.Message, error) {
} }
return info, nil return info, nil
}
func (v *vote) Query_GetVotes(in *vty.ReqStrings) (types.Message, error) {
if in == nil {
return nil, types.ErrInvalidParam
}
infos := &vty.VoteInfos{VoteList: make([]*vty.VoteInfo, 0, len(in.GetItems()))}
for _, id := range in.GetItems() {
info, err := v.getVote(id)
if err != nil {
return nil, err
}
infos.VoteList = append(infos.VoteList, info)
}
return classifyVoteList(infos), nil
} }
func (v *vote) Query_GetMember(in *types.ReqString) (types.Message, error) { func (v *vote) getMember(addr string) (*vty.MemberInfo, error) {
if len(in.GetData()) != addrLen { if len(addr) != addrLen {
return nil, types.ErrInvalidAddress return nil, types.ErrInvalidAddress
} }
addr := in.Data
table := newMemberTable(v.GetLocalDB()) table := newMemberTable(v.GetLocalDB())
row, err := table.GetData([]byte(addr)) row, err := table.GetData([]byte(addr))
...@@ -73,6 +100,22 @@ func (v *vote) Query_GetMember(in *types.ReqString) (types.Message, error) { ...@@ -73,6 +100,22 @@ func (v *vote) Query_GetMember(in *types.ReqString) (types.Message, error) {
return info, nil return info, nil
} }
func (v *vote) Query_GetMembers(in *vty.ReqStrings) (types.Message, error) {
if in == nil {
return nil, types.ErrInvalidParam
}
infos := &vty.MemberInfos{MemberList: make([]*vty.MemberInfo, 0, len(in.GetItems()))}
for _, id := range in.GetItems() {
info, err := v.getMember(id)
if err != nil {
return nil, err
}
infos.MemberList = append(infos.MemberList, info)
}
return infos, nil
}
func (v *vote) Query_ListGroup(in *vty.ReqListItem) (types.Message, error) { func (v *vote) Query_ListGroup(in *vty.ReqListItem) (types.Message, error) {
if in == nil { if in == nil {
...@@ -87,9 +130,9 @@ func (v *vote) Query_ListGroup(in *vty.ReqListItem) (types.Message, error) { ...@@ -87,9 +130,9 @@ func (v *vote) Query_ListGroup(in *vty.ReqListItem) (types.Message, error) {
return nil, err return nil, err
} }
list := &vty.GroupVoteInfos{GroupList: make([]*vty.GroupVoteInfo, 0)} list := &vty.GroupInfos{GroupList: make([]*vty.GroupInfo, 0, len(rows))}
for _, row := range rows { for _, row := range rows {
info, ok := row.Data.(*vty.GroupVoteInfo) info, ok := row.Data.(*vty.GroupInfo)
if !ok { if !ok {
return nil, types.ErrTypeAsset return nil, types.ErrTypeAsset
} }
...@@ -99,21 +142,28 @@ func (v *vote) Query_ListGroup(in *vty.ReqListItem) (types.Message, error) { ...@@ -99,21 +142,28 @@ func (v *vote) Query_ListGroup(in *vty.ReqListItem) (types.Message, error) {
return list, nil return list, nil
} }
func (v *vote) Query_ListVote(in *vty.ReqListItem) (types.Message, error) { func (v *vote) Query_ListVote(in *vty.ReqListVote) (types.Message, error) {
if in == nil { if in.GetListReq() == nil {
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
table := newVoteTable(v.GetLocalDB()) table := newVoteTable(v.GetLocalDB())
var primaryKey []byte //指定了组ID,则查询对应组下的投票列表
primaryKey = append(primaryKey, []byte(in.StartItemID)...) groupID := in.GetGroupID()
rows, err := table.ListIndex(voteTablePrimary, nil, primaryKey, in.Count, in.Direction) indexName := voteTablePrimary
var prefix, primaryKey []byte
if len(groupID) > 0 {
indexName = groupTablePrimary
prefix = []byte(groupID)
}
primaryKey = append(primaryKey, []byte(in.GetListReq().GetStartItemID())...)
rows, err := table.ListIndex(indexName, prefix, primaryKey, in.GetListReq().Count, in.GetListReq().Direction)
if err != nil { if err != nil {
elog.Error("query listVote", "err", err, "param", in) elog.Error("query listVote", "err", err, "param", in)
return nil, err return nil, err
} }
list := &vty.VoteInfos{VoteList: make([]*vty.VoteInfo, 0)} list := &vty.VoteInfos{VoteList: make([]*vty.VoteInfo, 0, len(rows))}
for _, row := range rows { for _, row := range rows {
info, ok := row.Data.(*vty.VoteInfo) info, ok := row.Data.(*vty.VoteInfo)
if !ok { if !ok {
...@@ -122,7 +172,7 @@ func (v *vote) Query_ListVote(in *vty.ReqListItem) (types.Message, error) { ...@@ -122,7 +172,7 @@ func (v *vote) Query_ListVote(in *vty.ReqListItem) (types.Message, error) {
list.VoteList = append(list.VoteList, info) list.VoteList = append(list.VoteList, info)
} }
return list, nil return classifyVoteList(list), nil
} }
func (v *vote) Query_ListMember(in *vty.ReqListItem) (types.Message, error) { func (v *vote) Query_ListMember(in *vty.ReqListItem) (types.Message, error) {
...@@ -139,7 +189,7 @@ func (v *vote) Query_ListMember(in *vty.ReqListItem) (types.Message, error) { ...@@ -139,7 +189,7 @@ func (v *vote) Query_ListMember(in *vty.ReqListItem) (types.Message, error) {
return nil, err return nil, err
} }
list := &vty.MemberInfos{MemberList: make([]*vty.MemberInfo, 0)} list := &vty.MemberInfos{MemberList: make([]*vty.MemberInfo, 0, len(rows))}
for _, row := range rows { for _, row := range rows {
info, ok := row.Data.(*vty.MemberInfo) info, ok := row.Data.(*vty.MemberInfo)
if !ok { if !ok {
......
...@@ -22,6 +22,7 @@ var voteTableOpt = &table.Option{ ...@@ -22,6 +22,7 @@ var voteTableOpt = &table.Option{
Prefix: keyPrefixLocalDB, Prefix: keyPrefixLocalDB,
Name: "vote", Name: "vote",
Primary: voteTablePrimary, Primary: voteTablePrimary,
Index: []string{groupTablePrimary},
} }
var memberTableOpt = &table.Option{ var memberTableOpt = &table.Option{
...@@ -53,18 +54,18 @@ func newMemberTable(kvDB db.KV) *table.Table { ...@@ -53,18 +54,18 @@ func newMemberTable(kvDB db.KV) *table.Table {
//groupTableRow table meta 结构 //groupTableRow table meta 结构
type groupTableRow struct { type groupTableRow struct {
*vty.GroupVoteInfo *vty.GroupInfo
} }
//CreateRow 新建数据行 //CreateRow 新建数据行
func (r *groupTableRow) CreateRow() *table.Row { func (r *groupTableRow) CreateRow() *table.Row {
return &table.Row{Data: &vty.GroupVoteInfo{}} return &table.Row{Data: &vty.GroupInfo{}}
} }
//SetPayload 设置数据 //SetPayload 设置数据
func (r *groupTableRow) SetPayload(data types.Message) error { func (r *groupTableRow) SetPayload(data types.Message) error {
if d, ok := data.(*vty.GroupVoteInfo); ok { if d, ok := data.(*vty.GroupInfo); ok {
r.GroupVoteInfo = d r.GroupInfo = d
return nil return nil
} }
return types.ErrTypeAsset return types.ErrTypeAsset
...@@ -73,7 +74,7 @@ func (r *groupTableRow) SetPayload(data types.Message) error { ...@@ -73,7 +74,7 @@ func (r *groupTableRow) SetPayload(data types.Message) error {
//Get 按照indexName 查询 indexValue //Get 按照indexName 查询 indexValue
func (r *groupTableRow) Get(key string) ([]byte, error) { func (r *groupTableRow) Get(key string) ([]byte, error) {
if key == groupTablePrimary { if key == groupTablePrimary {
return []byte(r.GroupVoteInfo.GetGroupInfo().GetID()), nil return []byte(r.GroupInfo.GetID()), nil
} }
return nil, types.ErrNotFound return nil, types.ErrNotFound
} }
...@@ -101,6 +102,8 @@ func (r *voteTableRow) SetPayload(data types.Message) error { ...@@ -101,6 +102,8 @@ func (r *voteTableRow) SetPayload(data types.Message) error {
func (r *voteTableRow) Get(key string) ([]byte, error) { func (r *voteTableRow) Get(key string) ([]byte, error) {
if key == voteTablePrimary { if key == voteTablePrimary {
return []byte(r.VoteInfo.GetID()), nil return []byte(r.VoteInfo.GetID()), nil
} else if key == groupTablePrimary {
return []byte(r.VoteInfo.GetGroupID()), nil
} }
return nil, types.ErrNotFound return nil, types.ErrNotFound
} }
......
...@@ -7,17 +7,22 @@ import ( ...@@ -7,17 +7,22 @@ import (
) )
const ( const (
voteStatusNormal = iota
voteStatusClosed
)
const (
// IDLen length of groupID or voteID // IDLen length of groupID or voteID
IDLen = 65 IDLen = 19
addrLen = 34 addrLen = 34
) )
func formatGroupID(txHash string) string { func formatGroupID(id string) string {
return "g" + txHash return "g" + id
} }
func formatVoteID(txHash string) string { func formatVoteID(id string) string {
return "v" + txHash return "v" + id
} }
func checkMemberExist(addr string, members []*vty.GroupMember) bool { func checkMemberExist(addr string, members []*vty.GroupMember) bool {
...@@ -76,3 +81,27 @@ func decodeVoteInfo(data []byte) *vty.VoteInfo { ...@@ -76,3 +81,27 @@ func decodeVoteInfo(data []byte) *vty.VoteInfo {
mustDecodeProto(data, info) mustDecodeProto(data, info)
return info return info
} }
func decodeCommitInfo(data []byte) *vty.CommitInfo {
info := &vty.CommitInfo{}
mustDecodeProto(data, info)
return info
}
func classifyVoteList(infos *vty.VoteInfos) *vty.ReplyVoteList {
reply := &vty.ReplyVoteList{}
for _, voteInfo := range infos.GetVoteList() {
if voteInfo.Status == voteStatusClosed {
reply.ClosedList = append(reply.ClosedList, voteInfo)
} else if voteInfo.BeginTimestamp > types.Now().Unix() {
reply.PendingList = append(reply.PendingList, voteInfo)
} else if voteInfo.EndTimestamp > types.Now().Unix() {
reply.OngoingList = append(reply.OngoingList, voteInfo)
} else {
reply.FinishedList = append(reply.FinishedList, voteInfo)
}
}
return reply
}
...@@ -7,9 +7,11 @@ message VoteAction { ...@@ -7,9 +7,11 @@ message VoteAction {
int32 ty = 1; int32 ty = 1;
oneof value { oneof value {
CreateGroup createGroup = 2; //创建投票组 CreateGroup createGroup = 2; //创建投票组
UpdateMember updateMember = 3; //更新组成员 UpdateGroup updateGroup = 3; //更新组成员
CreateVote createVote = 4; //创建一个投票 CreateVote createVote = 4; //创建一个投票
CommitVote commitVote = 5; //组员提交投票 CommitVote commitVote = 5; //组员提交投票
CloseVote closeVote = 6;
UpdateMember updateMember = 7;
} }
} }
...@@ -20,27 +22,35 @@ message GroupMember { ...@@ -20,27 +22,35 @@ message GroupMember {
//创建投票组 //创建投票组
message CreateGroup { message CreateGroup {
string name = 1; //投票组名称 string name = 1; //投票组名称
repeated string admins = 2; //管理员地址列表 repeated string admins = 2; //管理员地址列表
repeated GroupMember members = 3; //组员 repeated GroupMember members = 3; //组员
string description = 4;
} }
//更新投票组 //更新投票组
message UpdateMember { message UpdateGroup {
string groupID = 1; //投票组ID string groupID = 1; //投票组ID
repeated GroupMember addMembers = 2; //需要增加的组成员 repeated GroupMember addMembers = 2; //需要增加的组成员
repeated string removeMemberAddrs = 3; //删除组成员的地址列表 repeated string removeMembers = 3; //删除组成员的地址列表
repeated string addAdmins = 4;
repeated string removeAdmins = 5;
} }
// 投票组信息 // 投票组信息
message GroupInfo { message GroupInfo {
string ID = 1; //投票组ID string ID = 1; //投票组ID
string name = 2; //投票组名称 string name = 2; //投票组名称
uint32 memberNum = 3; //组员数量 uint32 memberNum = 3; //组员数量
string creator = 4; //创建者 string creator = 4; //创建者
repeated string admins = 5; //管理员列表 repeated string admins = 5; //管理员列表
repeated GroupMember members = 6; //成员列表 repeated GroupMember members = 6; //成员列表
string description = 7;
}
message GroupInfos {
repeated GroupInfo groupList = 1; //投票组信息列表
} }
//投票选项 //投票选项
...@@ -52,17 +62,30 @@ message VoteOption { ...@@ -52,17 +62,30 @@ message VoteOption {
// 创建投票交易,请求结构 // 创建投票交易,请求结构
message CreateVote { message CreateVote {
string name = 1; //投票名称 string name = 1; //投票名称
repeated string voteGroups = 2; //投票关联组列表 string groupID = 2; //投票关联组列表
repeated string voteOptions = 3; //投票选项列表 repeated string voteOptions = 3; //投票选项列表
int64 beginTimestamp = 4; //投票开始时间戳 int64 beginTimestamp = 4; //投票开始时间戳
int64 endTimestamp = 5; //投票结束时间戳 int64 endTimestamp = 5; //投票结束时间戳
string description = 6;
} }
// 创建提交投票交易,请求结构 // 创建提交投票交易,请求结构
message CommitVote { message CommitVote {
string voteID = 1; //投票ID string voteID = 1; //投票ID
string groupID = 2; //所属投票组ID uint32 optionIndex = 2; //投票选项数组下标,下标对应投票内容
uint32 optionIndex = 3; //投票选项数组下标,下标对应投票内容 }
message CommitInfo {
string addr = 1;
string txHash = 2;
}
message CloseVote {
string voteID = 1;
}
message UpdateMember {
string name = 1;
} }
//投票信息 //投票信息
...@@ -70,40 +93,50 @@ message VoteInfo { ...@@ -70,40 +93,50 @@ message VoteInfo {
string ID = 1; //投票ID string ID = 1; //投票ID
string name = 2; //投票名称 string name = 2; //投票名称
string creator = 3; //投票创建者 string creator = 3; //创建者
repeated string voteGroups = 4; //投票关联的投票组 string groupID = 4; //投票关联的投票组
repeated VoteOption voteOptions = 5; //投票的选项 repeated VoteOption voteOptions = 5; //投票的选项
int64 beginTimestamp = 6; //投票开始时间戳 int64 beginTimestamp = 6; //投票开始时间戳
int64 endTimestamp = 7; //投票结束时间戳 int64 endTimestamp = 7; //投票结束时间戳
repeated string votedMembers = 8; //已投票的成员 repeated CommitInfo commitInfos = 8; //已投票的提交信息
string description = 9;
uint32 status = 10;
} }
message VoteInfos { message VoteInfos {
repeated VoteInfo voteList = 1; //投票信息列表 repeated VoteInfo voteList = 1; //投票信息列表
} }
message GroupVoteInfo {
GroupInfo groupInfo = 1; // 投票组信息
repeated string voteIDs = 2; //投票组关联的投票ID信息
}
message GroupVoteInfos {
repeated GroupVoteInfo groupList = 1; //投票组信息列表
}
message MemberInfo { message MemberInfo {
string addr = 1; //地址 string addr = 1; //地址
repeated string groupIDs = 2; //所属投票组的ID列表 string name = 2;
repeated string groupIDs = 3; //所属投票组的ID列表
} }
message MemberInfos { message MemberInfos {
repeated MemberInfo memberList = 1; //投票组成员信息列表 repeated MemberInfo memberList = 1; //投票组成员信息列表
} }
message ReqStrings {
repeated string items = 1;
}
//列表请求结构 //列表请求结构
message ReqListItem { message ReqListItem {
string startItemID = 1; //列表开始的ID,如请求组列表即groupID,不包含在结果中 string startItemID = 1; //列表开始的ID,如请求组列表即groupID,不包含在结果中
int32 count = 2; //请求列表项数量 int32 count = 2; //请求列表项数量
int32 direction = 3; // 0表示根据ID降序,1表示升序 int32 direction = 3; // 0表示根据ID降序,1表示升序
} }
message ReqListVote {
string groupID = 1;
ReqListItem listReq = 2;
}
message ReplyVoteList {
repeated VoteInfo pendingList = 1;
repeated VoteInfo ongoingList = 2;
repeated VoteInfo finishedList = 3;
repeated VoteInfo closedList = 4;
}
...@@ -17,28 +17,36 @@ import ( ...@@ -17,28 +17,36 @@ import (
const ( const (
TyUnknowAction = iota + 100 TyUnknowAction = iota + 100
TyCreateGroupAction TyCreateGroupAction
TyUpdateMemberAction TyUpdateGroupAction
TyCreateVoteAction TyCreateVoteAction
TyCommitVoteAction TyCommitVoteAction
TyCloseVoteAction
TyUpdateMemberAction
NameCreateGroupAction = "CreateGroup" NameCreateGroupAction = "CreateGroup"
NameUpdateMemberAction = "UpdateMember" NameUpdateGroupAction = "UpdateGroup"
NameCreateVoteAction = "CreateVote" NameCreateVoteAction = "CreateVote"
NameCommitVoteAction = "CommitVote" NameCommitVoteAction = "CommitVote"
NameCloseVoteAction = "CloseVote"
NameUpdateMemberAction = "UpdateMember"
) )
// log类型id值 // log类型id值
const ( const (
TyUnknownLog = iota + 100 TyUnknownLog = iota + 100
TyCreateGroupLog TyCreateGroupLog
TyUpdateMemberLog TyUpdateGroupLog
TyCreateVoteLog TyCreateVoteLog
TyCommitVoteLog TyCommitVoteLog
TyCloseVoteLog
TyUpdateMemberLog
NameCreateGroupLog = "CreateGroupLog" NameCreateGroupLog = "CreateGroupLog"
NameUpdateMemberLog = "UpdateMemberLog" NameUpdateGroupLog = "UpdateGroupLog"
NameCreateVoteLog = "CreateVoteLog" NameCreateVoteLog = "CreateVoteLog"
NameCommitVoteLog = "CommitVoteLog" NameCommitVoteLog = "CommitVoteLog"
NameCloseVoteLog = "CloseVoteLog"
NameUpdateMemberLog = "UpdateMemberLog"
) )
var ( var (
...@@ -47,16 +55,20 @@ var ( ...@@ -47,16 +55,20 @@ var (
//定义actionMap //定义actionMap
actionMap = map[string]int32{ actionMap = map[string]int32{
NameCreateGroupAction: TyCreateGroupAction, NameCreateGroupAction: TyCreateGroupAction,
NameUpdateMemberAction: TyUpdateMemberAction, NameUpdateGroupAction: TyUpdateGroupAction,
NameCreateVoteAction: TyCreateVoteAction, NameCreateVoteAction: TyCreateVoteAction,
NameCommitVoteAction: TyCommitVoteAction, NameCommitVoteAction: TyCommitVoteAction,
NameCloseVoteAction: TyCloseVoteAction,
NameUpdateMemberAction: TyUpdateMemberAction,
} }
//定义log的id和具体log类型及名称,填入具体自定义log类型 //定义log的id和具体log类型及名称,填入具体自定义log类型
logMap = map[int64]*types.LogInfo{ logMap = map[int64]*types.LogInfo{
TyCreateGroupLog: {Ty: reflect.TypeOf(GroupInfo{}), Name: NameCreateGroupLog}, TyCreateGroupLog: {Ty: reflect.TypeOf(GroupInfo{}), Name: NameCreateGroupLog},
TyUpdateMemberLog: {Ty: reflect.TypeOf(GroupInfo{}), Name: NameUpdateMemberLog}, TyUpdateGroupLog: {Ty: reflect.TypeOf(GroupInfo{}), Name: NameUpdateGroupLog},
TyCreateVoteLog: {Ty: reflect.TypeOf(VoteInfo{}), Name: NameCreateVoteLog}, TyCreateVoteLog: {Ty: reflect.TypeOf(VoteInfo{}), Name: NameCreateVoteLog},
TyCommitVoteLog: {Ty: reflect.TypeOf(VoteInfo{}), Name: NameCommitVoteLog}, TyCommitVoteLog: {Ty: reflect.TypeOf(CommitInfo{}), Name: NameCommitVoteLog},
TyCloseVoteLog: {Ty: reflect.TypeOf(VoteInfo{}), Name: NameCloseVoteLog},
TyUpdateMemberLog: {Ty: reflect.TypeOf(MemberInfo{}), Name: NameUpdateMemberLog},
} }
tlog = log.New("module", "vote.types") tlog = log.New("module", "vote.types")
) )
......
...@@ -26,9 +26,11 @@ type VoteAction struct { ...@@ -26,9 +26,11 @@ type VoteAction struct {
Ty int32 `protobuf:"varint,1,opt,name=ty,proto3" json:"ty,omitempty"` Ty int32 `protobuf:"varint,1,opt,name=ty,proto3" json:"ty,omitempty"`
// Types that are valid to be assigned to Value: // Types that are valid to be assigned to Value:
// *VoteAction_CreateGroup // *VoteAction_CreateGroup
// *VoteAction_UpdateMember // *VoteAction_UpdateGroup
// *VoteAction_CreateVote // *VoteAction_CreateVote
// *VoteAction_CommitVote // *VoteAction_CommitVote
// *VoteAction_CloseVote
// *VoteAction_UpdateMember
Value isVoteAction_Value `protobuf_oneof:"value"` Value isVoteAction_Value `protobuf_oneof:"value"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
...@@ -75,8 +77,8 @@ type VoteAction_CreateGroup struct { ...@@ -75,8 +77,8 @@ type VoteAction_CreateGroup struct {
CreateGroup *CreateGroup `protobuf:"bytes,2,opt,name=createGroup,proto3,oneof"` CreateGroup *CreateGroup `protobuf:"bytes,2,opt,name=createGroup,proto3,oneof"`
} }
type VoteAction_UpdateMember struct { type VoteAction_UpdateGroup struct {
UpdateMember *UpdateMember `protobuf:"bytes,3,opt,name=updateMember,proto3,oneof"` UpdateGroup *UpdateGroup `protobuf:"bytes,3,opt,name=updateGroup,proto3,oneof"`
} }
type VoteAction_CreateVote struct { type VoteAction_CreateVote struct {
...@@ -87,14 +89,26 @@ type VoteAction_CommitVote struct { ...@@ -87,14 +89,26 @@ type VoteAction_CommitVote struct {
CommitVote *CommitVote `protobuf:"bytes,5,opt,name=commitVote,proto3,oneof"` CommitVote *CommitVote `protobuf:"bytes,5,opt,name=commitVote,proto3,oneof"`
} }
type VoteAction_CloseVote struct {
CloseVote *CloseVote `protobuf:"bytes,6,opt,name=closeVote,proto3,oneof"`
}
type VoteAction_UpdateMember struct {
UpdateMember *UpdateMember `protobuf:"bytes,7,opt,name=updateMember,proto3,oneof"`
}
func (*VoteAction_CreateGroup) isVoteAction_Value() {} func (*VoteAction_CreateGroup) isVoteAction_Value() {}
func (*VoteAction_UpdateMember) isVoteAction_Value() {} func (*VoteAction_UpdateGroup) isVoteAction_Value() {}
func (*VoteAction_CreateVote) isVoteAction_Value() {} func (*VoteAction_CreateVote) isVoteAction_Value() {}
func (*VoteAction_CommitVote) isVoteAction_Value() {} func (*VoteAction_CommitVote) isVoteAction_Value() {}
func (*VoteAction_CloseVote) isVoteAction_Value() {}
func (*VoteAction_UpdateMember) isVoteAction_Value() {}
func (m *VoteAction) GetValue() isVoteAction_Value { func (m *VoteAction) GetValue() isVoteAction_Value {
if m != nil { if m != nil {
return m.Value return m.Value
...@@ -109,9 +123,9 @@ func (m *VoteAction) GetCreateGroup() *CreateGroup { ...@@ -109,9 +123,9 @@ func (m *VoteAction) GetCreateGroup() *CreateGroup {
return nil return nil
} }
func (m *VoteAction) GetUpdateMember() *UpdateMember { func (m *VoteAction) GetUpdateGroup() *UpdateGroup {
if x, ok := m.GetValue().(*VoteAction_UpdateMember); ok { if x, ok := m.GetValue().(*VoteAction_UpdateGroup); ok {
return x.UpdateMember return x.UpdateGroup
} }
return nil return nil
} }
...@@ -130,13 +144,29 @@ func (m *VoteAction) GetCommitVote() *CommitVote { ...@@ -130,13 +144,29 @@ func (m *VoteAction) GetCommitVote() *CommitVote {
return nil return nil
} }
func (m *VoteAction) GetCloseVote() *CloseVote {
if x, ok := m.GetValue().(*VoteAction_CloseVote); ok {
return x.CloseVote
}
return nil
}
func (m *VoteAction) GetUpdateMember() *UpdateMember {
if x, ok := m.GetValue().(*VoteAction_UpdateMember); ok {
return x.UpdateMember
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package. // XXX_OneofWrappers is for the internal use of the proto package.
func (*VoteAction) XXX_OneofWrappers() []interface{} { func (*VoteAction) XXX_OneofWrappers() []interface{} {
return []interface{}{ return []interface{}{
(*VoteAction_CreateGroup)(nil), (*VoteAction_CreateGroup)(nil),
(*VoteAction_UpdateMember)(nil), (*VoteAction_UpdateGroup)(nil),
(*VoteAction_CreateVote)(nil), (*VoteAction_CreateVote)(nil),
(*VoteAction_CommitVote)(nil), (*VoteAction_CommitVote)(nil),
(*VoteAction_CloseVote)(nil),
(*VoteAction_UpdateMember)(nil),
} }
} }
...@@ -192,6 +222,7 @@ type CreateGroup struct { ...@@ -192,6 +222,7 @@ type CreateGroup struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Admins []string `protobuf:"bytes,2,rep,name=admins,proto3" json:"admins,omitempty"` Admins []string `protobuf:"bytes,2,rep,name=admins,proto3" json:"admins,omitempty"`
Members []*GroupMember `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"` Members []*GroupMember `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"`
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -243,58 +274,81 @@ func (m *CreateGroup) GetMembers() []*GroupMember { ...@@ -243,58 +274,81 @@ func (m *CreateGroup) GetMembers() []*GroupMember {
return nil return nil
} }
func (m *CreateGroup) GetDescription() string {
if m != nil {
return m.Description
}
return ""
}
//更新投票组 //更新投票组
type UpdateMember struct { type UpdateGroup struct {
GroupID string `protobuf:"bytes,1,opt,name=groupID,proto3" json:"groupID,omitempty"` GroupID string `protobuf:"bytes,1,opt,name=groupID,proto3" json:"groupID,omitempty"`
AddMembers []*GroupMember `protobuf:"bytes,2,rep,name=addMembers,proto3" json:"addMembers,omitempty"` AddMembers []*GroupMember `protobuf:"bytes,2,rep,name=addMembers,proto3" json:"addMembers,omitempty"`
RemoveMemberAddrs []string `protobuf:"bytes,3,rep,name=removeMemberAddrs,proto3" json:"removeMemberAddrs,omitempty"` RemoveMembers []string `protobuf:"bytes,3,rep,name=removeMembers,proto3" json:"removeMembers,omitempty"`
AddAdmins []string `protobuf:"bytes,4,rep,name=addAdmins,proto3" json:"addAdmins,omitempty"`
RemoveAdmins []string `protobuf:"bytes,5,rep,name=removeAdmins,proto3" json:"removeAdmins,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
} }
func (m *UpdateMember) Reset() { *m = UpdateMember{} } func (m *UpdateGroup) Reset() { *m = UpdateGroup{} }
func (m *UpdateMember) String() string { return proto.CompactTextString(m) } func (m *UpdateGroup) String() string { return proto.CompactTextString(m) }
func (*UpdateMember) ProtoMessage() {} func (*UpdateGroup) ProtoMessage() {}
func (*UpdateMember) Descriptor() ([]byte, []int) { func (*UpdateGroup) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{3} return fileDescriptor_21d31c94b62a6ac7, []int{3}
} }
func (m *UpdateMember) XXX_Unmarshal(b []byte) error { func (m *UpdateGroup) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateMember.Unmarshal(m, b) return xxx_messageInfo_UpdateGroup.Unmarshal(m, b)
} }
func (m *UpdateMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { func (m *UpdateGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UpdateMember.Marshal(b, m, deterministic) return xxx_messageInfo_UpdateGroup.Marshal(b, m, deterministic)
} }
func (m *UpdateMember) XXX_Merge(src proto.Message) { func (m *UpdateGroup) XXX_Merge(src proto.Message) {
xxx_messageInfo_UpdateMember.Merge(m, src) xxx_messageInfo_UpdateGroup.Merge(m, src)
} }
func (m *UpdateMember) XXX_Size() int { func (m *UpdateGroup) XXX_Size() int {
return xxx_messageInfo_UpdateMember.Size(m) return xxx_messageInfo_UpdateGroup.Size(m)
} }
func (m *UpdateMember) XXX_DiscardUnknown() { func (m *UpdateGroup) XXX_DiscardUnknown() {
xxx_messageInfo_UpdateMember.DiscardUnknown(m) xxx_messageInfo_UpdateGroup.DiscardUnknown(m)
} }
var xxx_messageInfo_UpdateMember proto.InternalMessageInfo var xxx_messageInfo_UpdateGroup proto.InternalMessageInfo
func (m *UpdateMember) GetGroupID() string { func (m *UpdateGroup) GetGroupID() string {
if m != nil { if m != nil {
return m.GroupID return m.GroupID
} }
return "" return ""
} }
func (m *UpdateMember) GetAddMembers() []*GroupMember { func (m *UpdateGroup) GetAddMembers() []*GroupMember {
if m != nil { if m != nil {
return m.AddMembers return m.AddMembers
} }
return nil return nil
} }
func (m *UpdateMember) GetRemoveMemberAddrs() []string { func (m *UpdateGroup) GetRemoveMembers() []string {
if m != nil { if m != nil {
return m.RemoveMemberAddrs return m.RemoveMembers
}
return nil
}
func (m *UpdateGroup) GetAddAdmins() []string {
if m != nil {
return m.AddAdmins
}
return nil
}
func (m *UpdateGroup) GetRemoveAdmins() []string {
if m != nil {
return m.RemoveAdmins
} }
return nil return nil
} }
...@@ -307,6 +361,7 @@ type GroupInfo struct { ...@@ -307,6 +361,7 @@ type GroupInfo struct {
Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"`
Admins []string `protobuf:"bytes,5,rep,name=admins,proto3" json:"admins,omitempty"` Admins []string `protobuf:"bytes,5,rep,name=admins,proto3" json:"admins,omitempty"`
Members []*GroupMember `protobuf:"bytes,6,rep,name=members,proto3" json:"members,omitempty"` Members []*GroupMember `protobuf:"bytes,6,rep,name=members,proto3" json:"members,omitempty"`
Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -379,6 +434,52 @@ func (m *GroupInfo) GetMembers() []*GroupMember { ...@@ -379,6 +434,52 @@ func (m *GroupInfo) GetMembers() []*GroupMember {
return nil return nil
} }
func (m *GroupInfo) GetDescription() string {
if m != nil {
return m.Description
}
return ""
}
type GroupInfos struct {
GroupList []*GroupInfo `protobuf:"bytes,1,rep,name=groupList,proto3" json:"groupList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GroupInfos) Reset() { *m = GroupInfos{} }
func (m *GroupInfos) String() string { return proto.CompactTextString(m) }
func (*GroupInfos) ProtoMessage() {}
func (*GroupInfos) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{5}
}
func (m *GroupInfos) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GroupInfos.Unmarshal(m, b)
}
func (m *GroupInfos) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GroupInfos.Marshal(b, m, deterministic)
}
func (m *GroupInfos) XXX_Merge(src proto.Message) {
xxx_messageInfo_GroupInfos.Merge(m, src)
}
func (m *GroupInfos) XXX_Size() int {
return xxx_messageInfo_GroupInfos.Size(m)
}
func (m *GroupInfos) XXX_DiscardUnknown() {
xxx_messageInfo_GroupInfos.DiscardUnknown(m)
}
var xxx_messageInfo_GroupInfos proto.InternalMessageInfo
func (m *GroupInfos) GetGroupList() []*GroupInfo {
if m != nil {
return m.GroupList
}
return nil
}
//投票选项 //投票选项
type VoteOption struct { type VoteOption struct {
Option string `protobuf:"bytes,1,opt,name=option,proto3" json:"option,omitempty"` Option string `protobuf:"bytes,1,opt,name=option,proto3" json:"option,omitempty"`
...@@ -392,7 +493,7 @@ func (m *VoteOption) Reset() { *m = VoteOption{} } ...@@ -392,7 +493,7 @@ func (m *VoteOption) Reset() { *m = VoteOption{} }
func (m *VoteOption) String() string { return proto.CompactTextString(m) } func (m *VoteOption) String() string { return proto.CompactTextString(m) }
func (*VoteOption) ProtoMessage() {} func (*VoteOption) ProtoMessage() {}
func (*VoteOption) Descriptor() ([]byte, []int) { func (*VoteOption) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{5} return fileDescriptor_21d31c94b62a6ac7, []int{6}
} }
func (m *VoteOption) XXX_Unmarshal(b []byte) error { func (m *VoteOption) XXX_Unmarshal(b []byte) error {
...@@ -430,10 +531,11 @@ func (m *VoteOption) GetScore() uint32 { ...@@ -430,10 +531,11 @@ func (m *VoteOption) GetScore() uint32 {
// 创建投票交易,请求结构 // 创建投票交易,请求结构
type CreateVote struct { type CreateVote struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
VoteGroups []string `protobuf:"bytes,2,rep,name=voteGroups,proto3" json:"voteGroups,omitempty"` GroupID string `protobuf:"bytes,2,opt,name=groupID,proto3" json:"groupID,omitempty"`
VoteOptions []string `protobuf:"bytes,3,rep,name=voteOptions,proto3" json:"voteOptions,omitempty"` VoteOptions []string `protobuf:"bytes,3,rep,name=voteOptions,proto3" json:"voteOptions,omitempty"`
BeginTimestamp int64 `protobuf:"varint,4,opt,name=beginTimestamp,proto3" json:"beginTimestamp,omitempty"` BeginTimestamp int64 `protobuf:"varint,4,opt,name=beginTimestamp,proto3" json:"beginTimestamp,omitempty"`
EndTimestamp int64 `protobuf:"varint,5,opt,name=endTimestamp,proto3" json:"endTimestamp,omitempty"` EndTimestamp int64 `protobuf:"varint,5,opt,name=endTimestamp,proto3" json:"endTimestamp,omitempty"`
Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -443,7 +545,7 @@ func (m *CreateVote) Reset() { *m = CreateVote{} } ...@@ -443,7 +545,7 @@ func (m *CreateVote) Reset() { *m = CreateVote{} }
func (m *CreateVote) String() string { return proto.CompactTextString(m) } func (m *CreateVote) String() string { return proto.CompactTextString(m) }
func (*CreateVote) ProtoMessage() {} func (*CreateVote) ProtoMessage() {}
func (*CreateVote) Descriptor() ([]byte, []int) { func (*CreateVote) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{6} return fileDescriptor_21d31c94b62a6ac7, []int{7}
} }
func (m *CreateVote) XXX_Unmarshal(b []byte) error { func (m *CreateVote) XXX_Unmarshal(b []byte) error {
...@@ -471,11 +573,11 @@ func (m *CreateVote) GetName() string { ...@@ -471,11 +573,11 @@ func (m *CreateVote) GetName() string {
return "" return ""
} }
func (m *CreateVote) GetVoteGroups() []string { func (m *CreateVote) GetGroupID() string {
if m != nil { if m != nil {
return m.VoteGroups return m.GroupID
} }
return nil return ""
} }
func (m *CreateVote) GetVoteOptions() []string { func (m *CreateVote) GetVoteOptions() []string {
...@@ -499,11 +601,17 @@ func (m *CreateVote) GetEndTimestamp() int64 { ...@@ -499,11 +601,17 @@ func (m *CreateVote) GetEndTimestamp() int64 {
return 0 return 0
} }
func (m *CreateVote) GetDescription() string {
if m != nil {
return m.Description
}
return ""
}
// 创建提交投票交易,请求结构 // 创建提交投票交易,请求结构
type CommitVote struct { type CommitVote struct {
VoteID string `protobuf:"bytes,1,opt,name=voteID,proto3" json:"voteID,omitempty"` VoteID string `protobuf:"bytes,1,opt,name=voteID,proto3" json:"voteID,omitempty"`
GroupID string `protobuf:"bytes,2,opt,name=groupID,proto3" json:"groupID,omitempty"` OptionIndex uint32 `protobuf:"varint,2,opt,name=optionIndex,proto3" json:"optionIndex,omitempty"`
OptionIndex uint32 `protobuf:"varint,3,opt,name=optionIndex,proto3" json:"optionIndex,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -513,7 +621,7 @@ func (m *CommitVote) Reset() { *m = CommitVote{} } ...@@ -513,7 +621,7 @@ func (m *CommitVote) Reset() { *m = CommitVote{} }
func (m *CommitVote) String() string { return proto.CompactTextString(m) } func (m *CommitVote) String() string { return proto.CompactTextString(m) }
func (*CommitVote) ProtoMessage() {} func (*CommitVote) ProtoMessage() {}
func (*CommitVote) Descriptor() ([]byte, []int) { func (*CommitVote) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{7} return fileDescriptor_21d31c94b62a6ac7, []int{8}
} }
func (m *CommitVote) XXX_Unmarshal(b []byte) error { func (m *CommitVote) XXX_Unmarshal(b []byte) error {
...@@ -541,18 +649,136 @@ func (m *CommitVote) GetVoteID() string { ...@@ -541,18 +649,136 @@ func (m *CommitVote) GetVoteID() string {
return "" return ""
} }
func (m *CommitVote) GetGroupID() string { func (m *CommitVote) GetOptionIndex() uint32 {
if m != nil { if m != nil {
return m.GroupID return m.OptionIndex
}
return 0
}
type CommitInfo struct {
Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"`
TxHash string `protobuf:"bytes,2,opt,name=txHash,proto3" json:"txHash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CommitInfo) Reset() { *m = CommitInfo{} }
func (m *CommitInfo) String() string { return proto.CompactTextString(m) }
func (*CommitInfo) ProtoMessage() {}
func (*CommitInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{9}
}
func (m *CommitInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CommitInfo.Unmarshal(m, b)
}
func (m *CommitInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CommitInfo.Marshal(b, m, deterministic)
}
func (m *CommitInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_CommitInfo.Merge(m, src)
}
func (m *CommitInfo) XXX_Size() int {
return xxx_messageInfo_CommitInfo.Size(m)
}
func (m *CommitInfo) XXX_DiscardUnknown() {
xxx_messageInfo_CommitInfo.DiscardUnknown(m)
}
var xxx_messageInfo_CommitInfo proto.InternalMessageInfo
func (m *CommitInfo) GetAddr() string {
if m != nil {
return m.Addr
} }
return "" return ""
} }
func (m *CommitVote) GetOptionIndex() uint32 { func (m *CommitInfo) GetTxHash() string {
if m != nil { if m != nil {
return m.OptionIndex return m.TxHash
} }
return 0 return ""
}
type CloseVote struct {
VoteID string `protobuf:"bytes,1,opt,name=voteID,proto3" json:"voteID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CloseVote) Reset() { *m = CloseVote{} }
func (m *CloseVote) String() string { return proto.CompactTextString(m) }
func (*CloseVote) ProtoMessage() {}
func (*CloseVote) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{10}
}
func (m *CloseVote) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CloseVote.Unmarshal(m, b)
}
func (m *CloseVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CloseVote.Marshal(b, m, deterministic)
}
func (m *CloseVote) XXX_Merge(src proto.Message) {
xxx_messageInfo_CloseVote.Merge(m, src)
}
func (m *CloseVote) XXX_Size() int {
return xxx_messageInfo_CloseVote.Size(m)
}
func (m *CloseVote) XXX_DiscardUnknown() {
xxx_messageInfo_CloseVote.DiscardUnknown(m)
}
var xxx_messageInfo_CloseVote proto.InternalMessageInfo
func (m *CloseVote) GetVoteID() string {
if m != nil {
return m.VoteID
}
return ""
}
type UpdateMember struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UpdateMember) Reset() { *m = UpdateMember{} }
func (m *UpdateMember) String() string { return proto.CompactTextString(m) }
func (*UpdateMember) ProtoMessage() {}
func (*UpdateMember) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{11}
}
func (m *UpdateMember) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateMember.Unmarshal(m, b)
}
func (m *UpdateMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UpdateMember.Marshal(b, m, deterministic)
}
func (m *UpdateMember) XXX_Merge(src proto.Message) {
xxx_messageInfo_UpdateMember.Merge(m, src)
}
func (m *UpdateMember) XXX_Size() int {
return xxx_messageInfo_UpdateMember.Size(m)
}
func (m *UpdateMember) XXX_DiscardUnknown() {
xxx_messageInfo_UpdateMember.DiscardUnknown(m)
}
var xxx_messageInfo_UpdateMember proto.InternalMessageInfo
func (m *UpdateMember) GetName() string {
if m != nil {
return m.Name
}
return ""
} }
//投票信息 //投票信息
...@@ -560,11 +786,13 @@ type VoteInfo struct { ...@@ -560,11 +786,13 @@ type VoteInfo struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"`
VoteGroups []string `protobuf:"bytes,4,rep,name=voteGroups,proto3" json:"voteGroups,omitempty"` GroupID string `protobuf:"bytes,4,opt,name=groupID,proto3" json:"groupID,omitempty"`
VoteOptions []*VoteOption `protobuf:"bytes,5,rep,name=voteOptions,proto3" json:"voteOptions,omitempty"` VoteOptions []*VoteOption `protobuf:"bytes,5,rep,name=voteOptions,proto3" json:"voteOptions,omitempty"`
BeginTimestamp int64 `protobuf:"varint,6,opt,name=beginTimestamp,proto3" json:"beginTimestamp,omitempty"` BeginTimestamp int64 `protobuf:"varint,6,opt,name=beginTimestamp,proto3" json:"beginTimestamp,omitempty"`
EndTimestamp int64 `protobuf:"varint,7,opt,name=endTimestamp,proto3" json:"endTimestamp,omitempty"` EndTimestamp int64 `protobuf:"varint,7,opt,name=endTimestamp,proto3" json:"endTimestamp,omitempty"`
VotedMembers []string `protobuf:"bytes,8,rep,name=votedMembers,proto3" json:"votedMembers,omitempty"` CommitInfos []*CommitInfo `protobuf:"bytes,8,rep,name=commitInfos,proto3" json:"commitInfos,omitempty"`
Description string `protobuf:"bytes,9,opt,name=description,proto3" json:"description,omitempty"`
Status uint32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -574,7 +802,7 @@ func (m *VoteInfo) Reset() { *m = VoteInfo{} } ...@@ -574,7 +802,7 @@ func (m *VoteInfo) Reset() { *m = VoteInfo{} }
func (m *VoteInfo) String() string { return proto.CompactTextString(m) } func (m *VoteInfo) String() string { return proto.CompactTextString(m) }
func (*VoteInfo) ProtoMessage() {} func (*VoteInfo) ProtoMessage() {}
func (*VoteInfo) Descriptor() ([]byte, []int) { func (*VoteInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{8} return fileDescriptor_21d31c94b62a6ac7, []int{12}
} }
func (m *VoteInfo) XXX_Unmarshal(b []byte) error { func (m *VoteInfo) XXX_Unmarshal(b []byte) error {
...@@ -616,11 +844,11 @@ func (m *VoteInfo) GetCreator() string { ...@@ -616,11 +844,11 @@ func (m *VoteInfo) GetCreator() string {
return "" return ""
} }
func (m *VoteInfo) GetVoteGroups() []string { func (m *VoteInfo) GetGroupID() string {
if m != nil { if m != nil {
return m.VoteGroups return m.GroupID
} }
return nil return ""
} }
func (m *VoteInfo) GetVoteOptions() []*VoteOption { func (m *VoteInfo) GetVoteOptions() []*VoteOption {
...@@ -644,13 +872,27 @@ func (m *VoteInfo) GetEndTimestamp() int64 { ...@@ -644,13 +872,27 @@ func (m *VoteInfo) GetEndTimestamp() int64 {
return 0 return 0
} }
func (m *VoteInfo) GetVotedMembers() []string { func (m *VoteInfo) GetCommitInfos() []*CommitInfo {
if m != nil { if m != nil {
return m.VotedMembers return m.CommitInfos
} }
return nil return nil
} }
func (m *VoteInfo) GetDescription() string {
if m != nil {
return m.Description
}
return ""
}
func (m *VoteInfo) GetStatus() uint32 {
if m != nil {
return m.Status
}
return 0
}
type VoteInfos struct { type VoteInfos struct {
VoteList []*VoteInfo `protobuf:"bytes,1,rep,name=voteList,proto3" json:"voteList,omitempty"` VoteList []*VoteInfo `protobuf:"bytes,1,rep,name=voteList,proto3" json:"voteList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
...@@ -662,7 +904,7 @@ func (m *VoteInfos) Reset() { *m = VoteInfos{} } ...@@ -662,7 +904,7 @@ func (m *VoteInfos) Reset() { *m = VoteInfos{} }
func (m *VoteInfos) String() string { return proto.CompactTextString(m) } func (m *VoteInfos) String() string { return proto.CompactTextString(m) }
func (*VoteInfos) ProtoMessage() {} func (*VoteInfos) ProtoMessage() {}
func (*VoteInfos) Descriptor() ([]byte, []int) { func (*VoteInfos) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{9} return fileDescriptor_21d31c94b62a6ac7, []int{13}
} }
func (m *VoteInfos) XXX_Unmarshal(b []byte) error { func (m *VoteInfos) XXX_Unmarshal(b []byte) error {
...@@ -690,95 +932,10 @@ func (m *VoteInfos) GetVoteList() []*VoteInfo { ...@@ -690,95 +932,10 @@ func (m *VoteInfos) GetVoteList() []*VoteInfo {
return nil return nil
} }
type GroupVoteInfo struct {
GroupInfo *GroupInfo `protobuf:"bytes,1,opt,name=groupInfo,proto3" json:"groupInfo,omitempty"`
VoteIDs []string `protobuf:"bytes,2,rep,name=voteIDs,proto3" json:"voteIDs,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GroupVoteInfo) Reset() { *m = GroupVoteInfo{} }
func (m *GroupVoteInfo) String() string { return proto.CompactTextString(m) }
func (*GroupVoteInfo) ProtoMessage() {}
func (*GroupVoteInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{10}
}
func (m *GroupVoteInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GroupVoteInfo.Unmarshal(m, b)
}
func (m *GroupVoteInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GroupVoteInfo.Marshal(b, m, deterministic)
}
func (m *GroupVoteInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_GroupVoteInfo.Merge(m, src)
}
func (m *GroupVoteInfo) XXX_Size() int {
return xxx_messageInfo_GroupVoteInfo.Size(m)
}
func (m *GroupVoteInfo) XXX_DiscardUnknown() {
xxx_messageInfo_GroupVoteInfo.DiscardUnknown(m)
}
var xxx_messageInfo_GroupVoteInfo proto.InternalMessageInfo
func (m *GroupVoteInfo) GetGroupInfo() *GroupInfo {
if m != nil {
return m.GroupInfo
}
return nil
}
func (m *GroupVoteInfo) GetVoteIDs() []string {
if m != nil {
return m.VoteIDs
}
return nil
}
type GroupVoteInfos struct {
GroupList []*GroupVoteInfo `protobuf:"bytes,1,rep,name=groupList,proto3" json:"groupList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *GroupVoteInfos) Reset() { *m = GroupVoteInfos{} }
func (m *GroupVoteInfos) String() string { return proto.CompactTextString(m) }
func (*GroupVoteInfos) ProtoMessage() {}
func (*GroupVoteInfos) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{11}
}
func (m *GroupVoteInfos) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GroupVoteInfos.Unmarshal(m, b)
}
func (m *GroupVoteInfos) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_GroupVoteInfos.Marshal(b, m, deterministic)
}
func (m *GroupVoteInfos) XXX_Merge(src proto.Message) {
xxx_messageInfo_GroupVoteInfos.Merge(m, src)
}
func (m *GroupVoteInfos) XXX_Size() int {
return xxx_messageInfo_GroupVoteInfos.Size(m)
}
func (m *GroupVoteInfos) XXX_DiscardUnknown() {
xxx_messageInfo_GroupVoteInfos.DiscardUnknown(m)
}
var xxx_messageInfo_GroupVoteInfos proto.InternalMessageInfo
func (m *GroupVoteInfos) GetGroupList() []*GroupVoteInfo {
if m != nil {
return m.GroupList
}
return nil
}
type MemberInfo struct { type MemberInfo struct {
Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"`
GroupIDs []string `protobuf:"bytes,2,rep,name=groupIDs,proto3" json:"groupIDs,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
GroupIDs []string `protobuf:"bytes,3,rep,name=groupIDs,proto3" json:"groupIDs,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -788,7 +945,7 @@ func (m *MemberInfo) Reset() { *m = MemberInfo{} } ...@@ -788,7 +945,7 @@ func (m *MemberInfo) Reset() { *m = MemberInfo{} }
func (m *MemberInfo) String() string { return proto.CompactTextString(m) } func (m *MemberInfo) String() string { return proto.CompactTextString(m) }
func (*MemberInfo) ProtoMessage() {} func (*MemberInfo) ProtoMessage() {}
func (*MemberInfo) Descriptor() ([]byte, []int) { func (*MemberInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{12} return fileDescriptor_21d31c94b62a6ac7, []int{14}
} }
func (m *MemberInfo) XXX_Unmarshal(b []byte) error { func (m *MemberInfo) XXX_Unmarshal(b []byte) error {
...@@ -816,6 +973,13 @@ func (m *MemberInfo) GetAddr() string { ...@@ -816,6 +973,13 @@ func (m *MemberInfo) GetAddr() string {
return "" return ""
} }
func (m *MemberInfo) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *MemberInfo) GetGroupIDs() []string { func (m *MemberInfo) GetGroupIDs() []string {
if m != nil { if m != nil {
return m.GroupIDs return m.GroupIDs
...@@ -834,7 +998,7 @@ func (m *MemberInfos) Reset() { *m = MemberInfos{} } ...@@ -834,7 +998,7 @@ func (m *MemberInfos) Reset() { *m = MemberInfos{} }
func (m *MemberInfos) String() string { return proto.CompactTextString(m) } func (m *MemberInfos) String() string { return proto.CompactTextString(m) }
func (*MemberInfos) ProtoMessage() {} func (*MemberInfos) ProtoMessage() {}
func (*MemberInfos) Descriptor() ([]byte, []int) { func (*MemberInfos) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{13} return fileDescriptor_21d31c94b62a6ac7, []int{15}
} }
func (m *MemberInfos) XXX_Unmarshal(b []byte) error { func (m *MemberInfos) XXX_Unmarshal(b []byte) error {
...@@ -862,6 +1026,45 @@ func (m *MemberInfos) GetMemberList() []*MemberInfo { ...@@ -862,6 +1026,45 @@ func (m *MemberInfos) GetMemberList() []*MemberInfo {
return nil return nil
} }
type ReqStrings struct {
Items []string `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqStrings) Reset() { *m = ReqStrings{} }
func (m *ReqStrings) String() string { return proto.CompactTextString(m) }
func (*ReqStrings) ProtoMessage() {}
func (*ReqStrings) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{16}
}
func (m *ReqStrings) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqStrings.Unmarshal(m, b)
}
func (m *ReqStrings) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqStrings.Marshal(b, m, deterministic)
}
func (m *ReqStrings) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqStrings.Merge(m, src)
}
func (m *ReqStrings) XXX_Size() int {
return xxx_messageInfo_ReqStrings.Size(m)
}
func (m *ReqStrings) XXX_DiscardUnknown() {
xxx_messageInfo_ReqStrings.DiscardUnknown(m)
}
var xxx_messageInfo_ReqStrings proto.InternalMessageInfo
func (m *ReqStrings) GetItems() []string {
if m != nil {
return m.Items
}
return nil
}
//列表请求结构 //列表请求结构
type ReqListItem struct { type ReqListItem struct {
StartItemID string `protobuf:"bytes,1,opt,name=startItemID,proto3" json:"startItemID,omitempty"` StartItemID string `protobuf:"bytes,1,opt,name=startItemID,proto3" json:"startItemID,omitempty"`
...@@ -876,7 +1079,7 @@ func (m *ReqListItem) Reset() { *m = ReqListItem{} } ...@@ -876,7 +1079,7 @@ func (m *ReqListItem) Reset() { *m = ReqListItem{} }
func (m *ReqListItem) String() string { return proto.CompactTextString(m) } func (m *ReqListItem) String() string { return proto.CompactTextString(m) }
func (*ReqListItem) ProtoMessage() {} func (*ReqListItem) ProtoMessage() {}
func (*ReqListItem) Descriptor() ([]byte, []int) { func (*ReqListItem) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{14} return fileDescriptor_21d31c94b62a6ac7, []int{17}
} }
func (m *ReqListItem) XXX_Unmarshal(b []byte) error { func (m *ReqListItem) XXX_Unmarshal(b []byte) error {
...@@ -918,22 +1121,137 @@ func (m *ReqListItem) GetDirection() int32 { ...@@ -918,22 +1121,137 @@ func (m *ReqListItem) GetDirection() int32 {
return 0 return 0
} }
type ReqListVote struct {
GroupID string `protobuf:"bytes,1,opt,name=groupID,proto3" json:"groupID,omitempty"`
ListReq *ReqListItem `protobuf:"bytes,2,opt,name=listReq,proto3" json:"listReq,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReqListVote) Reset() { *m = ReqListVote{} }
func (m *ReqListVote) String() string { return proto.CompactTextString(m) }
func (*ReqListVote) ProtoMessage() {}
func (*ReqListVote) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{18}
}
func (m *ReqListVote) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqListVote.Unmarshal(m, b)
}
func (m *ReqListVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReqListVote.Marshal(b, m, deterministic)
}
func (m *ReqListVote) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReqListVote.Merge(m, src)
}
func (m *ReqListVote) XXX_Size() int {
return xxx_messageInfo_ReqListVote.Size(m)
}
func (m *ReqListVote) XXX_DiscardUnknown() {
xxx_messageInfo_ReqListVote.DiscardUnknown(m)
}
var xxx_messageInfo_ReqListVote proto.InternalMessageInfo
func (m *ReqListVote) GetGroupID() string {
if m != nil {
return m.GroupID
}
return ""
}
func (m *ReqListVote) GetListReq() *ReqListItem {
if m != nil {
return m.ListReq
}
return nil
}
type ReplyVoteList struct {
PendingList []*VoteInfo `protobuf:"bytes,1,rep,name=pendingList,proto3" json:"pendingList,omitempty"`
OngoingList []*VoteInfo `protobuf:"bytes,2,rep,name=ongoingList,proto3" json:"ongoingList,omitempty"`
FinishedList []*VoteInfo `protobuf:"bytes,3,rep,name=finishedList,proto3" json:"finishedList,omitempty"`
ClosedList []*VoteInfo `protobuf:"bytes,4,rep,name=closedList,proto3" json:"closedList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ReplyVoteList) Reset() { *m = ReplyVoteList{} }
func (m *ReplyVoteList) String() string { return proto.CompactTextString(m) }
func (*ReplyVoteList) ProtoMessage() {}
func (*ReplyVoteList) Descriptor() ([]byte, []int) {
return fileDescriptor_21d31c94b62a6ac7, []int{19}
}
func (m *ReplyVoteList) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReplyVoteList.Unmarshal(m, b)
}
func (m *ReplyVoteList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ReplyVoteList.Marshal(b, m, deterministic)
}
func (m *ReplyVoteList) XXX_Merge(src proto.Message) {
xxx_messageInfo_ReplyVoteList.Merge(m, src)
}
func (m *ReplyVoteList) XXX_Size() int {
return xxx_messageInfo_ReplyVoteList.Size(m)
}
func (m *ReplyVoteList) XXX_DiscardUnknown() {
xxx_messageInfo_ReplyVoteList.DiscardUnknown(m)
}
var xxx_messageInfo_ReplyVoteList proto.InternalMessageInfo
func (m *ReplyVoteList) GetPendingList() []*VoteInfo {
if m != nil {
return m.PendingList
}
return nil
}
func (m *ReplyVoteList) GetOngoingList() []*VoteInfo {
if m != nil {
return m.OngoingList
}
return nil
}
func (m *ReplyVoteList) GetFinishedList() []*VoteInfo {
if m != nil {
return m.FinishedList
}
return nil
}
func (m *ReplyVoteList) GetClosedList() []*VoteInfo {
if m != nil {
return m.ClosedList
}
return nil
}
func init() { func init() {
proto.RegisterType((*VoteAction)(nil), "types.VoteAction") proto.RegisterType((*VoteAction)(nil), "types.VoteAction")
proto.RegisterType((*GroupMember)(nil), "types.GroupMember") proto.RegisterType((*GroupMember)(nil), "types.GroupMember")
proto.RegisterType((*CreateGroup)(nil), "types.CreateGroup") proto.RegisterType((*CreateGroup)(nil), "types.CreateGroup")
proto.RegisterType((*UpdateMember)(nil), "types.UpdateMember") proto.RegisterType((*UpdateGroup)(nil), "types.UpdateGroup")
proto.RegisterType((*GroupInfo)(nil), "types.GroupInfo") proto.RegisterType((*GroupInfo)(nil), "types.GroupInfo")
proto.RegisterType((*GroupInfos)(nil), "types.GroupInfos")
proto.RegisterType((*VoteOption)(nil), "types.VoteOption") proto.RegisterType((*VoteOption)(nil), "types.VoteOption")
proto.RegisterType((*CreateVote)(nil), "types.CreateVote") proto.RegisterType((*CreateVote)(nil), "types.CreateVote")
proto.RegisterType((*CommitVote)(nil), "types.CommitVote") proto.RegisterType((*CommitVote)(nil), "types.CommitVote")
proto.RegisterType((*CommitInfo)(nil), "types.CommitInfo")
proto.RegisterType((*CloseVote)(nil), "types.CloseVote")
proto.RegisterType((*UpdateMember)(nil), "types.UpdateMember")
proto.RegisterType((*VoteInfo)(nil), "types.VoteInfo") proto.RegisterType((*VoteInfo)(nil), "types.VoteInfo")
proto.RegisterType((*VoteInfos)(nil), "types.VoteInfos") proto.RegisterType((*VoteInfos)(nil), "types.VoteInfos")
proto.RegisterType((*GroupVoteInfo)(nil), "types.GroupVoteInfo")
proto.RegisterType((*GroupVoteInfos)(nil), "types.GroupVoteInfos")
proto.RegisterType((*MemberInfo)(nil), "types.MemberInfo") proto.RegisterType((*MemberInfo)(nil), "types.MemberInfo")
proto.RegisterType((*MemberInfos)(nil), "types.MemberInfos") proto.RegisterType((*MemberInfos)(nil), "types.MemberInfos")
proto.RegisterType((*ReqStrings)(nil), "types.ReqStrings")
proto.RegisterType((*ReqListItem)(nil), "types.ReqListItem") proto.RegisterType((*ReqListItem)(nil), "types.ReqListItem")
proto.RegisterType((*ReqListVote)(nil), "types.ReqListVote")
proto.RegisterType((*ReplyVoteList)(nil), "types.ReplyVoteList")
} }
func init() { func init() {
...@@ -941,49 +1259,62 @@ func init() { ...@@ -941,49 +1259,62 @@ func init() {
} }
var fileDescriptor_21d31c94b62a6ac7 = []byte{ var fileDescriptor_21d31c94b62a6ac7 = []byte{
// 703 bytes of a gzipped FileDescriptorProto // 909 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x5f, 0x6b, 0xd4, 0x4e, 0x1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f, 0x49, 0x5a, 0x72, 0xfc, 0xe6,
0xc0, 0xf1, 0xf2, 0x58, 0x9b, 0xa0, 0xaf, 0x9b, 0x4d, 0x70, 0xec, 0x4f, 0xff, 0xa9, 0x3c, 0x83,
0xd1, 0x26, 0x95, 0x8a, 0xf1, 0xdb, 0x83, 0x2f, 0x13, 0xab, 0x47, 0x56, 0x43, 0xe8, 0xdf, 0x0e,
0x4c, 0x19, 0x2f, 0x36, 0xfb, 0xcb, 0xca, 0x05, 0xf2, 0x1c, 0x82, 0x82, 0xe7, 0x49, 0x9a, 0xaf,
0xff, 0xcb, 0x35, 0x1b, 0xa3, 0x29, 0x22, 0x5f, 0x8b, 0x9a, 0xe2, 0x9e, 0xa0, 0x58, 0x18, 0xb2,
0x80, 0xc9, 0x75, 0x9a, 0xa7, 0xf2, 0x86, 0x27, 0xc8, 0xe9, 0x1f, 0xe7, 0x74, 0x40, 0xe4, 0x13,
0x00, 0xfc, 0xf2, 0x30, 0x94, 0xc1, 0x71, 0x8a, 0x05, 0xb9, 0x1a, 0xe2, 0x67, 0xdd, 0xe2, 0xdf,
0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0x29, 0x58, 0x6e, 0xe4, 0x09, 0x00, 0x00,
} }
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