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
c4b89c92
Commit
c4b89c92
authored
Jul 15, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add prob project
parent
644a26e3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
211 additions
and
43 deletions
+211
-43
board.go
plugin/dapp/autonomy/executor/board.go
+4
-4
exec_local.go
plugin/dapp/autonomy/executor/exec_local.go
+23
-0
project.go
plugin/dapp/autonomy/executor/project.go
+134
-0
projectaction.go
plugin/dapp/autonomy/executor/projectaction.go
+23
-27
query.go
plugin/dapp/autonomy/executor/query.go
+7
-1
project.proto
plugin/dapp/autonomy/proto/project.proto
+17
-10
rpc.go
plugin/dapp/autonomy/rpc/rpc.go
+2
-0
autonomy.pb.go
plugin/dapp/autonomy/types/autonomy.pb.go
+1
-1
project.pb.go
plugin/dapp/autonomy/types/project.pb.go
+0
-0
No files found.
plugin/dapp/autonomy/executor/board.go
View file @
c4b89c92
...
...
@@ -26,7 +26,7 @@ func (a *Autonomy) execLocalBoard(receiptData *types.ReceiptData) (*types.LocalD
if
err
!=
nil
{
return
nil
,
err
}
kv
:=
saveHeightIndex
(
&
receipt
)
kv
:=
save
Board
HeightIndex
(
&
receipt
)
set
=
append
(
set
,
kv
...
)
}
default
:
...
...
@@ -37,7 +37,7 @@ func (a *Autonomy) execLocalBoard(receiptData *types.ReceiptData) (*types.LocalD
return
dbSet
,
nil
}
func
saveHeightIndex
(
res
*
auty
.
ReceiptProposalBoard
)
(
kvs
[]
*
types
.
KeyValue
)
{
func
save
Board
HeightIndex
(
res
*
auty
.
ReceiptProposalBoard
)
(
kvs
[]
*
types
.
KeyValue
)
{
// 先将之前的状态删除掉,再做更新
if
res
.
Current
.
Status
>
1
{
kv
:=
&
types
.
KeyValue
{}
...
...
@@ -68,7 +68,7 @@ func (a *Autonomy) execDelLocalBoard(receiptData *types.ReceiptData) (*types.Loc
if
err
!=
nil
{
return
nil
,
err
}
kv
:=
delHeightIndex
(
&
receipt
)
kv
:=
del
Board
HeightIndex
(
&
receipt
)
set
=
append
(
set
,
kv
...
)
}
default
:
...
...
@@ -79,7 +79,7 @@ func (a *Autonomy) execDelLocalBoard(receiptData *types.ReceiptData) (*types.Loc
return
dbSet
,
nil
}
func
delHeightIndex
(
res
*
auty
.
ReceiptProposalBoard
)
(
kvs
[]
*
types
.
KeyValue
)
{
func
del
Board
HeightIndex
(
res
*
auty
.
ReceiptProposalBoard
)
(
kvs
[]
*
types
.
KeyValue
)
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcBoardKey4StatusHeight
(
res
.
Current
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Current
.
Height
,
int64
(
res
.
Current
.
Index
)))
kv
.
Value
=
nil
...
...
plugin/dapp/autonomy/executor/exec_local.go
View file @
c4b89c92
...
...
@@ -9,6 +9,7 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
// 提案董事会相关
// ExecLocal_PropBoard 创建提案
func
(
a
*
Autonomy
)
ExecLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalBoard
(
receiptData
)
...
...
@@ -28,3 +29,24 @@ func (a *Autonomy) ExecLocal_VotePropBoard(payload *auty.VoteProposalBoard, tx *
func
(
a
*
Autonomy
)
ExecLocal_TmintPropBoard
(
payload
*
auty
.
TerminateProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalBoard
(
receiptData
)
}
// 提案项目相关
// ExecLocal_PropProject 创建提案项目
func
(
a
*
Autonomy
)
ExecLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalProject
(
receiptData
)
}
// ExecLocal_RvkPropProject 撤销提案项目
func
(
a
*
Autonomy
)
ExecLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
){
return
a
.
execLocalProject
(
receiptData
)
}
// ExecLocal_VotePropProject 投票提案项目
func
(
a
*
Autonomy
)
ExecLocal_VotePropProject
(
payload
*
auty
.
VoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalProject
(
receiptData
)
}
// ExecLocal_TmintPropProject 终止提案项目
func
(
a
*
Autonomy
)
ExecLocal_TmintPropProject
(
payload
*
auty
.
TerminateProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
a
.
execLocalProject
(
receiptData
)
}
\ No newline at end of file
plugin/dapp/autonomy/executor/project.go
0 → 100644
View file @
c4b89c92
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
executor
import
(
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
func
(
a
*
Autonomy
)
execLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
case
auty
.
TyLogPropProject
,
auty
.
TyLogRvkPropProject
,
auty
.
TyLogVotePropProject
,
auty
.
TyLogPubVotePropProject
,
auty
.
TyLogTmintPropProject
:
{
var
receipt
auty
.
ReceiptProposalProject
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
return
nil
,
err
}
kv
:=
saveProjectHeightIndex
(
&
receipt
)
set
=
append
(
set
,
kv
...
)
}
default
:
break
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
set
...
)
return
dbSet
,
nil
}
func
saveProjectHeightIndex
(
res
*
auty
.
ReceiptProposalProject
)
(
kvs
[]
*
types
.
KeyValue
)
{
// 先将之前的状态删除掉,再做更新
if
res
.
Current
.
Status
>
1
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcProjectKey4StatusHeight
(
res
.
Prev
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Prev
.
Height
,
int64
(
res
.
Prev
.
Index
)))
kv
.
Value
=
nil
kvs
=
append
(
kvs
,
kv
)
}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcProjectKey4StatusHeight
(
res
.
Current
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Current
.
Height
,
int64
(
res
.
Current
.
Index
)))
kv
.
Value
=
types
.
Encode
(
res
.
Current
)
kvs
=
append
(
kvs
,
kv
)
return
kvs
}
func
(
a
*
Autonomy
)
execDelLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
case
auty
.
TyLogPropProject
,
auty
.
TyLogRvkPropProject
,
auty
.
TyLogVotePropProject
,
auty
.
TyLogPubVotePropProject
,
auty
.
TyLogTmintPropProject
:
{
var
receipt
auty
.
ReceiptProposalProject
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
return
nil
,
err
}
kv
:=
delProjectHeightIndex
(
&
receipt
)
set
=
append
(
set
,
kv
...
)
}
default
:
break
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
set
...
)
return
dbSet
,
nil
}
func
delProjectHeightIndex
(
res
*
auty
.
ReceiptProposalProject
)
(
kvs
[]
*
types
.
KeyValue
)
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcProjectKey4StatusHeight
(
res
.
Current
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Current
.
Height
,
int64
(
res
.
Current
.
Index
)))
kv
.
Value
=
nil
kvs
=
append
(
kvs
,
kv
)
if
res
.
Current
.
Status
>
1
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcProjectKey4StatusHeight
(
res
.
Prev
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Prev
.
Height
,
int64
(
res
.
Prev
.
Index
)))
kv
.
Value
=
types
.
Encode
(
res
.
Prev
)
kvs
=
append
(
kvs
,
kv
)
}
return
kvs
}
// getProposalBoard
func
(
a
*
Autonomy
)
getProposalProject
(
req
*
auty
.
ReqQueryProposalProject
)
(
types
.
Message
,
error
)
{
if
req
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
var
key
[]
byte
var
values
[][]
byte
var
err
error
localDb
:=
a
.
GetLocalDB
()
if
req
.
GetIndex
()
==
-
1
{
key
=
nil
}
else
{
//翻页查找指定的txhash列表
heightstr
:=
genHeightIndexStr
(
req
.
GetIndex
())
key
=
calcProjectKey4StatusHeight
(
req
.
Status
,
heightstr
)
}
prefix
:=
calcProjectKey4StatusHeight
(
req
.
Status
,
""
)
values
,
err
=
localDb
.
List
(
prefix
,
key
,
req
.
Count
,
req
.
GetDirection
())
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
values
)
==
0
{
return
nil
,
types
.
ErrNotFound
}
var
rep
auty
.
ReplyQueryProposalProject
for
_
,
value
:=
range
values
{
prop
:=
&
auty
.
AutonomyProposalProject
{}
err
=
types
.
Decode
(
value
,
prop
)
if
err
!=
nil
{
return
nil
,
err
}
rep
.
PropProjects
=
append
(
rep
.
PropProjects
,
prop
)
}
return
&
rep
,
nil
}
\ No newline at end of file
plugin/dapp/autonomy/executor/projectaction.go
View file @
c4b89c92
...
...
@@ -29,6 +29,25 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
return
nil
,
types
.
ErrInvalidParam
}
// 获取董事会成员
value
,
err
:=
a
.
db
.
Get
(
activeBoardID
())
if
err
!=
nil
{
err
=
auty
.
ErrNoActiveBoard
alog
.
Error
(
"propProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"get activeBoardID failed"
,
err
)
return
nil
,
err
}
pboard
:=
&
auty
.
ProposalBoard
{}
err
=
types
.
Decode
(
value
,
pboard
)
if
err
!=
nil
{
alog
.
Error
(
"propProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode ProposalBoard failed"
,
err
)
return
nil
,
err
}
if
len
(
pboard
.
Boards
)
>
maxBoards
||
len
(
pboard
.
Boards
)
<
minBoards
{
err
=
auty
.
ErrNoActiveBoard
alog
.
Error
(
"propProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"illegality boards number"
,
err
)
return
nil
,
err
}
receipt
,
err
:=
a
.
coinsAccount
.
ExecFrozen
(
a
.
fromaddr
,
a
.
execaddr
,
lockAmount
)
if
err
!=
nil
{
alog
.
Error
(
"propProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"ExecFrozen amount"
,
lockAmount
)
...
...
@@ -47,6 +66,7 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
}
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
prob
,
Boards
:
pboard
.
Boards
,
BoardVoteRes
:
&
auty
.
VoteResult
{},
PubVote
:
&
auty
.
PublicVote
{
Publicity
:
isPubVote
},
Status
:
auty
.
AutonomyStatusProposalProject
,
...
...
@@ -54,11 +74,7 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
Height
:
a
.
height
,
Index
:
a
.
index
,
}
key
:=
propProjectID
(
common
.
ToHex
(
a
.
txhash
))
value
:=
types
.
Encode
(
cur
)
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
value
})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
propProjectID
(
common
.
ToHex
(
a
.
txhash
)),
Value
:
types
.
Encode
(
cur
)})
receiptLog
:=
getProjectReceiptLog
(
nil
,
cur
,
auty
.
TyLogPropProject
)
logs
=
append
(
logs
,
receiptLog
)
...
...
@@ -161,28 +177,8 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
}
// 董事会成员验证
value
,
err
=
a
.
db
.
Get
(
activeBoardID
())
if
err
!=
nil
{
err
=
auty
.
ErrNoActiveBoard
alog
.
Error
(
"votePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"get activeBoardID failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
prob
:=
&
auty
.
ProposalBoard
{}
err
=
types
.
Decode
(
value
,
prob
)
if
err
!=
nil
{
alog
.
Error
(
"votePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"decode ProposalBoard failed"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
if
len
(
prob
.
Boards
)
>
maxBoards
||
len
(
prob
.
Boards
)
<
minBoards
{
err
=
auty
.
ErrNoActiveBoard
alog
.
Error
(
"votePropProject "
,
"addr"
,
a
.
fromaddr
,
"execaddr"
,
a
.
execaddr
,
"illegality boards number"
,
voteProb
.
ProposalID
,
"err"
,
err
)
return
nil
,
err
}
var
isBoard
bool
for
_
,
addr
:=
range
prob
.
Boards
{
for
_
,
addr
:=
range
cur
.
Boards
{
if
addr
==
a
.
fromaddr
{
isBoard
=
true
}
...
...
@@ -216,7 +212,7 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
// 更新已经投票地址
votes
.
Address
=
append
(
votes
.
Address
,
a
.
fromaddr
)
// 更新投票结果
cur
.
BoardVoteRes
.
TotalVotes
=
int32
(
len
(
prob
.
Boards
))
cur
.
BoardVoteRes
.
TotalVotes
=
int32
(
len
(
cur
.
Boards
))
if
voteProb
.
Approve
{
cur
.
BoardVoteRes
.
ApproveVotes
+=
1
}
else
{
...
...
plugin/dapp/autonomy/executor/query.go
View file @
c4b89c92
...
...
@@ -9,7 +9,12 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
// Query_Get
UnfreezeWithdraw 查询合约可提币量
// Query_Get
ProposalBoard 查询提案董事会
func
(
a
*
Autonomy
)
Query_GetProposalBoard
(
in
*
auty
.
ReqQueryProposalBoard
)
(
types
.
Message
,
error
)
{
return
a
.
getProposalBoard
(
in
)
}
// Query_GetProposalProject 查询提案项目
func
(
a
*
Autonomy
)
Query_GetProposalProject
(
in
*
auty
.
ReqQueryProposalProject
)
(
types
.
Message
,
error
)
{
return
a
.
getProposalProject
(
in
)
}
\ No newline at end of file
plugin/dapp/autonomy/proto/project.proto
View file @
c4b89c92
...
...
@@ -10,15 +10,17 @@ package types;
message
AutonomyProposalProject
{
ProposalProject
propProject
=
1
;
// 投票该提案的董事会成员
repeated
string
boards
=
2
;
// 董事会投票结果
VoteResult
boardVoteRes
=
2
;
VoteResult
boardVoteRes
=
3
;
// 公示投票
PublicVote
pubVote
=
3
;
PublicVote
pubVote
=
4
;
// 状态
int32
status
=
4
;
string
address
=
5
;
int64
height
=
6
;
int32
index
=
7
;
int32
status
=
5
;
string
address
=
6
;
int64
height
=
7
;
int32
index
=
8
;
}
message
ProposalProject
{
...
...
@@ -76,10 +78,14 @@ message LocalProposalProject {
}
// query
message
ReplyQueryProposalProject
{
string
proposalID
=
1
;
message
ReqQueryProposalProject
{
//优先根据status查询
int32
status
=
1
;
int32
count
=
2
;
int32
direction
=
3
;
int64
index
=
4
;
}
message
ReplyProposalProject
{
repeated
Local
ProposalProject
propProjects
=
1
;
message
Reply
Query
ProposalProject
{
repeated
Autonomy
ProposalProject
propProjects
=
1
;
}
\ No newline at end of file
plugin/dapp/autonomy/rpc/rpc.go
View file @
c4b89c92
...
...
@@ -71,3 +71,5 @@ func (c *channelClient) terminateProposalBoard(ctx context.Context, head *auty.T
}
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
// Proposal Project 相关的接口
plugin/dapp/autonomy/types/autonomy.pb.go
View file @
c4b89c92
...
...
@@ -33,8 +33,8 @@ It has these top-level messages:
TerminateProposalProject
ReceiptProposalProject
LocalProposalProject
ReqQueryProposalProject
ReplyQueryProposalProject
ReplyProposalProject
AutonomyProposalRule
ProposalRule
RevokeProposalRule
...
...
plugin/dapp/autonomy/types/project.pb.go
View file @
c4b89c92
This diff is collapsed.
Click to expand it.
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