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
4016e4d3
Commit
4016e4d3
authored
Jul 21, 2021
by
mdj33
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved by issue specification
parent
2b013042
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
237 additions
and
38 deletions
+237
-38
boardaction.go
plugin/dapp/autonomy/executor/boardaction.go
+0
-0
changeaction.go
plugin/dapp/autonomy/executor/changeaction.go
+100
-17
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+18
-3
ruleaction.go
plugin/dapp/autonomy/executor/ruleaction.go
+75
-18
board.proto
plugin/dapp/autonomy/proto/board.proto
+17
-0
change.proto
plugin/dapp/autonomy/proto/change.proto
+1
-0
lcommon.proto
plugin/dapp/autonomy/proto/lcommon.proto
+18
-0
project.proto
plugin/dapp/autonomy/proto/project.proto
+1
-0
rule.proto
plugin/dapp/autonomy/proto/rule.proto
+1
-0
types.go
plugin/dapp/autonomy/types/types.go
+6
-0
No files found.
plugin/dapp/autonomy/executor/boardaction.go
View file @
4016e4d3
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/executor/changeaction.go
View file @
4016e4d3
...
@@ -7,6 +7,8 @@ package executor
...
@@ -7,6 +7,8 @@ package executor
import
(
import
(
"sort"
"sort"
"github.com/pkg/errors"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
...
@@ -30,11 +32,21 @@ func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) {
...
@@ -30,11 +32,21 @@ func (a *action) propChange(prob *auty.ProposalChange) (*types.Receipt, error) {
alog
.
Error
(
"propChange "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getActiveBoard failed"
,
err
)
alog
.
Error
(
"propChange "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"getActiveBoard failed"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
// 检查是否符合提案修改
// 检查是否符合提案修改
new
,
err
:=
a
.
checkChangeable
(
act
,
prob
.
Changes
)
var
new
*
auty
.
ActiveBoard
if
err
!=
nil
{
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
alog
.
Error
(
"propChange "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"checkChangeable failed"
,
err
)
//替换成员方案
return
nil
,
err
new
,
err
=
a
.
replaceBoard
(
act
,
prob
.
Changes
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
new
,
err
=
a
.
checkChangeable
(
act
,
prob
.
Changes
)
if
err
!=
nil
{
alog
.
Error
(
"propChange "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"checkChangeable failed"
,
err
)
return
nil
,
err
}
}
}
// 获取当前生效提案规则,并且将不修改的规则补齐
// 获取当前生效提案规则,并且将不修改的规则补齐
...
@@ -167,20 +179,32 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
...
@@ -167,20 +179,32 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
return
nil
,
err
return
nil
,
err
}
}
// 董事会成员验证
cfg
:=
a
.
api
.
GetConfig
()
// 董事会成员验证,把剔除的原成员放回来
mpBd
:=
make
(
map
[
string
]
struct
{})
mpBd
:=
make
(
map
[
string
]
struct
{})
for
_
,
b
:=
range
cur
.
Board
.
Boards
{
if
cfg
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
mpBd
[
b
]
=
struct
{}{}
for
_
,
b
:=
range
cur
.
Board
.
Boards
{
}
if
b
==
cur
.
PropChange
.
Changes
[
0
]
.
Addr
{
for
_
,
ch
:=
range
cur
.
PropChange
.
Changes
{
mpBd
[
cur
.
Address
]
=
struct
{}{}
if
ch
.
Cancel
{
continue
mpBd
[
ch
.
Addr
]
=
struct
{}{}
}
}
else
{
mpBd
[
b
]
=
struct
{}{}
if
_
,
ok
:=
mpBd
[
ch
.
Addr
];
ok
{
}
delete
(
mpBd
,
ch
.
Addr
)
}
else
{
for
_
,
b
:=
range
cur
.
Board
.
Boards
{
mpBd
[
b
]
=
struct
{}{}
}
for
_
,
ch
:=
range
cur
.
PropChange
.
Changes
{
if
ch
.
Cancel
{
mpBd
[
ch
.
Addr
]
=
struct
{}{}
}
else
{
if
_
,
ok
:=
mpBd
[
ch
.
Addr
];
ok
{
delete
(
mpBd
,
ch
.
Addr
)
}
}
}
}
}
}
}
if
_
,
ok
:=
mpBd
[
a
.
fromaddr
];
!
ok
{
if
_
,
ok
:=
mpBd
[
a
.
fromaddr
];
!
ok
{
err
=
auty
.
ErrNoActiveBoard
err
=
auty
.
ErrNoActiveBoard
alog
.
Error
(
"votePropChange "
,
"addr"
,
a
.
fromaddr
,
"this addr is not active board member"
,
alog
.
Error
(
"votePropChange "
,
"addr"
,
a
.
fromaddr
,
"this addr is not active board member"
,
...
@@ -191,10 +215,23 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
...
@@ -191,10 +215,23 @@ func (a *action) votePropChange(voteProb *auty.VoteProposalChange) (*types.Recei
// 更新投票记录
// 更新投票记录
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
if
voteProb
.
Approve
{
if
cfg
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
cur
.
VoteResult
.
ApproveVotes
++
switch
voteProb
.
Vote
{
case
auty
.
VoteOption_APPROVE
:
cur
.
VoteResult
.
ApproveVotes
++
case
auty
.
VoteOption_OPPOSE
:
cur
.
VoteResult
.
OpposeVotes
++
case
auty
.
VoteOption_QUIT
:
cur
.
VoteResult
.
QuitVotes
++
default
:
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"vote option=%d"
,
voteProb
.
Vote
)
}
}
else
{
}
else
{
cur
.
VoteResult
.
OpposeVotes
++
if
voteProb
.
Approve
{
cur
.
VoteResult
.
ApproveVotes
++
}
else
{
cur
.
VoteResult
.
OpposeVotes
++
}
}
}
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
...
@@ -319,6 +356,52 @@ func (a *action) getProposalChange(ID string) (*auty.AutonomyProposalChange, err
...
@@ -319,6 +356,52 @@ func (a *action) getProposalChange(ID string) (*auty.AutonomyProposalChange, err
return
cur
,
nil
return
cur
,
nil
}
}
//新的方案只允许替换board里面的成员,而且是本用户申请,不允许从revBoard恢复
func
(
a
*
action
)
replaceBoard
(
act
*
auty
.
ActiveBoard
,
change
[]
*
auty
.
Change
)
(
*
auty
.
ActiveBoard
,
error
)
{
//一个成员只允许替换一个新的
if
len
(
change
)
>
1
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"only allow one addr to be replaced,change=%d"
,
len
(
change
))
}
//只允许替换,不允许恢复操作
if
!
change
[
0
]
.
Cancel
||
len
(
change
[
0
]
.
Addr
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"cancel=%d not allow to addr=%s"
,
change
[
0
]
.
Cancel
,
change
[
0
]
.
Addr
)
}
mpBd
:=
make
(
map
[
string
]
struct
{})
mpRbd
:=
make
(
map
[
string
]
struct
{})
for
_
,
b
:=
range
act
.
Boards
{
mpBd
[
b
]
=
struct
{}{}
}
for
_
,
b
:=
range
act
.
Revboards
{
mpRbd
[
b
]
=
struct
{}{}
}
//发起者必须是董事会成员
if
_
,
ok
:=
mpBd
[
a
.
fromaddr
];
!
ok
{
return
nil
,
errors
.
Wrap
(
types
.
ErrNotAllow
,
"from addr should be in boards"
)
}
//待替换地址不能在board和revBoard里面
if
_
,
ok
:=
mpBd
[
change
[
0
]
.
Addr
];
ok
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"new addr=%s in boards"
,
change
[
0
]
.
Addr
)
}
if
_
,
ok
:=
mpRbd
[
change
[
0
]
.
Addr
];
ok
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"new addr=%s in rev boards"
,
change
[
0
]
.
Addr
)
}
//替换board
for
i
,
k
:=
range
act
.
Boards
{
if
k
==
a
.
fromaddr
{
act
.
Boards
[
i
]
=
change
[
0
]
.
Addr
break
}
}
//当前地址追加到revBoards
act
.
Revboards
=
append
(
act
.
Revboards
,
a
.
fromaddr
)
return
act
,
nil
}
func
(
a
*
action
)
checkChangeable
(
act
*
auty
.
ActiveBoard
,
change
[]
*
auty
.
Change
)
(
*
auty
.
ActiveBoard
,
error
)
{
func
(
a
*
action
)
checkChangeable
(
act
*
auty
.
ActiveBoard
,
change
[]
*
auty
.
Change
)
(
*
auty
.
ActiveBoard
,
error
)
{
mpBd
:=
make
(
map
[
string
]
struct
{})
mpBd
:=
make
(
map
[
string
]
struct
{})
mpRbd
:=
make
(
map
[
string
]
struct
{})
mpRbd
:=
make
(
map
[
string
]
struct
{})
...
...
plugin/dapp/autonomy/executor/projectaction.go
View file @
4016e4d3
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
)
)
...
@@ -217,11 +218,25 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
...
@@ -217,11 +218,25 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
// 更新已经投票地址
// 更新已经投票地址
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
// 更新投票结果
// 更新投票结果
if
voteProb
.
Approve
{
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
cur
.
BoardVoteRes
.
ApproveVotes
++
switch
voteProb
.
Vote
{
case
auty
.
VoteOption_APPROVE
:
cur
.
BoardVoteRes
.
ApproveVotes
++
case
auty
.
VoteOption_OPPOSE
:
cur
.
BoardVoteRes
.
OpposeVotes
++
case
auty
.
VoteOption_QUIT
:
cur
.
BoardVoteRes
.
QuitVotes
++
default
:
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"vote option=%d"
,
voteProb
.
Vote
)
}
}
else
{
}
else
{
cur
.
BoardVoteRes
.
OpposeVotes
++
if
voteProb
.
Approve
{
cur
.
BoardVoteRes
.
ApproveVotes
++
}
else
{
cur
.
BoardVoteRes
.
OpposeVotes
++
}
}
}
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
...
...
plugin/dapp/autonomy/executor/ruleaction.go
View file @
4016e4d3
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/pkg/errors"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
...
@@ -18,10 +19,23 @@ const (
...
@@ -18,10 +19,23 @@ const (
minBoardApproveRatio
=
50
minBoardApproveRatio
=
50
// 最大董事会赞成率
// 最大董事会赞成率
maxBoardApproveRatio
=
66
maxBoardApproveRatio
=
66
// 最小全体持票人否决率
// 最小全体持票人否决率
minPubOpposeRatio
=
33
minPubOpposeRatio
=
33
// 最大全体持票人否决率
// 最大全体持票人否决率
maxPubOpposeRatio
=
50
maxPubOpposeRatio
=
50
//不能设置太低和太高,太低就容易作弊,太高则有可能很难达到
// 最小全体持票人参与率
minPubAttendRatio
=
50
// 最大全体持票人参与率
maxPubAttendRatio
=
80
// 最小全体持票人赞成率
minPubApproveRatio
=
50
// 最大全体持票人赞成率
maxPubApproveRatio
=
80
// 最小公示周期
// 最小公示周期
minPublicPeriod
int32
=
17280
*
7
minPublicPeriod
int32
=
17280
*
7
// 最大公示周期
// 最大公示周期
...
@@ -36,6 +50,13 @@ const (
...
@@ -36,6 +50,13 @@ const (
maxProposalAmount
=
2000
maxProposalAmount
=
2000
)
)
func
checkParaInvalid
(
param
,
min
,
max
int64
)
bool
{
if
param
>
0
&&
((
param
>
max
)
||
param
<
min
)
{
return
true
}
return
false
}
func
(
a
*
action
)
propRule
(
prob
*
auty
.
ProposalRule
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
propRule
(
prob
*
auty
.
ProposalRule
)
(
*
types
.
Receipt
,
error
)
{
cfg
:=
a
.
api
.
GetConfig
()
cfg
:=
a
.
api
.
GetConfig
()
//如果全小于等于0,则说明该提案规则参数不正确
//如果全小于等于0,则说明该提案规则参数不正确
...
@@ -44,11 +65,13 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
...
@@ -44,11 +65,13 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
alog
.
Error
(
"propRule "
,
"ProposalRule RuleCfg invaild or have no modify param"
,
prob
.
RuleCfg
)
alog
.
Error
(
"propRule "
,
"ProposalRule RuleCfg invaild or have no modify param"
,
prob
.
RuleCfg
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
if
(
prob
.
RuleCfg
.
BoardApproveRatio
>
0
&&
(
prob
.
RuleCfg
.
BoardApproveRatio
>
maxBoardApproveRatio
||
prob
.
RuleCfg
.
BoardApproveRatio
<
minBoardApproveRatio
))
||
if
checkParaInvalid
(
int64
(
prob
.
RuleCfg
.
BoardApproveRatio
),
minBoardApproveRatio
,
maxBoardApproveRatio
)
||
(
prob
.
RuleCfg
.
PubOpposeRatio
>
0
&&
(
prob
.
RuleCfg
.
PubOpposeRatio
>
maxPubOpposeRatio
||
prob
.
RuleCfg
.
PubOpposeRatio
<
minPubOpposeRatio
))
||
checkParaInvalid
(
int64
(
prob
.
RuleCfg
.
PubOpposeRatio
),
minPubOpposeRatio
,
maxPubOpposeRatio
)
||
(
prob
.
RuleCfg
.
PublicPeriod
>
0
&&
(
prob
.
RuleCfg
.
PublicPeriod
>
maxPublicPeriod
||
prob
.
RuleCfg
.
PublicPeriod
<
minPublicPeriod
))
||
checkParaInvalid
(
int64
(
prob
.
RuleCfg
.
PublicPeriod
),
int64
(
minPublicPeriod
),
int64
(
maxPublicPeriod
))
||
(
prob
.
RuleCfg
.
LargeProjectAmount
>
0
&&
(
prob
.
RuleCfg
.
LargeProjectAmount
>
maxLargeProjectAmount
*
cfg
.
GetCoinPrecision
()
||
prob
.
RuleCfg
.
LargeProjectAmount
<
minLargeProjectAmount
*
cfg
.
GetCoinPrecision
()))
||
checkParaInvalid
(
prob
.
RuleCfg
.
LargeProjectAmount
,
minLargeProjectAmount
*
cfg
.
GetCoinPrecision
(),
maxLargeProjectAmount
*
cfg
.
GetCoinPrecision
())
||
(
prob
.
RuleCfg
.
ProposalAmount
>
0
&&
(
prob
.
RuleCfg
.
ProposalAmount
>
maxProposalAmount
*
cfg
.
GetCoinPrecision
()
||
prob
.
RuleCfg
.
ProposalAmount
<
minProposalAmount
*
cfg
.
GetCoinPrecision
()))
{
checkParaInvalid
(
prob
.
RuleCfg
.
ProposalAmount
,
minProposalAmount
*
cfg
.
GetCoinPrecision
(),
maxProposalAmount
*
cfg
.
GetCoinPrecision
())
||
checkParaInvalid
(
int64
(
prob
.
RuleCfg
.
PubAttendRatio
),
minPubAttendRatio
,
maxPubAttendRatio
)
||
checkParaInvalid
(
int64
(
prob
.
RuleCfg
.
PubApproveRatio
),
minPubApproveRatio
,
maxPubApproveRatio
)
{
alog
.
Error
(
"propRule RuleCfg invaild"
,
"ruleCfg"
,
prob
.
RuleCfg
)
alog
.
Error
(
"propRule RuleCfg invaild"
,
"ruleCfg"
,
prob
.
RuleCfg
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
...
@@ -230,10 +253,24 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
...
@@ -230,10 +253,24 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
voteProb
.
ProposalID
,
"err"
,
err
)
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
if
voteProb
.
Approve
{
cfg
:=
a
.
api
.
GetConfig
()
cur
.
VoteResult
.
ApproveVotes
+=
vtCouts
if
cfg
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
switch
voteProb
.
Vote
{
case
auty
.
VoteOption_APPROVE
:
cur
.
VoteResult
.
ApproveVotes
+=
vtCouts
case
auty
.
VoteOption_OPPOSE
:
cur
.
VoteResult
.
OpposeVotes
+=
vtCouts
case
auty
.
VoteOption_QUIT
:
cur
.
VoteResult
.
QuitVotes
+=
vtCouts
default
:
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"wrong vote value=%d"
,
voteProb
.
Vote
)
}
}
else
{
}
else
{
cur
.
VoteResult
.
OpposeVotes
+=
vtCouts
if
voteProb
.
Approve
{
cur
.
VoteResult
.
ApproveVotes
+=
vtCouts
}
else
{
cur
.
VoteResult
.
OpposeVotes
+=
vtCouts
}
}
}
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
...
@@ -250,12 +287,20 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
...
@@ -250,12 +287,20 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
}
}
if
cur
.
VoteResult
.
TotalVotes
!=
0
&&
if
cfg
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
!=
0
&&
if
isApproved
(
cur
.
VoteResult
.
TotalVotes
,
cur
.
VoteResult
.
ApproveVotes
,
cur
.
VoteResult
.
OpposeVotes
,
cur
.
VoteResult
.
QuitVotes
,
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>
float32
(
pubAttendRatio
)
/
100.0
&&
cur
.
CurRule
.
PubAttendRatio
,
cur
.
CurRule
.
PubApproveRatio
)
{
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
cur
.
VoteResult
.
Pass
=
true
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
}
}
else
{
if
cur
.
VoteResult
.
TotalVotes
!=
0
&&
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
!=
0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
}
}
}
key
:=
propRuleID
(
voteProb
.
ProposalID
)
key
:=
propRuleID
(
voteProb
.
ProposalID
)
...
@@ -320,11 +365,16 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
...
@@ -320,11 +365,16 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
cur
.
VoteResult
.
TotalVotes
=
vtCouts
cur
.
VoteResult
.
TotalVotes
=
vtCouts
}
}
if
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>
float32
(
pubAttendRatio
)
/
100.0
&&
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
auty
.
AutonomyX
,
auty
.
ForkAutonomyDelRule
)
{
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
isApproved
(
cur
.
VoteResult
.
TotalVotes
,
cur
.
VoteResult
.
ApproveVotes
,
cur
.
VoteResult
.
OpposeVotes
,
cur
.
VoteResult
.
QuitVotes
,
cur
.
VoteResult
.
Pass
=
true
cur
.
CurRule
.
PubAttendRatio
,
cur
.
CurRule
.
PubApproveRatio
)
}
else
{
}
else
{
cur
.
VoteResult
.
Pass
=
false
if
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
/
float32
(
cur
.
VoteResult
.
TotalVotes
)
>
float32
(
pubAttendRatio
)
/
100.0
&&
float32
(
cur
.
VoteResult
.
ApproveVotes
)
/
float32
(
cur
.
VoteResult
.
ApproveVotes
+
cur
.
VoteResult
.
OpposeVotes
)
>
float32
(
pubApproveRatio
)
/
100.0
{
cur
.
VoteResult
.
Pass
=
true
}
else
{
cur
.
VoteResult
.
Pass
=
false
}
}
}
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
cur
.
PropRule
.
RealEndBlockHeight
=
a
.
height
...
@@ -466,5 +516,12 @@ func upgradeRule(cur, modify *auty.RuleConfig) *auty.RuleConfig {
...
@@ -466,5 +516,12 @@ func upgradeRule(cur, modify *auty.RuleConfig) *auty.RuleConfig {
if
modify
.
PublicPeriod
>
0
{
if
modify
.
PublicPeriod
>
0
{
new
.
PublicPeriod
=
modify
.
PublicPeriod
new
.
PublicPeriod
=
modify
.
PublicPeriod
}
}
if
modify
.
PubAttendRatio
>
0
{
new
.
PubAttendRatio
=
modify
.
PubAttendRatio
}
if
modify
.
PubApproveRatio
>
0
{
new
.
PubApproveRatio
=
modify
.
PubApproveRatio
}
return
&
new
return
&
new
}
}
plugin/dapp/autonomy/proto/board.proto
View file @
4016e4d3
...
@@ -25,6 +25,16 @@ message AutonomyProposalBoard {
...
@@ -25,6 +25,16 @@ message AutonomyProposalBoard {
string
proposalID
=
9
;
string
proposalID
=
9
;
}
}
enum
BoardUpdate
{
INV
=
0
;
//新增
ADD
=
1
;
//剔除
DEL
=
2
;
//整体替换
WHOLE
=
3
;
}
// action
// action
message
ProposalBoard
{
message
ProposalBoard
{
// 提案时间
// 提案时间
...
@@ -41,6 +51,10 @@ message ProposalBoard {
...
@@ -41,6 +51,10 @@ message ProposalBoard {
int64
startBlockHeight
=
6
;
// 提案开始投票高度
int64
startBlockHeight
=
6
;
// 提案开始投票高度
int64
endBlockHeight
=
7
;
// 提案结束投票高度
int64
endBlockHeight
=
7
;
// 提案结束投票高度
int64
realEndBlockHeight
=
8
;
// 实际提案结束投票高度
int64
realEndBlockHeight
=
8
;
// 实际提案结束投票高度
//代替update,并扩展
BoardUpdate
boardUpdate
=
9
;
}
}
message
RevokeProposalBoard
{
message
RevokeProposalBoard
{
...
@@ -50,7 +64,10 @@ message RevokeProposalBoard {
...
@@ -50,7 +64,10 @@ message RevokeProposalBoard {
message
VoteProposalBoard
{
message
VoteProposalBoard
{
string
proposalID
=
1
;
string
proposalID
=
1
;
bool
approve
=
2
;
bool
approve
=
2
;
//真正投票地址
repeated
string
originAddr
=
3
;
repeated
string
originAddr
=
3
;
//代替approve,并增加了弃权选项
VoteOption
voteOption
=
4
;
}
}
message
TerminateProposalBoard
{
message
TerminateProposalBoard
{
...
...
plugin/dapp/autonomy/proto/change.proto
View file @
4016e4d3
...
@@ -54,6 +54,7 @@ message RevokeProposalChange {
...
@@ -54,6 +54,7 @@ message RevokeProposalChange {
message
VoteProposalChange
{
message
VoteProposalChange
{
string
proposalID
=
1
;
string
proposalID
=
1
;
bool
approve
=
2
;
bool
approve
=
2
;
VoteOption
vote
=
3
;
}
}
message
TerminateProposalChange
{
message
TerminateProposalChange
{
...
...
plugin/dapp/autonomy/proto/lcommon.proto
View file @
4016e4d3
...
@@ -16,6 +16,8 @@ message VoteResult {
...
@@ -16,6 +16,8 @@ message VoteResult {
int32
opposeVotes
=
3
;
int32
opposeVotes
=
3
;
// 是否通过
// 是否通过
bool
pass
=
4
;
bool
pass
=
4
;
//弃权票
int32
quitVotes
=
5
;
}
}
message
PublicVote
{
message
PublicVote
{
...
@@ -44,6 +46,22 @@ message RuleConfig {
...
@@ -44,6 +46,22 @@ message RuleConfig {
int64
largeProjectAmount
=
4
;
int64
largeProjectAmount
=
4
;
// 重大项目公示时间(以区块数为单位)
// 重大项目公示时间(以区块数为单位)
int32
publicPeriod
=
5
;
int32
publicPeriod
=
5
;
// 全体持票人参与率
int32
pubAttendRatio
=
6
;
// 全体持票人赞成率
int32
pubApproveRatio
=
7
;
}
//三种投票选项
enum
VoteOption
{
INVALID
=
0
;
//支持
APPROVE
=
1
;
//反对
OPPOSE
=
2
;
//弃权
QUIT
=
3
;
}
}
message
ActiveBoard
{
message
ActiveBoard
{
...
...
plugin/dapp/autonomy/proto/project.proto
View file @
4016e4d3
...
@@ -59,6 +59,7 @@ message RevokeProposalProject {
...
@@ -59,6 +59,7 @@ message RevokeProposalProject {
message
VoteProposalProject
{
message
VoteProposalProject
{
string
proposalID
=
1
;
string
proposalID
=
1
;
bool
approve
=
2
;
bool
approve
=
2
;
VoteOption
vote
=
3
;
}
}
message
PubVoteProposalProject
{
message
PubVoteProposalProject
{
...
...
plugin/dapp/autonomy/proto/rule.proto
View file @
4016e4d3
...
@@ -44,6 +44,7 @@ message VoteProposalRule {
...
@@ -44,6 +44,7 @@ message VoteProposalRule {
string
proposalID
=
1
;
string
proposalID
=
1
;
bool
approve
=
2
;
bool
approve
=
2
;
repeated
string
originAddr
=
3
;
repeated
string
originAddr
=
3
;
VoteOption
vote
=
4
;
}
}
message
TerminateProposalRule
{
message
TerminateProposalRule
{
...
...
plugin/dapp/autonomy/types/types.go
View file @
4016e4d3
...
@@ -12,6 +12,11 @@ import (
...
@@ -12,6 +12,11 @@ import (
var
name
string
var
name
string
var
(
//ForkAutonomyDelRule fork for delete boards member rules
ForkAutonomyDelRule
=
"ForkAutonomyDelRule"
)
func
init
()
{
func
init
()
{
name
=
AutonomyX
name
=
AutonomyX
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
name
))
types
.
AllowUserExec
=
append
(
types
.
AllowUserExec
,
[]
byte
(
name
))
...
@@ -22,6 +27,7 @@ func init() {
...
@@ -22,6 +27,7 @@ func init() {
//InitFork ...
//InitFork ...
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
AutonomyX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
AutonomyX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
AutonomyX
,
ForkAutonomyDelRule
,
9500000
)
}
}
//InitExecutor ...
//InitExecutor ...
...
...
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