Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
644a26e3
Commit
644a26e3
authored
Jul 12, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add prob project
parent
dba1186c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
86 deletions
+146
-86
boardaction.go
plugin/dapp/autonomy/executor/boardaction.go
+20
-18
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+97
-50
lcommon.proto
plugin/dapp/autonomy/proto/lcommon.proto
+4
-2
lcommon.pb.go
plugin/dapp/autonomy/types/lcommon.pb.go
+25
-16
No files found.
plugin/dapp/autonomy/executor/boardaction.go
View file @
644a26e3
...
...
@@ -160,6 +160,14 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
}
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
end
:=
cur
.
GetPropBoard
()
.
EndBlockHeight
real
:=
cur
.
GetPropBoard
()
.
RealEndBlockHeight
...
...
@@ -170,14 +178,6 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
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
value
,
err
=
a
.
db
.
Get
(
VotesRecord
(
voteProb
.
ProposalID
))
...
...
@@ -224,7 +224,9 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
var
logs
[]
*
types
.
ReceiptLog
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
{
cur
.
VoteResult
.
Pass
=
true
cur
.
PropBoard
.
RealEndBlockHeight
=
a
.
height
...
...
@@ -281,15 +283,6 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
}
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
{
err
:=
auty
.
ErrProposalStatus
...
...
@@ -298,6 +291,15 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
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
{
//需要统计票数
addr
:=
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account
,
err
:=
a
.
getStartHeightVoteAccount
(
addr
,
start
)
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
644a26e3
...
...
@@ -15,6 +15,7 @@ import (
const
(
largeAmount
=
types
.
Coin
*
100
*
10000
// 重大项目金额阈值
publicPeriod
=
120960
// 公示一周时间,以区块高度计算
opposeRate
=
float32
(
1
)
/
float32
(
3
)
// 反对率
)
...
...
@@ -141,6 +142,14 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
}
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
end
:=
cur
.
GetPropProject
()
.
EndBlockHeight
real
:=
cur
.
GetPropProject
()
.
RealEndBlockHeight
...
...
@@ -151,14 +160,6 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
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
())
if
err
!=
nil
{
...
...
@@ -225,11 +226,12 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
var
logs
[]
*
types
.
ReceiptLog
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
{
cur
.
BoardVoteRes
.
Pass
=
true
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
receipt
,
err
:=
a
.
coinsAccount
.
ExecTransferFrozen
(
cur
.
Address
,
autonomyAddr
,
a
.
execaddr
,
lockAmount
)
if
err
!=
nil
{
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
key
:=
propProjectID
(
voteProb
.
ProposalID
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
if
cur
.
BoardVoteRes
.
Pass
{
if
cur
.
PubVote
.
Publicity
{
// 进入公
视
if
cur
.
PubVote
.
Publicity
{
// 进入公
示
cur
.
Status
=
auty
.
AutonomyStatusPubVotePropProject
// 进入公示期默认为该提案通过,只有反对票达到三分之一才不会通过该提案
cur
.
PubVote
.
PubPass
=
true
}
else
{
cur
.
Status
=
auty
.
AutonomyStatusTmintPropProject
}
...
...
@@ -272,33 +276,33 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
// 获取GameID
value
,
err
:=
a
.
db
.
Get
(
propProjectID
(
voteProb
.
ProposalID
))
if
err
!=
nil
{
alog
.
Error
(
"
v
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"get propProjectID failed"
,
alog
.
Error
(
"
pubV
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"get propProjectID failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
var
cur
auty
.
AutonomyProposalProject
err
=
types
.
Decode
(
value
,
&
cur
)
if
err
!=
nil
{
alog
.
Error
(
"
v
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode AutonomyProposalProject failed"
,
alog
.
Error
(
"
pubV
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode AutonomyProposalProject failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
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
end
:=
cur
.
GetPropProject
()
.
EndBlockHeight
real
:=
cur
.
GetPropProject
()
.
RealEndBlockHeight
if
start
<
a
.
height
||
end
<
a
.
height
||
(
real
!=
0
&&
real
<
a
.
height
)
{
err
:=
auty
.
ErrVotePeriod
alog
.
Error
(
"votePropProject "
,
"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"
,
alog
.
Error
(
"pubVotePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"ProposalID"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
...
...
@@ -309,7 +313,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
if
err
==
nil
{
err
=
types
.
Decode
(
value
,
&
votes
)
if
err
!=
nil
{
alog
.
Error
(
"
v
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode VotesRecord failed"
,
alog
.
Error
(
"
pubV
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode VotesRecord failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
...
...
@@ -317,7 +321,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
for
_
,
addr
:=
range
votes
.
Address
{
if
addr
==
a
.
fromaddr
{
err
:=
auty
.
ErrRepeatVoteAddr
alog
.
Error
(
"
v
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"repeat address GameID"
,
alog
.
Error
(
"
pubV
otePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"repeat address GameID"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
...
...
@@ -325,36 +329,35 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
// 加入已经投票的
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
if
cur
.
GetBoardVoteRes
()
.
TotalVotes
==
0
{
//需要统计票数
if
cur
.
GetBoardVoteRes
()
.
TotalVotes
==
0
{
//需要统计
总
票数
addr
:=
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
account
,
err
:=
a
.
getStartHeightVoteAccount
(
addr
,
start
)
if
err
!=
nil
{
return
nil
,
err
}
cur
.
BoardVoteRes
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
cur
.
PubVote
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
}
// 获取该地址票数
account
,
err
:=
a
.
getStartHeightVoteAccount
(
a
.
fromaddr
,
start
)
if
err
!=
nil
{
return
nil
,
err
}
if
voteProb
.
voteProb
{
cur
.
BoardVoteRes
.
ApproveVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
else
{
cur
.
BoardVoteRes
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
if
voteProb
.
Oppose
{
//投反对票
cur
.
PubVote
.
OpposeVotes
+=
int32
(
account
.
Balance
/
ticketPrice
)
}
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
if
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
/
float32
(
cur
.
BoardVoteRes
.
TotalVotes
)
>=
participationRate
&&
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
)
/
float32
(
cur
.
BoardVoteRes
.
ApproveVotes
+
cur
.
BoardVoteRes
.
OpposeVotes
)
>=
approv
eRate
{
cur
.
BoardVoteRes
.
Pass
=
tru
e
if
cur
.
PubVote
.
TotalVotes
!=
0
&&
float32
(
cur
.
PubVote
.
OpposeVotes
)
/
float32
(
cur
.
PubVote
.
TotalVotes
)
>=
oppos
eRate
{
cur
.
PubVote
.
PubPass
=
fals
e
cur
.
PropProject
.
RealEndBlockHeight
=
a
.
height
receipt
,
err
:=
a
.
coinsAccount
.
ExecTransferFrozen
(
cur
.
Address
,
autonomyAddr
,
a
.
execaddr
,
lockAmount
)
if
err
!=
nil
{
alog
.
Error
(
"
v
otePropProject "
,
"addr"
,
cur
.
Address
,
"execaddr"
,
a
.
execaddr
,
"ExecTransferFrozen amount fail"
,
err
)
alog
.
Error
(
"
pubV
otePropProject "
,
"addr"
,
cur
.
Address
,
"execaddr"
,
a
.
execaddr
,
"ExecTransferFrozen amount fail"
,
err
)
return
nil
,
err
}
logs
=
append
(
logs
,
receipt
.
Logs
...
)
...
...
@@ -362,8 +365,8 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
}
key
:=
propProjectID
(
voteProb
.
ProposalID
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
if
cur
.
BoardVoteRes
.
Pass
{
cur
.
Status
=
auty
.
AutonomyStatus
Pub
VotePropProject
if
!
cur
.
PubVote
.
Pub
Pass
{
cur
.
Status
=
auty
.
AutonomyStatusTmintPropProject
}
value
=
types
.
Encode
(
&
cur
)
...
...
@@ -372,7 +375,7 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
// 更新VotesRecord
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
VotesRecord
(
voteProb
.
ProposalID
),
Value
:
types
.
Encode
(
&
votes
)})
ty
:=
auty
.
TyLogVotePropProject
ty
:=
auty
.
TyLog
Pub
VotePropProject
if
cur
.
BoardVoteRes
.
Pass
{
ty
=
auty
.
TyLogTmintPropProject
}
...
...
@@ -399,15 +402,6 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
}
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
{
err
:=
auty
.
ErrProposalStatus
...
...
@@ -416,21 +410,74 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
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
{
//需要统计票数
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
}
cur
.
BoardVoteRes
.
TotalVotes
=
int32
(
account
.
Balance
/
ticketPrice
)
prob
:=
&
auty
.
ProposalBoard
{}
err
=
types
.
Decode
(
value
,
prob
)
if
err
!=
nil
{
alog
.
Error
(
"tmintPropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode ProposalBoard failed"
,
tmintProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
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
{
cur
.
BoardVoteRes
.
Pass
=
true
}
else
{
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
var
logs
[]
*
types
.
ReceiptLog
...
...
plugin/dapp/autonomy/proto/lcommon.proto
View file @
644a26e3
...
...
@@ -20,10 +20,12 @@ message VoteResult {
message
PublicVote
{
// 是否需要公示
bool
publicity
=
1
;
// 总票数
int32
totalVotes
=
2
;
// 全体持票人反对票
int32
opposeVotes
=
2
;
int32
opposeVotes
=
3
;
// 是否通过
bool
pubPass
=
3
;
bool
pubPass
=
4
;
}
message
VotesRecord
{
...
...
plugin/dapp/autonomy/types/lcommon.pb.go
View file @
644a26e3
...
...
@@ -59,10 +59,12 @@ func (m *VoteResult) GetPass() bool {
type
PublicVote
struct
{
// 是否需要公示
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
{}
}
...
...
@@ -77,6 +79,13 @@ func (m *PublicVote) GetPublicity() bool {
return
false
}
func
(
m
*
PublicVote
)
GetTotalVotes
()
int32
{
if
m
!=
nil
{
return
m
.
TotalVotes
}
return
0
}
func
(
m
*
PublicVote
)
GetOpposeVotes
()
int32
{
if
m
!=
nil
{
return
m
.
OpposeVotes
...
...
@@ -116,18 +125,18 @@ func init() {
func
init
()
{
proto
.
RegisterFile
(
"lcommon.proto"
,
fileDescriptor2
)
}
var
fileDescriptor2
=
[]
byte
{
// 20
5
bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x
64
,
0x90
,
0xcd
,
0x4e
,
0x85
,
0x30
,
0x10
,
0x
85
,
0x53
,
0x7e
,
0x14
,
0x06
,
0xdd
,
0x74
,
0xc5
,
0xc2
,
0x18
,
0xd2
,
0x8d
,
0xac
,
0xdc
,
0xf8
,
0x
22
,
0xa4
,
0x0b
,
0xf7
,
0x05
,
0x6a
,
0x42
,
0x52
,
0x9c
,
0x49
,
0x5b
,
0x4c
,
0x78
,
0x01
,
0x9f
,
0xdb
,
0x7
4
,
0x94
,
0xc8
,
0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x64
,
0xde
,
0x4f
,
0xa8
,
0xe1
,
0x91
,
0x
d6
,
0xa1
,
0x3f
,
0x2a
,
0xf6
,
0xd9
,
0xbe
,
0x41
,
0xc5
,
0x8a
,
0x32
,
0x23
,
0xba
,
0x29
,
0x8a
,
0x7a
,
0x
9a
,
0x9c
,
0xf1
,
0xf1
,
0x1d
,
0x69
,
0x57
,
0xaa
,
0x7d
,
0x0e
,
0x0f
,
0xfc
,
0xc8
,
0x8f
,
0xdf
,
0x00
,
0x00
,
0x00
,
0x
ff
,
0xff
,
0x86
,
0x6a
,
0x7e
,
0x62
,
0x59
,
0x01
,
0x00
,
0x00
,
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment