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)
......
...@@ -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, 0x9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, 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