Commit 644a26e3 authored by liuyuhang's avatar liuyuhang Committed by 33cn

add prob project

parent dba1186c
...@@ -160,6 +160,14 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -160,6 +160,14 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
} }
pre := copyAutonomyProposalBoard(&cur) pre := copyAutonomyProposalBoard(&cur)
// 检查当前状态
if cur.Status != auty.AutonomyStatusProposalBoard && cur.Status != auty.AutonomyStatusVotePropBoard {
err := auty.ErrProposalStatus
alog.Error("votePropBoard ", "addr", a.fromaddr, "status", cur.Status, "ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
start := cur.GetPropBoard().StartBlockHeight start := cur.GetPropBoard().StartBlockHeight
end := cur.GetPropBoard().EndBlockHeight end := cur.GetPropBoard().EndBlockHeight
real := cur.GetPropBoard().RealEndBlockHeight real := cur.GetPropBoard().RealEndBlockHeight
...@@ -170,14 +178,6 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -170,14 +178,6 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
return nil, err return nil, err
} }
// 检查当前状态
if cur.Status != auty.AutonomyStatusProposalBoard && cur.Status != auty.AutonomyStatusVotePropBoard {
err := auty.ErrProposalStatus
alog.Error("votePropBoard ", "addr", a.fromaddr, "status", cur.Status, "ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
// 检查是否已经参与投票 // 检查是否已经参与投票
var votes auty.VotesRecord var votes auty.VotesRecord
value, err = a.db.Get(VotesRecord(voteProb.ProposalID)) value, err = a.db.Get(VotesRecord(voteProb.ProposalID))
...@@ -224,7 +224,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -224,7 +224,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
if float32(cur.VoteResult.ApproveVotes + cur.VoteResult.OpposeVotes) / float32(cur.VoteResult.TotalVotes) >= participationRate && if cur.VoteResult.TotalVotes != 0 &&
cur.VoteResult.ApproveVotes + cur.VoteResult.OpposeVotes != 0 &&
float32(cur.VoteResult.ApproveVotes + cur.VoteResult.OpposeVotes) / float32(cur.VoteResult.TotalVotes) >= participationRate &&
float32(cur.VoteResult.ApproveVotes) / float32(cur.VoteResult.ApproveVotes + cur.VoteResult.OpposeVotes) >= approveRate { float32(cur.VoteResult.ApproveVotes) / float32(cur.VoteResult.ApproveVotes + cur.VoteResult.OpposeVotes) >= approveRate {
cur.VoteResult.Pass = true cur.VoteResult.Pass = true
cur.PropBoard.RealEndBlockHeight = a.height cur.PropBoard.RealEndBlockHeight = a.height
...@@ -281,15 +283,6 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types. ...@@ -281,15 +283,6 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
} }
pre := copyAutonomyProposalBoard(&cur) pre := copyAutonomyProposalBoard(&cur)
start := cur.GetPropBoard().StartBlockHeight
end := cur.GetPropBoard().EndBlockHeight
if a.height < end && cur.Status != auty.AutonomyStatusVotePropBoard {
err := auty.ErrTerminatePeriod
alog.Error("tmintPropBoard ", "addr", a.fromaddr, "status", cur.Status, "height", a.height, "ProposalID",
tmintProb.ProposalID, "err", err)
return nil, err
}
// 检查当前状态 // 检查当前状态
if cur.Status == auty.AutonomyStatusTmintPropBoard { if cur.Status == auty.AutonomyStatusTmintPropBoard {
err := auty.ErrProposalStatus err := auty.ErrProposalStatus
...@@ -298,6 +291,15 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types. ...@@ -298,6 +291,15 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
return nil, err return nil, err
} }
start := cur.GetPropBoard().StartBlockHeight
end := cur.GetPropBoard().EndBlockHeight
if a.height < end && !cur.VoteResult.Pass {
err := auty.ErrTerminatePeriod
alog.Error("tmintPropBoard ", "addr", a.fromaddr, "status", cur.Status, "height", a.height,
"in vote period can not terminate", tmintProb.ProposalID, "err", err)
return nil, err
}
if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数 if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数
addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp" addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account, err := a.getStartHeightVoteAccount(addr, start) account, err := a.getStartHeightVoteAccount(addr, start)
......
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
const ( const (
largeAmount = types.Coin * 100 *10000 // 重大项目金额阈值 largeAmount = types.Coin * 100 *10000 // 重大项目金额阈值
publicPeriod = 120960 // 公示一周时间,以区块高度计算 publicPeriod = 120960 // 公示一周时间,以区块高度计算
opposeRate = float32(1)/float32(3) // 反对率
) )
...@@ -141,6 +142,14 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -141,6 +142,14 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
} }
pre := copyAutonomyProposalProject(&cur) pre := copyAutonomyProposalProject(&cur)
// 检查当前状态
if cur.Status != auty.AutonomyStatusProposalProject && cur.Status != auty.AutonomyStatusVotePropProject {
err := auty.ErrProposalStatus
alog.Error("votePropProject ", "addr", a.fromaddr, "status", cur.Status, "ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
start := cur.GetPropProject().StartBlockHeight start := cur.GetPropProject().StartBlockHeight
end := cur.GetPropProject().EndBlockHeight end := cur.GetPropProject().EndBlockHeight
real := cur.GetPropProject().RealEndBlockHeight real := cur.GetPropProject().RealEndBlockHeight
...@@ -151,14 +160,6 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -151,14 +160,6 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
return nil, err return nil, err
} }
// 检查当前状态
if cur.Status != auty.AutonomyStatusProposalProject && cur.Status != auty.AutonomyStatusVotePropProject {
err := auty.ErrProposalStatus
alog.Error("votePropProject ", "addr", a.fromaddr, "status", cur.Status, "ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
// 董事会成员验证 // 董事会成员验证
value, err = a.db.Get(activeBoardID()) value, err = a.db.Get(activeBoardID())
if err != nil { if err != nil {
...@@ -225,11 +226,12 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -225,11 +226,12 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
if float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= participationRate && if cur.BoardVoteRes.TotalVotes != 0 &&
cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes != 0 &&
float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= participationRate &&
float32(cur.BoardVoteRes.ApproveVotes) / float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) >= approveRate { float32(cur.BoardVoteRes.ApproveVotes) / float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) >= approveRate {
cur.BoardVoteRes.Pass = true cur.BoardVoteRes.Pass = true
cur.PropProject.RealEndBlockHeight = a.height cur.PropProject.RealEndBlockHeight = a.height
receipt, err := a.coinsAccount.ExecTransferFrozen(cur.Address, autonomyAddr, a.execaddr, lockAmount) receipt, err := a.coinsAccount.ExecTransferFrozen(cur.Address, autonomyAddr, a.execaddr, lockAmount)
if err != nil { if err != nil {
alog.Error("votePropProject ", "addr", cur.Address, "execaddr", a.execaddr, "ExecTransferFrozen amount fail", err) alog.Error("votePropProject ", "addr", cur.Address, "execaddr", a.execaddr, "ExecTransferFrozen amount fail", err)
...@@ -242,8 +244,10 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -242,8 +244,10 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
key := propProjectID(voteProb.ProposalID) key := propProjectID(voteProb.ProposalID)
cur.Status = auty.AutonomyStatusVotePropProject cur.Status = auty.AutonomyStatusVotePropProject
if cur.BoardVoteRes.Pass { if cur.BoardVoteRes.Pass {
if cur.PubVote.Publicity { // 进入公 if cur.PubVote.Publicity { // 进入公
cur.Status = auty.AutonomyStatusPubVotePropProject cur.Status = auty.AutonomyStatusPubVotePropProject
// 进入公示期默认为该提案通过,只有反对票达到三分之一才不会通过该提案
cur.PubVote.PubPass = true
} else { } else {
cur.Status = auty.AutonomyStatusTmintPropProject cur.Status = auty.AutonomyStatusTmintPropProject
} }
...@@ -272,33 +276,33 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -272,33 +276,33 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
// 获取GameID // 获取GameID
value, err := a.db.Get(propProjectID(voteProb.ProposalID)) value, err := a.db.Get(propProjectID(voteProb.ProposalID))
if err != nil { if err != nil {
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propProjectID failed", alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propProjectID failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
var cur auty.AutonomyProposalProject var cur auty.AutonomyProposalProject
err = types.Decode(value, &cur) err = types.Decode(value, &cur)
if err != nil { if err != nil {
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalProject failed", alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalProject failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
pre := copyAutonomyProposalProject(&cur) pre := copyAutonomyProposalProject(&cur)
// 检查当前状态
if cur.Status != auty.AutonomyStatusPubVotePropProject {
err := auty.ErrProposalStatus
alog.Error("pubVotePropProject ", "addr", a.fromaddr, "status", cur.Status, "ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
start := cur.GetPropProject().StartBlockHeight start := cur.GetPropProject().StartBlockHeight
end := cur.GetPropProject().EndBlockHeight end := cur.GetPropProject().EndBlockHeight
real := cur.GetPropProject().RealEndBlockHeight real := cur.GetPropProject().RealEndBlockHeight
if start < a.height || end < a.height || (real != 0 && real < a.height) { if start < a.height || end < a.height || (real != 0 && real < a.height) {
err := auty.ErrVotePeriod err := auty.ErrVotePeriod
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID", alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
// 检查当前状态
if cur.Status != auty.AutonomyStatusProposalProject && cur.Status != auty.AutonomyStatusVotePropProject {
err := auty.ErrProposalStatus
alog.Error("votePropProject ", "addr", a.fromaddr, "status", cur.Status, "ProposalID",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
...@@ -309,7 +313,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -309,7 +313,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
if err == nil { if err == nil {
err = types.Decode(value, &votes) err = types.Decode(value, &votes)
if err != nil { if err != nil {
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode VotesRecord failed", alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode VotesRecord failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
...@@ -317,7 +321,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -317,7 +321,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
for _, addr := range votes.Address { for _, addr := range votes.Address {
if addr == a.fromaddr { if addr == a.fromaddr {
err := auty.ErrRepeatVoteAddr err := auty.ErrRepeatVoteAddr
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "repeat address GameID", alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "repeat address GameID",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
...@@ -325,36 +329,35 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -325,36 +329,35 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
// 加入已经投票的 // 加入已经投票的
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计票数 if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计票数
addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp" addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account, err := a.getStartHeightVoteAccount(addr, start) account, err := a.getStartHeightVoteAccount(addr, start)
if err != nil { if err != nil {
return nil, err return nil, err
} }
cur.BoardVoteRes.TotalVotes = int32(account.Balance/ticketPrice) cur.PubVote.TotalVotes = int32(account.Balance/ticketPrice)
} }
// 获取该地址票数
account, err := a.getStartHeightVoteAccount(a.fromaddr, start) account, err := a.getStartHeightVoteAccount(a.fromaddr, start)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if voteProb.voteProb { if voteProb.Oppose { //投反对票
cur.BoardVoteRes.ApproveVotes += int32(account.Balance/ticketPrice) cur.PubVote.OpposeVotes += int32(account.Balance/ticketPrice)
} else {
cur.BoardVoteRes.OpposeVotes += int32(account.Balance/ticketPrice)
} }
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
if float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= participationRate && if cur.PubVote.TotalVotes != 0 &&
float32(cur.BoardVoteRes.ApproveVotes) / float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) >= approveRate { float32(cur.PubVote.OpposeVotes) / float32(cur.PubVote.TotalVotes) >= opposeRate {
cur.BoardVoteRes.Pass = true cur.PubVote.PubPass = false
cur.PropProject.RealEndBlockHeight = a.height cur.PropProject.RealEndBlockHeight = a.height
receipt, err := a.coinsAccount.ExecTransferFrozen(cur.Address, autonomyAddr, a.execaddr, lockAmount) receipt, err := a.coinsAccount.ExecTransferFrozen(cur.Address, autonomyAddr, a.execaddr, lockAmount)
if err != nil { if err != nil {
alog.Error("votePropProject ", "addr", cur.Address, "execaddr", a.execaddr, "ExecTransferFrozen amount fail", err) alog.Error("pubVotePropProject ", "addr", cur.Address, "execaddr", a.execaddr, "ExecTransferFrozen amount fail", err)
return nil, err return nil, err
} }
logs = append(logs, receipt.Logs...) logs = append(logs, receipt.Logs...)
...@@ -362,8 +365,8 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -362,8 +365,8 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
} }
key := propProjectID(voteProb.ProposalID) key := propProjectID(voteProb.ProposalID)
cur.Status = auty.AutonomyStatusVotePropProject cur.Status = auty.AutonomyStatusPubVotePropProject
if cur.BoardVoteRes.Pass { if !cur.PubVote.PubPass {
cur.Status = auty.AutonomyStatusTmintPropProject cur.Status = auty.AutonomyStatusTmintPropProject
} }
value = types.Encode(&cur) value = types.Encode(&cur)
...@@ -372,7 +375,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -372,7 +375,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
// 更新VotesRecord // 更新VotesRecord
kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(&votes)}) kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(&votes)})
ty := auty.TyLogVotePropProject ty := auty.TyLogPubVotePropProject
if cur.BoardVoteRes.Pass { if cur.BoardVoteRes.Pass {
ty = auty.TyLogTmintPropProject ty = auty.TyLogTmintPropProject
} }
...@@ -399,15 +402,6 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty ...@@ -399,15 +402,6 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
} }
pre := copyAutonomyProposalProject(&cur) pre := copyAutonomyProposalProject(&cur)
start := cur.GetPropProject().StartBlockHeight
end := cur.GetPropProject().EndBlockHeight
if a.height < end && cur.Status != auty.AutonomyStatusVotePropProject {
err := auty.ErrTerminatePeriod
alog.Error("tmintPropProject ", "addr", a.fromaddr, "status", cur.Status, "height", a.height, "ProposalID",
tmintProb.ProposalID, "err", err)
return nil, err
}
// 检查当前状态 // 检查当前状态
if cur.Status == auty.AutonomyStatusTmintPropProject { if cur.Status == auty.AutonomyStatusTmintPropProject {
err := auty.ErrProposalStatus err := auty.ErrProposalStatus
...@@ -416,21 +410,74 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty ...@@ -416,21 +410,74 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
return nil, err return nil, err
} }
// 公示期间不能终止
if cur.PubVote.Publicity && cur.PubVote.PubPass &&
a.height <= cur.PropProject.EndBlockHeight + publicPeriod {
err := auty.ErrTerminatePeriod
alog.Error("tmintPropProject ", "addr", a.fromaddr, "status", cur.Status,
"in publicity vote period can not terminate", tmintProb.ProposalID, "err", err)
return nil, err
}
// 董事会投票期间不能终止
start := cur.GetPropProject().StartBlockHeight
end := cur.GetPropProject().EndBlockHeight
if !cur.PubVote.Publicity && a.height < end && !cur.BoardVoteRes.Pass {
err := auty.ErrTerminatePeriod
alog.Error("tmintPropProject ", "addr", a.fromaddr, "status", cur.Status, "height", a.height,
"in board vote period can not terminate", tmintProb.ProposalID, "err", err)
return nil, err
}
if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计票数 if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计票数
addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp" // 董事会成员验证
account, err := a.getStartHeightVoteAccount(addr, start) value, err = a.db.Get(activeBoardID())
if err != nil {
err = auty.ErrNoActiveBoard
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get activeBoardID failed",
tmintProb.ProposalID, "err", err)
return nil, err
}
prob := &auty.ProposalBoard{}
err = types.Decode(value, prob)
if err != nil { if err != nil {
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalBoard failed",
tmintProb.ProposalID, "err", err)
return nil, err return nil, err
} }
cur.BoardVoteRes.TotalVotes = int32(account.Balance/ticketPrice) if len(prob.Boards) > maxBoards || len(prob.Boards) < minBoards {
err = auty.ErrNoActiveBoard
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "illegality boards number",
tmintProb.ProposalID, "err", err)
return nil, err
}
cur.BoardVoteRes.TotalVotes = int32(len(prob.Boards))
} }
if float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= participationRate && if cur.BoardVoteRes.TotalVotes != 0 &&
cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes != 0 &&
float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= participationRate &&
float32(cur.BoardVoteRes.ApproveVotes) / float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) >= approveRate { float32(cur.BoardVoteRes.ApproveVotes) / float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) >= approveRate {
cur.BoardVoteRes.Pass = true cur.BoardVoteRes.Pass = true
} else { } else {
cur.BoardVoteRes.Pass = false cur.BoardVoteRes.Pass = false
} }
if cur.PubVote.Publicity {
if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计总票数
addr := "16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account, err := a.getStartHeightVoteAccount(addr, start)
if err != nil {
return nil, err
}
cur.PubVote.TotalVotes = int32(account.Balance/ticketPrice)
}
if cur.PubVote.TotalVotes != 0 &&
float32(cur.PubVote.OpposeVotes) / float32(cur.PubVote.TotalVotes) >= opposeRate {
cur.PubVote.PubPass = false
}
}
cur.PropProject.RealEndBlockHeight = a.height cur.PropProject.RealEndBlockHeight = a.height
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
......
...@@ -20,10 +20,12 @@ message VoteResult { ...@@ -20,10 +20,12 @@ message VoteResult {
message PublicVote { message PublicVote {
// 是否需要公示 // 是否需要公示
bool publicity = 1; bool publicity = 1;
// 总票数
int32 totalVotes = 2;
// 全体持票人反对票 // 全体持票人反对票
int32 opposeVotes = 2; int32 opposeVotes = 3;
// 是否通过 // 是否通过
bool pubPass = 3; bool pubPass = 4;
} }
message VotesRecord { message VotesRecord {
......
...@@ -59,10 +59,12 @@ func (m *VoteResult) GetPass() bool { ...@@ -59,10 +59,12 @@ func (m *VoteResult) GetPass() bool {
type PublicVote struct { type PublicVote struct {
// 是否需要公示 // 是否需要公示
Publicity bool `protobuf:"varint,1,opt,name=publicity" json:"publicity,omitempty"` Publicity bool `protobuf:"varint,1,opt,name=publicity" json:"publicity,omitempty"`
// 总票数
TotalVotes int32 `protobuf:"varint,2,opt,name=totalVotes" json:"totalVotes,omitempty"`
// 全体持票人反对票 // 全体持票人反对票
OpposeVotes int32 `protobuf:"varint,2,opt,name=opposeVotes" json:"opposeVotes,omitempty"` OpposeVotes int32 `protobuf:"varint,3,opt,name=opposeVotes" json:"opposeVotes,omitempty"`
// 是否通过 // 是否通过
PubPass bool `protobuf:"varint,3,opt,name=pubPass" json:"pubPass,omitempty"` PubPass bool `protobuf:"varint,4,opt,name=pubPass" json:"pubPass,omitempty"`
} }
func (m *PublicVote) Reset() { *m = PublicVote{} } func (m *PublicVote) Reset() { *m = PublicVote{} }
...@@ -77,6 +79,13 @@ func (m *PublicVote) GetPublicity() bool { ...@@ -77,6 +79,13 @@ func (m *PublicVote) GetPublicity() bool {
return false return false
} }
func (m *PublicVote) GetTotalVotes() int32 {
if m != nil {
return m.TotalVotes
}
return 0
}
func (m *PublicVote) GetOpposeVotes() int32 { func (m *PublicVote) GetOpposeVotes() int32 {
if m != nil { if m != nil {
return m.OpposeVotes return m.OpposeVotes
...@@ -116,18 +125,18 @@ func init() { ...@@ -116,18 +125,18 @@ func init() {
func init() { proto.RegisterFile("lcommon.proto", fileDescriptor2) } func init() { proto.RegisterFile("lcommon.proto", fileDescriptor2) }
var fileDescriptor2 = []byte{ var fileDescriptor2 = []byte{
// 205 bytes of a gzipped FileDescriptorProto // 204 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xcd, 0x4e, 0x85, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x3d, 0x6e, 0x84, 0x30,
0x10, 0x85, 0x53, 0x7e, 0x14, 0x06, 0xdd, 0x74, 0xc5, 0xc2, 0x18, 0xd2, 0x8d, 0xac, 0xdc, 0xf8, 0x10, 0x46, 0x65, 0x7e, 0x12, 0x18, 0x92, 0xc6, 0x15, 0x45, 0x14, 0x21, 0x9a, 0x50, 0xa5, 0xc9,
0x22, 0xa4, 0x0b, 0xf7, 0x05, 0x6a, 0x42, 0x52, 0x9c, 0x49, 0x5b, 0x4c, 0x78, 0x01, 0x9f, 0xdb, 0x45, 0x90, 0x8b, 0xf4, 0x06, 0x5c, 0x20, 0x99, 0xcc, 0xc8, 0x36, 0x91, 0xb8, 0x40, 0xce, 0x1d,
0x74, 0x94, 0xc8, 0xbd, 0x77, 0xd7, 0xf3, 0xe5, 0x6b, 0xce, 0xcc, 0xc0, 0xa3, 0x9b, 0x70, 0x5d, 0x79, 0x12, 0x04, 0xbb, 0x5b, 0x6c, 0x37, 0xdf, 0xd3, 0x2b, 0x9e, 0x06, 0x9e, 0xed, 0x88, 0xcb,
0xf1, 0xf3, 0x95, 0x3c, 0x46, 0x94, 0x65, 0xdc, 0xc9, 0x06, 0xf5, 0x2d, 0x00, 0xde, 0x31, 0x5a, 0x82, 0x5f, 0xef, 0xe4, 0x30, 0xa0, 0xcc, 0xc3, 0x46, 0xc6, 0xb7, 0x3f, 0x02, 0xe0, 0x13, 0x83,
0x6d, 0xc3, 0xe6, 0xa2, 0x7c, 0x06, 0x88, 0x18, 0x8d, 0x4b, 0x28, 0xb4, 0xa2, 0x13, 0x7d, 0xa9, 0x51, 0xc6, 0xaf, 0x36, 0xc8, 0x57, 0x80, 0x80, 0x41, 0xdb, 0x88, 0x7c, 0x2d, 0x1a, 0xd1, 0xe5,
0x4f, 0x44, 0x2a, 0x78, 0x30, 0x44, 0x1e, 0xbf, 0xec, 0xaf, 0x91, 0xb1, 0x71, 0xc1, 0x64, 0x07, 0xea, 0x44, 0x64, 0x0b, 0x4f, 0x9a, 0xc8, 0xe1, 0xb7, 0xf9, 0x33, 0x12, 0x36, 0x2e, 0x98, 0x6c,
0x0d, 0x12, 0x61, 0xf8, 0x53, 0x72, 0x56, 0xce, 0x48, 0x4a, 0x28, 0xc8, 0x84, 0xd0, 0x16, 0x9d, 0xa0, 0x42, 0x22, 0xf4, 0xff, 0x4a, 0xca, 0xca, 0x19, 0x49, 0x09, 0x19, 0x69, 0xef, 0xeb, 0xac,
0xe8, 0x2b, 0xcd, 0x6f, 0xf5, 0x01, 0x30, 0x6c, 0xa3, 0x5b, 0xa6, 0xa4, 0xc8, 0x27, 0xa8, 0x89, 0x11, 0x5d, 0xa1, 0xf8, 0xe6, 0x90, 0x7e, 0x1d, 0xec, 0x3c, 0x46, 0x47, 0xbe, 0x40, 0x49, 0xbc,
0xd3, 0x12, 0x77, 0x1e, 0xa3, 0xd2, 0xff, 0xe0, 0xba, 0x21, 0xbb, 0x6d, 0x68, 0xe1, 0x9e, 0xb6, 0xe6, 0xb0, 0x71, 0x47, 0xa1, 0x0e, 0x70, 0x95, 0x99, 0xdc, 0x64, 0xde, 0x4f, 0xa8, 0xe1, 0x91,
0x71, 0x48, 0x25, 0x39, 0xff, 0x3e, 0xa2, 0x7a, 0x81, 0x86, 0x15, 0x6d, 0x27, 0xf4, 0x73, 0x12, 0xd6, 0xa1, 0x3f, 0x2a, 0xf6, 0xd9, 0xbe, 0x41, 0xc5, 0x8a, 0x32, 0x23, 0xba, 0x29, 0x8a, 0x7a,
0xcd, 0x3c, 0x7b, 0x1b, 0xd2, 0xb6, 0x79, 0x5f, 0xeb, 0x23, 0x8e, 0x77, 0x7c, 0xa7, 0xb7, 0x9f, 0x9a, 0x9c, 0xf1, 0xf1, 0x1d, 0x69, 0x57, 0xaa, 0x7d, 0x0e, 0x0f, 0xfc, 0xc8, 0x8f, 0xdf, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xe3, 0x7b, 0x84, 0x76, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x86, 0x6a, 0x7e, 0x62, 0x59, 0x01, 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