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
9b962259
Commit
9b962259
authored
Aug 05, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add db table to rule project
parent
af4f3531
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
707 additions
and
361 deletions
+707
-361
proposal_board.go
plugin/dapp/autonomy/commands/proposal_board.go
+9
-2
proposal_project.go
plugin/dapp/autonomy/commands/proposal_project.go
+9
-2
proposal_rule.go
plugin/dapp/autonomy/commands/proposal_rule.go
+13
-3
board.go
plugin/dapp/autonomy/executor/board.go
+0
-36
board_test.go
plugin/dapp/autonomy/executor/board_test.go
+112
-34
boardtable.go
plugin/dapp/autonomy/executor/boardtable.go
+2
-2
project.go
plugin/dapp/autonomy/executor/project.go
+71
-70
project_test.go
plugin/dapp/autonomy/executor/project_test.go
+101
-33
projecttable.go
plugin/dapp/autonomy/executor/projecttable.go
+73
-0
rule.go
plugin/dapp/autonomy/executor/rule.go
+74
-71
rule_test.go
plugin/dapp/autonomy/executor/rule_test.go
+97
-35
ruletable.go
plugin/dapp/autonomy/executor/ruletable.go
+73
-0
board.proto
plugin/dapp/autonomy/proto/board.proto
+6
-6
project.proto
plugin/dapp/autonomy/proto/project.proto
+6
-6
rule.proto
plugin/dapp/autonomy/proto/rule.proto
+8
-7
board.pb.go
plugin/dapp/autonomy/types/board.pb.go
+53
-54
project.pb.go
plugin/dapp/autonomy/types/project.pb.go
+0
-0
rule.pb.go
plugin/dapp/autonomy/types/rule.pb.go
+0
-0
No files found.
plugin/dapp/autonomy/commands/proposal_board.go
View file @
9b962259
...
@@ -259,10 +259,13 @@ func addShowProposalBoardflags(cmd *cobra.Command) {
...
@@ -259,10 +259,13 @@ func addShowProposalBoardflags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"type"
)
cmd
.
MarkFlagRequired
(
"type"
)
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
Flags
()
.
Uint32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
Uint32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"address"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int64P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
cmd
.
Flags
()
.
Int64P
(
"height"
,
"h"
,
-
1
,
"height, default is -1"
)
cmd
.
Flags
()
.
Int32P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
}
}
func
showProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
@@ -270,9 +273,11 @@ func showProposalBoard(cmd *cobra.Command, args []string) {
...
@@ -270,9 +273,11 @@ func showProposalBoard(cmd *cobra.Command, args []string) {
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"index"
)
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
var
rep
interface
{}
var
rep
interface
{}
...
@@ -286,8 +291,10 @@ func showProposalBoard(cmd *cobra.Command, args []string) {
...
@@ -286,8 +291,10 @@ func showProposalBoard(cmd *cobra.Command, args []string) {
}
else
if
1
==
typ
{
}
else
if
1
==
typ
{
req
:=
auty
.
ReqQueryProposalBoard
{
req
:=
auty
.
ReqQueryProposalBoard
{
Status
:
int32
(
status
),
Status
:
int32
(
status
),
Addr
:
addr
,
Count
:
count
,
Count
:
count
,
Direction
:
direction
,
Direction
:
direction
,
Height
:
height
,
Index
:
index
,
Index
:
index
,
}
}
params
.
FuncName
=
auty
.
ListProposalBoard
params
.
FuncName
=
auty
.
ListProposalBoard
...
...
plugin/dapp/autonomy/commands/proposal_project.go
View file @
9b962259
...
@@ -286,10 +286,13 @@ func addShowProposalProjectflags(cmd *cobra.Command) {
...
@@ -286,10 +286,13 @@ func addShowProposalProjectflags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"type"
)
cmd
.
MarkFlagRequired
(
"type"
)
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
Flags
()
.
Uint32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
Uint32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"address"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int64P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
cmd
.
Flags
()
.
Int64P
(
"height"
,
"h"
,
-
1
,
"height, default is -1"
)
cmd
.
Flags
()
.
Int32P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
}
}
func
showProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
@@ -297,9 +300,11 @@ func showProposalProject(cmd *cobra.Command, args []string) {
...
@@ -297,9 +300,11 @@ func showProposalProject(cmd *cobra.Command, args []string) {
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"index"
)
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
var
rep
interface
{}
var
rep
interface
{}
...
@@ -314,8 +319,10 @@ func showProposalProject(cmd *cobra.Command, args []string) {
...
@@ -314,8 +319,10 @@ func showProposalProject(cmd *cobra.Command, args []string) {
}
else
if
1
==
typ
{
}
else
if
1
==
typ
{
req
:=
auty
.
ReqQueryProposalProject
{
req
:=
auty
.
ReqQueryProposalProject
{
Status
:
int32
(
status
),
Status
:
int32
(
status
),
Addr
:
addr
,
Count
:
count
,
Count
:
count
,
Direction
:
direction
,
Direction
:
direction
,
Height
:
height
,
Index
:
index
,
Index
:
index
,
}
}
params
.
FuncName
=
auty
.
ListProposalProject
params
.
FuncName
=
auty
.
ListProposalProject
...
...
plugin/dapp/autonomy/commands/proposal_rule.go
View file @
9b962259
...
@@ -226,10 +226,13 @@ func addShowProposalRuleflags(cmd *cobra.Command) {
...
@@ -226,10 +226,13 @@ func addShowProposalRuleflags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"type"
)
cmd
.
MarkFlagRequired
(
"type"
)
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
Flags
()
.
StringP
(
"proposalID"
,
"p"
,
""
,
"proposal ID"
)
cmd
.
Flags
()
.
Uint32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
Uint32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"address"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int64P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
cmd
.
Flags
()
.
Int64P
(
"height"
,
"h"
,
-
1
,
"height, default is -1"
)
cmd
.
Flags
()
.
Int32P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
}
}
func
showProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
showProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
@@ -237,9 +240,11 @@ func showProposalRule(cmd *cobra.Command, args []string) {
...
@@ -237,9 +240,11 @@ func showProposalRule(cmd *cobra.Command, args []string) {
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
typ
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"type"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"status"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"index"
)
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
var
rep
interface
{}
var
rep
interface
{}
...
@@ -253,8 +258,10 @@ func showProposalRule(cmd *cobra.Command, args []string) {
...
@@ -253,8 +258,10 @@ func showProposalRule(cmd *cobra.Command, args []string) {
}
else
if
1
==
typ
{
}
else
if
1
==
typ
{
req
:=
auty
.
ReqQueryProposalRule
{
req
:=
auty
.
ReqQueryProposalRule
{
Status
:
int32
(
status
),
Status
:
int32
(
status
),
Addr
:
addr
,
Count
:
count
,
Count
:
count
,
Direction
:
direction
,
Direction
:
direction
,
Height
:
height
,
Index
:
index
,
Index
:
index
,
}
}
params
.
FuncName
=
auty
.
ListProposalRule
params
.
FuncName
=
auty
.
ListProposalRule
...
@@ -366,6 +373,7 @@ func addShowProposalCommentflags(cmd *cobra.Command) {
...
@@ -366,6 +373,7 @@ func addShowProposalCommentflags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"proposalID"
)
cmd
.
MarkFlagRequired
(
"proposalID"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"count"
,
"c"
,
1
,
"count, default is 1"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int32P
(
"direction"
,
"d"
,
-
1
,
"direction, default is reserve"
)
cmd
.
Flags
()
.
Int64P
(
"height"
,
"h"
,
-
1
,
"height, default is -1"
)
cmd
.
Flags
()
.
Int64P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
cmd
.
Flags
()
.
Int64P
(
"index"
,
"i"
,
-
1
,
"index, default is -1"
)
}
}
...
@@ -374,7 +382,8 @@ func showProposalComment(cmd *cobra.Command, args []string) {
...
@@ -374,7 +382,8 @@ func showProposalComment(cmd *cobra.Command, args []string) {
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
propID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"index"
)
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
var
rep
interface
{}
var
rep
interface
{}
...
@@ -384,6 +393,7 @@ func showProposalComment(cmd *cobra.Command, args []string) {
...
@@ -384,6 +393,7 @@ func showProposalComment(cmd *cobra.Command, args []string) {
ProposalID
:
propID
,
ProposalID
:
propID
,
Count
:
count
,
Count
:
count
,
Direction
:
direction
,
Direction
:
direction
,
Height
:
height
,
Index
:
index
,
Index
:
index
,
}
}
params
.
FuncName
=
auty
.
ListProposalComment
params
.
FuncName
=
auty
.
ListProposalComment
...
...
plugin/dapp/autonomy/executor/board.go
View file @
9b962259
...
@@ -37,32 +37,14 @@ func (a *Autonomy) execLocalBoard(receiptData *types.ReceiptData) (*types.LocalD
...
@@ -37,32 +37,14 @@ func (a *Autonomy) execLocalBoard(receiptData *types.ReceiptData) (*types.LocalD
break
break
}
}
}
}
kvs
,
err
:=
table
.
Save
()
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
func
saveBoardHeightIndex
(
res
*
auty
.
ReceiptProposalBoard
)
(
kvs
[]
*
types
.
KeyValue
)
{
// 先将之前的状态删除掉,再做更新
if
res
.
Current
.
Status
>
1
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcBoardKey4StatusHeight
(
res
.
Prev
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Prev
.
Height
,
int64
(
res
.
Prev
.
Index
)))
kv
.
Value
=
nil
kvs
=
append
(
kvs
,
kv
)
}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcBoardKey4StatusHeight
(
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
)
execDelLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execDelLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
table
:=
NewBoardTable
(
a
.
GetLocalDB
())
table
:=
NewBoardTable
(
a
.
GetLocalDB
())
...
@@ -99,25 +81,9 @@ func (a *Autonomy) execDelLocalBoard(receiptData *types.ReceiptData) (*types.Loc
...
@@ -99,25 +81,9 @@ func (a *Autonomy) execDelLocalBoard(receiptData *types.ReceiptData) (*types.Loc
return
nil
,
err
return
nil
,
err
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
func
delBoardHeightIndex
(
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
kvs
=
append
(
kvs
,
kv
)
if
res
.
Current
.
Status
>
1
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcBoardKey4StatusHeight
(
res
.
Prev
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Prev
.
Height
,
int64
(
res
.
Prev
.
Index
)))
kv
.
Value
=
types
.
Encode
(
res
.
Prev
)
kvs
=
append
(
kvs
,
kv
)
}
return
kvs
}
func
(
a
*
Autonomy
)
getProposalBoard
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
getProposalBoard
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
if
req
==
nil
{
if
req
==
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
@@ -186,8 +152,6 @@ func (a *Autonomy) listProposalBoard(req *auty.ReqQueryProposalBoard) (types.Mes
...
@@ -186,8 +152,6 @@ func (a *Autonomy) listProposalBoard(req *auty.ReqQueryProposalBoard) (types.Mes
return
&
rep
,
nil
return
&
rep
,
nil
}
}
func
genHeightIndexStr
(
index
int64
)
string
{
func
genHeightIndexStr
(
index
int64
)
string
{
return
fmt
.
Sprintf
(
"%018d"
,
index
)
return
fmt
.
Sprintf
(
"%018d"
,
index
)
}
}
plugin/dapp/autonomy/executor/board_test.go
View file @
9b962259
...
@@ -12,10 +12,12 @@ import (
...
@@ -12,10 +12,12 @@ import (
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/33cn/chain33/common/db"
)
)
func
TestExecLocalBoard
(
t
*
testing
.
T
)
{
func
TestExecLocalBoard
(
t
*
testing
.
T
)
{
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
//TyLogPropBoard
//TyLogPropBoard
...
@@ -40,14 +42,16 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -40,14 +42,16 @@ func TestExecLocalBoard(t *testing.T) {
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcBoardKey4StatusHeight
(
cur
.
Status
,
//save to database
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
// TyLogRvkPropBoard
// TyLogRvkPropBoard
pre1
:=
copyAutonomyProposalBoard
(
cur
)
pre1
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusRvkPropBoard
cur
.
Status
=
auty
.
AutonomyStatusRvkPropBoard
cur
.
Height
=
2
cur
.
Index
=
3
receiptBoard1
:=
&
auty
.
ReceiptProposalBoard
{
receiptBoard1
:=
&
auty
.
ReceiptProposalBoard
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
...
@@ -59,11 +63,12 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -59,11 +63,12 @@ func TestExecLocalBoard(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcBoardKey4StatusHeight
(
pre1
.
Status
,
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre1
.
Index
))))
//save to database
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
saveKvs
(
sdb
,
set
.
KV
)
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcBoardKey4StatusHeight
(
cur
.
Status
,
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
// TyLogVotePropBoard
// TyLogVotePropBoard
cur
.
Status
=
auty
.
AutonomyStatusProposalBoard
cur
.
Status
=
auty
.
AutonomyStatusProposalBoard
...
@@ -71,8 +76,9 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -71,8 +76,9 @@ func TestExecLocalBoard(t *testing.T) {
cur
.
Index
=
2
cur
.
Index
=
2
pre2
:=
copyAutonomyProposalBoard
(
cur
)
pre2
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Height
=
2
cur
.
Height
=
1
cur
.
Index
=
3
cur
.
Index
=
2
cur
.
Address
=
"2222222222222"
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
Prev
:
pre2
,
Prev
:
pre2
,
Current
:
cur
,
Current
:
cur
,
...
@@ -84,15 +90,16 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -84,15 +90,16 @@ func TestExecLocalBoard(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcBoardKey4StatusHeight
(
pre2
.
Status
,
//save to database
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre2
.
Index
))))
saveKvs
(
sdb
,
set
.
KV
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
// check
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcBoardKey4StatusHeight
(
cur
.
Status
,
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
}
}
func
TestExecDelLocalBoard
(
t
*
testing
.
T
)
{
func
TestExecDelLocalBoard
(
t
*
testing
.
T
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
//TyLogPropBoard
//TyLogPropBoard
cur
:=
&
auty
.
AutonomyProposalBoard
{
cur
:=
&
auty
.
AutonomyProposalBoard
{
PropBoard
:
&
auty
.
ProposalBoard
{},
PropBoard
:
&
auty
.
ProposalBoard
{},
...
@@ -112,22 +119,51 @@ func TestExecDelLocalBoard(t *testing.T) {
...
@@ -112,22 +119,51 @@ func TestExecDelLocalBoard(t *testing.T) {
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalBoard
(
receipt
)
// 先执行local然后进行删除
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execDelLocalBoard
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcBoardKey4StatusHeight
(
cur
.
Status
,
saveKvs
(
sdb
,
set
.
KV
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
// check
table
:=
NewBoardTable
(
au
.
GetLocalDB
())
query
:=
table
.
GetQuery
(
kvdb
)
_
,
err
=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"addr"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"addr_status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
// TyLogVotePropBoard
// TyLogVotePropBoard
pre1
:=
copyAutonomyProposalBoard
(
cur
)
pre1
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Height
=
2
cur
.
Height
=
1
cur
.
Index
=
3
cur
.
Index
=
2
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
// 先执行local然后进行删除
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
},
})
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execDelLocalBoard
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execDelLocalBoard
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
...
@@ -135,12 +171,10 @@ func TestExecDelLocalBoard(t *testing.T) {
...
@@ -135,12 +171,10 @@ func TestExecDelLocalBoard(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcBoardKey4StatusHeight
(
cur
.
Status
,
saveKvs
(
sdb
,
set
.
KV
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
checkExecLocalBoard
(
t
,
kvdb
,
pre1
)
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcBoardKey4StatusHeight
(
pre1
.
Status
,
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre1
.
Index
))))
require
.
NotNil
(
t
,
set
.
KV
[
1
]
.
Value
)
}
}
func
TestGetProposalBoard
(
t
*
testing
.
T
)
{
func
TestGetProposalBoard
(
t
*
testing
.
T
)
{
...
@@ -161,7 +195,7 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -161,7 +195,7 @@ func TestListProposalBoard(t *testing.T) {
au
:=
&
Autonomy
{
au
:=
&
Autonomy
{
dapp
.
DriverBase
{},
dapp
.
DriverBase
{},
}
}
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
type
statu
struct
{
type
statu
struct
{
...
@@ -192,16 +226,23 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -192,16 +226,23 @@ func TestListProposalBoard(t *testing.T) {
Height
:
1
,
Height
:
1
,
Index
:
2
,
Index
:
2
,
}
}
//将数据保存下去
var
kvs
[]
*
types
.
KeyValue
table
:=
NewBoardTable
(
kvdb
)
for
_
,
tcase
:=
range
testcase
{
for
_
,
tcase
:=
range
testcase
{
key
:=
calcBoardKey4StatusHeight
(
tcase
.
status
,
dapp
.
HeightIndexStr
(
tcase
.
height
,
int64
(
tcase
.
index
)))
cur
.
Status
=
tcase
.
status
cur
.
Status
=
tcase
.
status
cur
.
Height
=
tcase
.
height
cur
.
Height
=
tcase
.
height
cur
.
Index
=
int32
(
tcase
.
index
)
cur
.
Index
=
int32
(
tcase
.
index
)
value
:=
types
.
Encode
(
cur
)
kvdb
.
Set
(
key
,
value
)
err
:=
table
.
Replace
(
cur
)
require
.
NoError
(
t
,
err
)
kv
,
err
:=
table
.
Save
()
require
.
NoError
(
t
,
err
)
kvs
=
append
(
kvs
,
kv
...
)
}
}
saveKvs
(
sdb
,
kvs
)
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalBoard
{
req
:=
&
auty
.
ReqQueryProposalBoard
{
Status
:
auty
.
AutonomyStatusProposalBoard
,
Status
:
auty
.
AutonomyStatusProposalBoard
,
...
@@ -264,3 +305,39 @@ func TestListProposalBoard(t *testing.T) {
...
@@ -264,3 +305,39 @@ func TestListProposalBoard(t *testing.T) {
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalBoard
)
.
PropBoards
[
1
]
.
Height
,
testcase2
[
0
]
.
height
)
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalBoard
)
.
PropBoards
[
1
]
.
Height
,
testcase2
[
0
]
.
height
)
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalBoard
)
.
PropBoards
[
1
]
.
Index
,
int32
(
testcase2
[
0
]
.
index
))
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalBoard
)
.
PropBoards
[
1
]
.
Index
,
int32
(
testcase2
[
0
]
.
index
))
}
}
func
checkExecLocalBoard
(
t
*
testing
.
T
,
kvdb
db
.
KVDB
,
cur
*
auty
.
AutonomyProposalBoard
)
{
table
:=
NewBoardTable
(
kvdb
)
query
:=
table
.
GetQuery
(
kvdb
)
rows
,
err
:=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
string
(
rows
[
0
]
.
Primary
),
dapp
.
HeightIndexStr
(
1
,
2
))
rows
,
err
=
query
.
ListIndex
(
"addr"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
rows
,
err
=
query
.
ListIndex
(
"status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
rows
,
err
=
query
.
ListIndex
(
"addr_status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
prop
,
ok
:=
rows
[
0
]
.
Data
.
(
*
auty
.
AutonomyProposalBoard
)
assert
.
Equal
(
t
,
true
,
ok
)
assert
.
Equal
(
t
,
prop
,
cur
)
}
func
saveKvs
(
sdb
db
.
DB
,
kvs
[]
*
types
.
KeyValue
)
{
for
_
,
kv
:=
range
kvs
{
if
kv
.
Value
==
nil
{
sdb
.
Delete
(
kv
.
Key
)
}
else
{
sdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
}
}
\ No newline at end of file
plugin/dapp/autonomy/executor/boardtable.go
View file @
9b962259
...
@@ -17,7 +17,7 @@ data: autonomy board
...
@@ -17,7 +17,7 @@ data: autonomy board
index: status, addr
index: status, addr
*/
*/
var
o
pt
=
&
table
.
Option
{
var
boardO
pt
=
&
table
.
Option
{
Prefix
:
"LODB-autonomy"
,
Prefix
:
"LODB-autonomy"
,
Name
:
"board"
,
Name
:
"board"
,
Primary
:
"heightindex"
,
Primary
:
"heightindex"
,
...
@@ -27,7 +27,7 @@ var opt = &table.Option{
...
@@ -27,7 +27,7 @@ var opt = &table.Option{
//NewTable 新建表
//NewTable 新建表
func
NewBoardTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
func
NewBoardTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewBoardRow
()
rowmeta
:=
NewBoardRow
()
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
o
pt
)
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
boardO
pt
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
...
plugin/dapp/autonomy/executor/project.go
View file @
9b962259
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
func
(
a
*
Autonomy
)
execLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
table
:=
NewProjectTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
switch
log
.
Ty
{
case
auty
.
TyLogPropProject
,
case
auty
.
TyLogPropProject
,
...
@@ -26,73 +26,61 @@ func (a *Autonomy) execLocalProject(receiptData *types.ReceiptData) (*types.Loca
...
@@ -26,73 +26,61 @@ func (a *Autonomy) execLocalProject(receiptData *types.ReceiptData) (*types.Loca
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
kv
:=
saveProjectHeightIndex
(
&
receipt
)
err
=
table
.
Replace
(
receipt
.
Current
)
set
=
append
(
set
,
kv
...
)
if
err
!=
nil
{
return
nil
,
err
}
}
}
default
:
default
:
break
break
}
}
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
set
...
)
kvs
,
err
:=
table
.
Save
()
return
dbSet
,
nil
if
err
!=
nil
{
}
return
nil
,
err
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
)
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
kv
:=
&
types
.
KeyValue
{}
return
dbSet
,
nil
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
)
{
func
(
a
*
Autonomy
)
execDelLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
table
:=
NewProjectTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
var
receipt
auty
.
ReceiptProposalProject
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
return
nil
,
err
}
switch
log
.
Ty
{
switch
log
.
Ty
{
case
auty
.
TyLogPropProject
,
case
auty
.
TyLogPropProject
:
auty
.
TyLogRvkPropProject
,
{
heightIndex
:=
dapp
.
HeightIndexStr
(
receipt
.
Current
.
Height
,
int64
(
receipt
.
Current
.
Index
))
err
=
table
.
Del
([]
byte
(
heightIndex
))
if
err
!=
nil
{
return
nil
,
err
}
}
case
auty
.
TyLogRvkPropProject
,
auty
.
TyLogVotePropProject
,
auty
.
TyLogVotePropProject
,
auty
.
TyLogPubVotePropProject
,
auty
.
TyLogPubVotePropProject
,
auty
.
TyLogTmintPropProject
:
auty
.
TyLogTmintPropProject
:
{
{
var
receipt
auty
.
ReceiptProposalProject
err
=
table
.
Replace
(
receipt
.
Prev
)
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
kv
:=
delProjectHeightIndex
(
&
receipt
)
set
=
append
(
set
,
kv
...
)
}
}
default
:
default
:
break
break
}
}
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
set
...
)
kvs
,
err
:=
table
.
Save
()
return
dbSet
,
nil
if
err
!=
nil
{
}
return
nil
,
err
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
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
}
}
func
(
a
*
Autonomy
)
getProposalProject
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
getProposalProject
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
...
@@ -117,34 +105,47 @@ func (a *Autonomy) listProposalProject(req *auty.ReqQueryProposalProject) (types
...
@@ -117,34 +105,47 @@ func (a *Autonomy) listProposalProject(req *auty.ReqQueryProposalProject) (types
if
req
==
nil
{
if
req
==
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
//var key []byte
localDb
:=
a
.
GetLocalDB
()
//var values [][]byte
query
:=
NewProjectTable
(
localDb
)
.
GetQuery
(
localDb
)
//var err error
var
primary
[]
byte
//
if
req
.
Height
>
0
{
//localDb := a.GetLocalDB()
primary
=
[]
byte
(
dapp
.
HeightIndexStr
(
req
.
Height
,
int64
(
req
.
Index
)))
//if req.GetIndex() == -1 {
}
// key = nil
indexName
:=
""
//} else { //翻页查找指定的txhash列表
if
req
.
Status
>
0
&&
req
.
Addr
!=
""
{
// heightstr := genHeightIndexStr(req.GetIndex())
indexName
=
"addr_status"
// key = calcProjectKey4StatusHeight(req.Status, heightstr)
}
else
if
req
.
Status
>
0
{
//}
indexName
=
"status"
//prefix := calcProjectKey4StatusHeight(req.Status, "")
}
else
if
req
.
Addr
!=
""
{
//values, err = localDb.List(prefix, key, req.Count, req.GetDirection())
indexName
=
"addr"
//if err != nil {
}
// return nil, err
//}
cur
:=
&
ProjectRow
{
//if len(values) == 0 {
AutonomyProposalProject
:
&
auty
.
AutonomyProposalProject
{},
// return nil, types.ErrNotFound
}
//}
cur
.
Address
=
req
.
Addr
cur
.
Status
=
req
.
Status
cur
.
Height
=
req
.
Height
cur
.
Index
=
req
.
Index
prefix
,
err
:=
cur
.
Get
(
indexName
)
rows
,
err
:=
query
.
ListIndex
(
indexName
,
prefix
,
primary
,
req
.
Count
,
req
.
Direction
)
if
err
!=
nil
{
alog
.
Error
(
"query List failed"
,
"indexName"
,
indexName
,
"prefix"
,
"prefix"
,
"key"
,
string
(
primary
),
"err"
,
err
)
return
nil
,
err
}
if
len
(
rows
)
==
0
{
return
nil
,
types
.
ErrNotFound
}
var
rep
auty
.
ReplyQueryProposalProject
var
rep
auty
.
ReplyQueryProposalProject
//for _, value := range value
s {
for
_
,
row
:=
range
row
s
{
// prop := &auty.AutonomyProposalProject{}
r
,
ok
:=
row
.
Data
.
(
*
auty
.
AutonomyProposalProject
)
// err = types.Decode(value, prop)
if
!
ok
{
// if err != nil {
alog
.
Error
(
"listProposalProject"
,
"err"
,
"bad row type"
)
// return nil, err
return
nil
,
types
.
ErrDecode
//
}
}
// rep.PropProjects = append(rep.PropProjects, prop
)
rep
.
PropProjects
=
append
(
rep
.
PropProjects
,
r
)
//
}
}
return
&
rep
,
nil
return
&
rep
,
nil
}
}
plugin/dapp/autonomy/executor/project_test.go
View file @
9b962259
...
@@ -12,10 +12,14 @@ import (
...
@@ -12,10 +12,14 @@ import (
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/33cn/chain33/common/db"
"github.com/stretchr/testify/assert"
)
)
func
TestExecLocalProject
(
t
*
testing
.
T
)
{
func
TestExecLocalProject
(
t
*
testing
.
T
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
//TyLogPropProject
//TyLogPropProject
cur
:=
&
auty
.
AutonomyProposalProject
{
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{},
PropProject
:
&
auty
.
ProposalProject
{},
...
@@ -40,14 +44,15 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -40,14 +44,15 @@ func TestExecLocalProject(t *testing.T) {
set
,
err
:=
au
.
execLocalProject
(
receipt
)
set
,
err
:=
au
.
execLocalProject
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcProjectKey4StatusHeight
(
cur
.
Status
,
//save to database
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalProject
(
t
,
kvdb
,
cur
)
// TyLogRvkPropProject
// TyLogRvkPropProject
pre1
:=
copyAutonomyProposalProject
(
cur
)
pre1
:=
copyAutonomyProposalProject
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusRvkPropProject
cur
.
Status
=
auty
.
AutonomyStatusRvkPropProject
cur
.
Height
=
2
cur
.
Index
=
3
receiptProject1
:=
&
auty
.
ReceiptProposalProject
{
receiptProject1
:=
&
auty
.
ReceiptProposalProject
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
...
@@ -59,11 +64,12 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -59,11 +64,12 @@ func TestExecLocalProject(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcProjectKey4StatusHeight
(
pre1
.
Status
,
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre1
.
Index
))))
//save to database
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
saveKvs
(
sdb
,
set
.
KV
)
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcProjectKey4StatusHeight
(
cur
.
Status
,
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
checkExecLocalProject
(
t
,
kvdb
,
cur
)
// TyLogVotePropProject
// TyLogVotePropProject
cur
.
Status
=
auty
.
AutonomyStatusProposalProject
cur
.
Status
=
auty
.
AutonomyStatusProposalProject
...
@@ -71,8 +77,9 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -71,8 +77,9 @@ func TestExecLocalProject(t *testing.T) {
cur
.
Index
=
2
cur
.
Index
=
2
pre2
:=
copyAutonomyProposalProject
(
cur
)
pre2
:=
copyAutonomyProposalProject
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Height
=
2
cur
.
Height
=
1
cur
.
Index
=
3
cur
.
Index
=
2
cur
.
Address
=
"2222222222222"
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
Prev
:
pre2
,
Prev
:
pre2
,
Current
:
cur
,
Current
:
cur
,
...
@@ -84,15 +91,18 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -84,15 +91,18 @@ func TestExecLocalProject(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcProjectKey4StatusHeight
(
pre2
.
Status
,
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre2
.
Index
))))
//save to database
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
saveKvs
(
sdb
,
set
.
KV
)
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcProjectKey4StatusHeight
(
cur
.
Status
,
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
checkExecLocalProject
(
t
,
kvdb
,
cur
)
}
}
func
TestExecDelLocalProject
(
t
*
testing
.
T
)
{
func
TestExecDelLocalProject
(
t
*
testing
.
T
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
//TyLogPropProject
//TyLogPropProject
cur
:=
&
auty
.
AutonomyProposalProject
{
cur
:=
&
auty
.
AutonomyProposalProject
{
PropProject
:
&
auty
.
ProposalProject
{},
PropProject
:
&
auty
.
ProposalProject
{},
...
@@ -114,22 +124,49 @@ func TestExecDelLocalProject(t *testing.T) {
...
@@ -114,22 +124,49 @@ func TestExecDelLocalProject(t *testing.T) {
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalProject
(
receipt
)
// 先执行local然后进行删除
set
,
err
:=
au
.
execLocalProject
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcProjectKey4StatusHeight
(
cur
.
Status
,
saveKvs
(
sdb
,
set
.
KV
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
set
,
err
=
au
.
execDelLocalProject
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
table
:=
NewBoardTable
(
au
.
GetLocalDB
())
query
:=
table
.
GetQuery
(
kvdb
)
_
,
err
=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"addr"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"addr_status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
// TyLogVotePropProject
// TyLogVotePropProject
pre1
:=
copyAutonomyProposalProject
(
cur
)
pre1
:=
copyAutonomyProposalProject
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Height
=
2
cur
.
Height
=
1
cur
.
Index
=
3
cur
.
Index
=
2
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
// 先执行local然后进行删除
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
},
})
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalProject
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execDelLocalProject
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execDelLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
...
@@ -137,12 +174,9 @@ func TestExecDelLocalProject(t *testing.T) {
...
@@ -137,12 +174,9 @@ func TestExecDelLocalProject(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcProjectKey4StatusHeight
(
cur
.
Status
,
saveKvs
(
sdb
,
set
.
KV
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
checkExecLocalProject
(
t
,
kvdb
,
pre1
)
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcProjectKey4StatusHeight
(
pre1
.
Status
,
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre1
.
Index
))))
require
.
NotNil
(
t
,
set
.
KV
[
1
]
.
Value
)
}
}
func
TestGetProposalProject
(
t
*
testing
.
T
)
{
func
TestGetProposalProject
(
t
*
testing
.
T
)
{
...
@@ -163,7 +197,7 @@ func TestListProposalProject(t *testing.T) {
...
@@ -163,7 +197,7 @@ func TestListProposalProject(t *testing.T) {
au
:=
&
Autonomy
{
au
:=
&
Autonomy
{
dapp
.
DriverBase
{},
dapp
.
DriverBase
{},
}
}
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
type
statu
struct
{
type
statu
struct
{
...
@@ -196,15 +230,22 @@ func TestListProposalProject(t *testing.T) {
...
@@ -196,15 +230,22 @@ func TestListProposalProject(t *testing.T) {
Height
:
1
,
Height
:
1
,
Index
:
2
,
Index
:
2
,
}
}
//将数据保存下去
var
kvs
[]
*
types
.
KeyValue
table
:=
NewProjectTable
(
kvdb
)
for
_
,
tcase
:=
range
testcase
{
for
_
,
tcase
:=
range
testcase
{
key
:=
calcProjectKey4StatusHeight
(
tcase
.
status
,
dapp
.
HeightIndexStr
(
tcase
.
height
,
int64
(
tcase
.
index
)))
cur
.
Status
=
tcase
.
status
cur
.
Status
=
tcase
.
status
cur
.
Height
=
tcase
.
height
cur
.
Height
=
tcase
.
height
cur
.
Index
=
int32
(
tcase
.
index
)
cur
.
Index
=
int32
(
tcase
.
index
)
value
:=
types
.
Encode
(
cur
)
kvdb
.
Set
(
key
,
value
)
err
:=
table
.
Replace
(
cur
)
require
.
NoError
(
t
,
err
)
kv
,
err
:=
table
.
Save
()
require
.
NoError
(
t
,
err
)
kvs
=
append
(
kvs
,
kv
...
)
}
}
saveKvs
(
sdb
,
kvs
)
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalProject
{
req
:=
&
auty
.
ReqQueryProposalProject
{
...
@@ -268,3 +309,29 @@ func TestListProposalProject(t *testing.T) {
...
@@ -268,3 +309,29 @@ func TestListProposalProject(t *testing.T) {
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalProject
)
.
PropProjects
[
1
]
.
Height
,
testcase2
[
0
]
.
height
)
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalProject
)
.
PropProjects
[
1
]
.
Height
,
testcase2
[
0
]
.
height
)
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalProject
)
.
PropProjects
[
1
]
.
Index
,
int32
(
testcase2
[
0
]
.
index
))
require
.
Equal
(
t
,
rsp
.
(
*
auty
.
ReplyQueryProposalProject
)
.
PropProjects
[
1
]
.
Index
,
int32
(
testcase2
[
0
]
.
index
))
}
}
func
checkExecLocalProject
(
t
*
testing
.
T
,
kvdb
db
.
KVDB
,
cur
*
auty
.
AutonomyProposalProject
)
{
table
:=
NewProjectTable
(
kvdb
)
query
:=
table
.
GetQuery
(
kvdb
)
rows
,
err
:=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
string
(
rows
[
0
]
.
Primary
),
dapp
.
HeightIndexStr
(
1
,
2
))
rows
,
err
=
query
.
ListIndex
(
"addr"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
rows
,
err
=
query
.
ListIndex
(
"status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
rows
,
err
=
query
.
ListIndex
(
"addr_status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
prop
,
ok
:=
rows
[
0
]
.
Data
.
(
*
auty
.
AutonomyProposalProject
)
assert
.
Equal
(
t
,
true
,
ok
)
assert
.
Equal
(
t
,
prop
,
cur
)
}
\ No newline at end of file
plugin/dapp/autonomy/executor/projecttable.go
0 → 100644
View file @
9b962259
package
executor
import
(
"fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/system/dapp"
)
/*
table struct
data: autonomy project
index: status, addr
*/
var
projectOpt
=
&
table
.
Option
{
Prefix
:
"LODB-autonomy"
,
Name
:
"project"
,
Primary
:
"heightindex"
,
Index
:
[]
string
{
"addr"
,
"status"
,
"addr_status"
},
}
//NewTable 新建表
func
NewProjectTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewProjectRow
()
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
projectOpt
)
if
err
!=
nil
{
panic
(
err
)
}
return
table
}
//ProjectRow table meta 结构
type
ProjectRow
struct
{
*
auty
.
AutonomyProposalProject
}
//NewProjectRow 新建一个meta 结构
func
NewProjectRow
()
*
ProjectRow
{
return
&
ProjectRow
{
AutonomyProposalProject
:
&
auty
.
AutonomyProposalProject
{}}
}
//CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存heightindex)
func
(
r
*
ProjectRow
)
CreateRow
()
*
table
.
Row
{
return
&
table
.
Row
{
Data
:
&
auty
.
AutonomyProposalProject
{}}
}
//SetPayload 设置数据
func
(
r
*
ProjectRow
)
SetPayload
(
data
types
.
Message
)
error
{
if
d
,
ok
:=
data
.
(
*
auty
.
AutonomyProposalProject
);
ok
{
r
.
AutonomyProposalProject
=
d
return
nil
}
return
types
.
ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func
(
r
*
ProjectRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"heightindex"
{
return
[]
byte
(
dapp
.
HeightIndexStr
(
r
.
Height
,
int64
(
r
.
Index
))),
nil
}
else
if
key
==
"status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
r
.
Status
)),
nil
}
else
if
key
==
"addr"
{
return
[]
byte
(
r
.
Address
),
nil
}
else
if
key
==
"addr_status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
r
.
Address
,
r
.
Status
)),
nil
}
return
nil
,
types
.
ErrNotFound
}
plugin/dapp/autonomy/executor/rule.go
View file @
9b962259
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
func
(
a
*
Autonomy
)
execLocalRule
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execLocalRule
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
table
:=
NewRuleTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
switch
log
.
Ty
{
case
auty
.
TyLogPropRule
,
case
auty
.
TyLogPropRule
,
...
@@ -25,73 +25,62 @@ func (a *Autonomy) execLocalRule(receiptData *types.ReceiptData) (*types.LocalDB
...
@@ -25,73 +25,62 @@ func (a *Autonomy) execLocalRule(receiptData *types.ReceiptData) (*types.LocalDB
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
kv
:=
saveRuleHeightIndex
(
&
receipt
)
err
=
table
.
Replace
(
receipt
.
Current
)
set
=
append
(
set
,
kv
...
)
if
err
!=
nil
{
return
nil
,
err
}
}
}
default
:
default
:
break
break
}
}
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
set
...
)
kvs
,
err
:=
table
.
Save
()
return
dbSet
,
nil
if
err
!=
nil
{
}
return
nil
,
err
func
saveRuleHeightIndex
(
res
*
auty
.
ReceiptProposalRule
)
(
kvs
[]
*
types
.
KeyValue
)
{
// 先将之前的状态删除掉,再做更新
if
res
.
Current
.
Status
>
1
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcRuleKey4StatusHeight
(
res
.
Prev
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Prev
.
Height
,
int64
(
res
.
Prev
.
Index
)))
kv
.
Value
=
nil
kvs
=
append
(
kvs
,
kv
)
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
kv
:=
&
types
.
KeyValue
{}
return
dbSet
,
nil
kv
.
Key
=
calcRuleKey4StatusHeight
(
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
)
execDelLocalRule
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execDelLocalRule
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
table
:=
NewRuleTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
var
receipt
auty
.
ReceiptProposalRule
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
return
nil
,
err
}
switch
log
.
Ty
{
switch
log
.
Ty
{
case
auty
.
TyLogPropRule
,
case
auty
.
TyLogPropRule
:
auty
.
TyLogRvkPropRule
,
{
heightIndex
:=
dapp
.
HeightIndexStr
(
receipt
.
Current
.
Height
,
int64
(
receipt
.
Current
.
Index
))
err
=
table
.
Del
([]
byte
(
heightIndex
))
if
err
!=
nil
{
return
nil
,
err
}
}
case
auty
.
TyLogRvkPropRule
,
auty
.
TyLogVotePropRule
,
auty
.
TyLogVotePropRule
,
auty
.
TyLogTmintPropRule
:
auty
.
TyLogTmintPropRule
:
{
{
var
receipt
auty
.
ReceiptProposalRule
err
=
table
.
Replace
(
receipt
.
Prev
)
err
:=
types
.
Decode
(
log
.
Log
,
&
receipt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
kv
:=
delRuleHeightIndex
(
&
receipt
)
set
=
append
(
set
,
kv
...
)
}
}
default
:
default
:
break
break
}
}
}
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
set
...
)
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
func
delRuleHeightIndex
(
res
*
auty
.
ReceiptProposalRule
)
(
kvs
[]
*
types
.
KeyValue
)
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcRuleKey4StatusHeight
(
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
=
calcRuleKey4StatusHeight
(
res
.
Prev
.
Status
,
dapp
.
HeightIndexStr
(
res
.
Prev
.
Height
,
int64
(
res
.
Prev
.
Index
)))
kv
.
Value
=
types
.
Encode
(
res
.
Prev
)
kvs
=
append
(
kvs
,
kv
)
}
return
kvs
}
func
(
a
*
Autonomy
)
getProposalRule
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
func
(
a
*
Autonomy
)
getProposalRule
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
if
req
==
nil
{
if
req
==
nil
{
...
@@ -115,35 +104,49 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa
...
@@ -115,35 +104,49 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa
if
req
==
nil
{
if
req
==
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
//var key []byte
//var values [][]byte
localDb
:=
a
.
GetLocalDB
()
//var err error
query
:=
NewRuleTable
(
localDb
)
.
GetQuery
(
localDb
)
//
var
primary
[]
byte
//localDb := a.GetLocalDB()
if
req
.
Height
>
0
{
//if req.GetIndex() == -1 {
primary
=
[]
byte
(
dapp
.
HeightIndexStr
(
req
.
Height
,
int64
(
req
.
Index
)))
// key = nil
}
//} else { //翻页查找指定的txhash列表
indexName
:=
""
// heightstr := genHeightIndexStr(req.GetIndex())
if
req
.
Status
>
0
&&
req
.
Addr
!=
""
{
// key = calcRuleKey4StatusHeight(req.Status, heightstr)
indexName
=
"addr_status"
//}
}
else
if
req
.
Status
>
0
{
//prefix := calcRuleKey4StatusHeight(req.Status, "")
indexName
=
"status"
//values, err = localDb.List(prefix, key, req.Count, req.GetDirection())
}
else
if
req
.
Addr
!=
""
{
//if err != nil {
indexName
=
"addr"
// return nil, err
}
//}
//if len(values) == 0 {
cur
:=
&
RuleRow
{
// return nil, types.ErrNotFound
AutonomyProposalRule
:
&
auty
.
AutonomyProposalRule
{},
//}
}
cur
.
Address
=
req
.
Addr
cur
.
Status
=
req
.
Status
cur
.
Height
=
req
.
Height
cur
.
Index
=
req
.
Index
prefix
,
err
:=
cur
.
Get
(
indexName
)
rows
,
err
:=
query
.
ListIndex
(
indexName
,
prefix
,
primary
,
req
.
Count
,
req
.
Direction
)
if
err
!=
nil
{
alog
.
Error
(
"query List failed"
,
"indexName"
,
indexName
,
"prefix"
,
"prefix"
,
"key"
,
string
(
primary
),
"err"
,
err
)
return
nil
,
err
}
if
len
(
rows
)
==
0
{
return
nil
,
types
.
ErrNotFound
}
var
rep
auty
.
ReplyQueryProposalRule
var
rep
auty
.
ReplyQueryProposalRule
//for _, value := range value
s {
for
_
,
row
:=
range
row
s
{
// prop := &auty.AutonomyProposalRule{}
r
,
ok
:=
row
.
Data
.
(
*
auty
.
AutonomyProposalRule
)
// err = types.Decode(value, prop)
if
!
ok
{
// if err != nil {
alog
.
Error
(
"listProposalRule"
,
"err"
,
"bad row type"
)
// return nil, err
return
nil
,
types
.
ErrDecode
//
}
}
// rep.PropRules = append(rep.PropRules, prop
)
rep
.
PropRules
=
append
(
rep
.
PropRules
,
r
)
//
}
}
return
&
rep
,
nil
return
&
rep
,
nil
}
}
...
@@ -224,10 +227,10 @@ func (a *Autonomy) listProposalComment(req *auty.ReqQueryProposalComment) (types
...
@@ -224,10 +227,10 @@ func (a *Autonomy) listProposalComment(req *auty.ReqQueryProposalComment) (types
var
err
error
var
err
error
localDb
:=
a
.
GetLocalDB
()
localDb
:=
a
.
GetLocalDB
()
if
req
.
GetIndex
()
==
-
1
{
if
req
.
Height
<=
0
{
key
=
nil
key
=
nil
}
else
{
//翻页查找指定的txhash列表
}
else
{
//翻页查找指定的txhash列表
heightstr
:=
genHeightIndexStr
(
req
.
GetIndex
(
))
heightstr
:=
dapp
.
HeightIndexStr
(
req
.
Height
,
int64
(
req
.
Index
))
key
=
calcCommentHeight
(
req
.
ProposalID
,
heightstr
)
key
=
calcCommentHeight
(
req
.
ProposalID
,
heightstr
)
}
}
prefix
:=
calcCommentHeight
(
req
.
ProposalID
,
""
)
prefix
:=
calcCommentHeight
(
req
.
ProposalID
,
""
)
...
...
plugin/dapp/autonomy/executor/rule_test.go
View file @
9b962259
...
@@ -12,10 +12,14 @@ import (
...
@@ -12,10 +12,14 @@ import (
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/util"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/33cn/chain33/common/db"
)
)
func
TestExecLocalRule
(
t
*
testing
.
T
)
{
func
TestExecLocalRule
(
t
*
testing
.
T
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
//TyLogPropRule
//TyLogPropRule
cur
:=
&
auty
.
AutonomyProposalRule
{
cur
:=
&
auty
.
AutonomyProposalRule
{
PropRule
:
&
auty
.
ProposalRule
{},
PropRule
:
&
auty
.
ProposalRule
{},
...
@@ -38,14 +42,15 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -38,14 +42,15 @@ func TestExecLocalRule(t *testing.T) {
set
,
err
:=
au
.
execLocalRule
(
receipt
)
set
,
err
:=
au
.
execLocalRule
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcRuleKey4StatusHeight
(
cur
.
Status
,
//save to database
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalRule
(
t
,
kvdb
,
cur
)
// TyLogRvkPropRule
// TyLogRvkPropRule
pre1
:=
copyAutonomyProposalRule
(
cur
)
pre1
:=
copyAutonomyProposalRule
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusRvkPropRule
cur
.
Status
=
auty
.
AutonomyStatusRvkPropRule
cur
.
Height
=
2
cur
.
Index
=
3
receiptRule1
:=
&
auty
.
ReceiptProposalRule
{
receiptRule1
:=
&
auty
.
ReceiptProposalRule
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
...
@@ -57,11 +62,11 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -57,11 +62,11 @@ func TestExecLocalRule(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcRuleKey4StatusHeight
(
pre1
.
Status
,
//save to database
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre1
.
Index
)))
)
saveKvs
(
sdb
,
set
.
KV
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcRuleKey4StatusHeight
(
cur
.
Status
,
// check
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
)))
)
checkExecLocalRule
(
t
,
kvdb
,
cur
)
// TyLogVotePropRule
// TyLogVotePropRule
cur
.
Status
=
auty
.
AutonomyStatusProposalRule
cur
.
Status
=
auty
.
AutonomyStatusProposalRule
...
@@ -69,8 +74,9 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -69,8 +74,9 @@ func TestExecLocalRule(t *testing.T) {
cur
.
Index
=
2
cur
.
Index
=
2
pre2
:=
copyAutonomyProposalRule
(
cur
)
pre2
:=
copyAutonomyProposalRule
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropRule
cur
.
Status
=
auty
.
AutonomyStatusVotePropRule
cur
.
Height
=
2
cur
.
Height
=
1
cur
.
Index
=
3
cur
.
Index
=
2
cur
.
Address
=
"2222222222222"
receiptRule2
:=
&
auty
.
ReceiptProposalRule
{
receiptRule2
:=
&
auty
.
ReceiptProposalRule
{
Prev
:
pre2
,
Prev
:
pre2
,
Current
:
cur
,
Current
:
cur
,
...
@@ -82,15 +88,16 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -82,15 +88,16 @@ func TestExecLocalRule(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcRuleKey4StatusHeight
(
pre2
.
Status
,
//save to database
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre2
.
Index
))))
saveKvs
(
sdb
,
set
.
KV
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
// check
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcRuleKey4StatusHeight
(
cur
.
Status
,
checkExecLocalRule
(
t
,
kvdb
,
cur
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
}
}
func
TestExecDelLocalRule
(
t
*
testing
.
T
)
{
func
TestExecDelLocalRule
(
t
*
testing
.
T
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
//TyLogPropRule
//TyLogPropRule
cur
:=
&
auty
.
AutonomyProposalRule
{
cur
:=
&
auty
.
AutonomyProposalRule
{
PropRule
:
&
auty
.
ProposalRule
{},
PropRule
:
&
auty
.
ProposalRule
{},
...
@@ -110,22 +117,47 @@ func TestExecDelLocalRule(t *testing.T) {
...
@@ -110,22 +117,47 @@ func TestExecDelLocalRule(t *testing.T) {
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalRule
(
receipt
)
// 先执行local然后进行删除
set
,
err
:=
au
.
execLocalRule
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execDelLocalRule
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcRuleKey4StatusHeight
(
cur
.
Status
,
saveKvs
(
sdb
,
set
.
KV
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
table
:=
NewRuleTable
(
au
.
GetLocalDB
())
query
:=
table
.
GetQuery
(
kvdb
)
_
,
err
=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"addr"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
_
,
err
=
query
.
ListIndex
(
"addr_status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
// TyLogVotePropRule
// TyLogVotePropRule
pre1
:=
copyAutonomyProposalRule
(
cur
)
pre1
:=
copyAutonomyProposalRule
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropRule
cur
.
Status
=
auty
.
AutonomyStatusVotePropRule
cur
.
Height
=
2
cur
.
Index
=
3
receiptRule2
:=
&
auty
.
ReceiptProposalRule
{
receiptRule2
:=
&
auty
.
ReceiptProposalRule
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
// 先执行local然后进行删除
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
},
})
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalRule
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execDelLocalRule
(
&
types
.
ReceiptData
{
set
,
err
=
au
.
execDelLocalRule
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
...
@@ -133,12 +165,35 @@ func TestExecDelLocalRule(t *testing.T) {
...
@@ -133,12 +165,35 @@ func TestExecDelLocalRule(t *testing.T) {
})
})
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcRuleKey4StatusHeight
(
cur
.
Status
,
saveKvs
(
sdb
,
set
.
KV
)
dapp
.
HeightIndexStr
(
cur
.
Height
,
int64
(
cur
.
Index
))))
// check
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Value
,
[]
byte
(
nil
))
checkExecLocalRule
(
t
,
kvdb
,
pre1
)
require
.
Equal
(
t
,
set
.
KV
[
1
]
.
Key
,
calcRuleKey4StatusHeight
(
pre1
.
Status
,
}
dapp
.
HeightIndexStr
(
pre1
.
Height
,
int64
(
pre1
.
Index
))))
require
.
NotNil
(
t
,
set
.
KV
[
1
]
.
Value
)
func
checkExecLocalRule
(
t
*
testing
.
T
,
kvdb
db
.
KVDB
,
cur
*
auty
.
AutonomyProposalRule
)
{
table
:=
NewRuleTable
(
kvdb
)
query
:=
table
.
GetQuery
(
kvdb
)
rows
,
err
:=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
string
(
rows
[
0
]
.
Primary
),
dapp
.
HeightIndexStr
(
1
,
2
))
rows
,
err
=
query
.
ListIndex
(
"addr"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
rows
,
err
=
query
.
ListIndex
(
"status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
rows
,
err
=
query
.
ListIndex
(
"addr_status"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
nil
)
assert
.
Equal
(
t
,
1
,
len
(
rows
))
prop
,
ok
:=
rows
[
0
]
.
Data
.
(
*
auty
.
AutonomyProposalRule
)
assert
.
Equal
(
t
,
true
,
ok
)
assert
.
Equal
(
t
,
prop
,
cur
)
}
}
func
TestGetProposalRule
(
t
*
testing
.
T
)
{
func
TestGetProposalRule
(
t
*
testing
.
T
)
{
...
@@ -159,7 +214,7 @@ func TestListProposalRule(t *testing.T) {
...
@@ -159,7 +214,7 @@ func TestListProposalRule(t *testing.T) {
au
:=
&
Autonomy
{
au
:=
&
Autonomy
{
dapp
.
DriverBase
{},
dapp
.
DriverBase
{},
}
}
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
type
statu
struct
{
type
statu
struct
{
...
@@ -190,15 +245,22 @@ func TestListProposalRule(t *testing.T) {
...
@@ -190,15 +245,22 @@ func TestListProposalRule(t *testing.T) {
Height
:
1
,
Height
:
1
,
Index
:
2
,
Index
:
2
,
}
}
//将数据保存下去
var
kvs
[]
*
types
.
KeyValue
table
:=
NewRuleTable
(
kvdb
)
for
_
,
tcase
:=
range
testcase
{
for
_
,
tcase
:=
range
testcase
{
key
:=
calcRuleKey4StatusHeight
(
tcase
.
status
,
dapp
.
HeightIndexStr
(
tcase
.
height
,
int64
(
tcase
.
index
)))
cur
.
Status
=
tcase
.
status
cur
.
Status
=
tcase
.
status
cur
.
Height
=
tcase
.
height
cur
.
Height
=
tcase
.
height
cur
.
Index
=
int32
(
tcase
.
index
)
cur
.
Index
=
int32
(
tcase
.
index
)
value
:=
types
.
Encode
(
cur
)
kvdb
.
Set
(
key
,
value
)
err
:=
table
.
Replace
(
cur
)
require
.
NoError
(
t
,
err
)
kv
,
err
:=
table
.
Save
()
require
.
NoError
(
t
,
err
)
kvs
=
append
(
kvs
,
kv
...
)
}
}
saveKvs
(
sdb
,
kvs
)
// 反向查找
// 反向查找
req
:=
&
auty
.
ReqQueryProposalRule
{
req
:=
&
auty
.
ReqQueryProposalRule
{
...
@@ -407,12 +469,12 @@ func TestListProposalComment(t *testing.T) {
...
@@ -407,12 +469,12 @@ func TestListProposalComment(t *testing.T) {
require
.
Equal
(
t
,
height
,
testcase2
[
2
]
.
height
)
require
.
Equal
(
t
,
height
,
testcase2
[
2
]
.
height
)
require
.
Equal
(
t
,
index
,
int32
(
testcase2
[
2
]
.
index
))
require
.
Equal
(
t
,
index
,
int32
(
testcase2
[
2
]
.
index
))
//
//
Index
:=
height
*
types
.
MaxTxsPerBlock
+
int64
(
index
)
req
=
&
auty
.
ReqQueryProposalComment
{
req
=
&
auty
.
ReqQueryProposalComment
{
ProposalID
:
propID2
,
ProposalID
:
propID2
,
Count
:
10
,
Count
:
10
,
Direction
:
0
,
Direction
:
0
,
Index
:
Index
,
Height
:
height
,
Index
:
index
,
}
}
rsp
,
err
=
au
.
listProposalComment
(
req
)
rsp
,
err
=
au
.
listProposalComment
(
req
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
...
plugin/dapp/autonomy/executor/ruletable.go
0 → 100644
View file @
9b962259
package
executor
import
(
"fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/33cn/chain33/system/dapp"
)
/*
table struct
data: autonomy rule
index: status, addr
*/
var
ruleOpt
=
&
table
.
Option
{
Prefix
:
"LODB-autonomy"
,
Name
:
"rule"
,
Primary
:
"heightindex"
,
Index
:
[]
string
{
"addr"
,
"status"
,
"addr_status"
},
}
//NewTable 新建表
func
NewRuleTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewRuleRow
()
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
ruleOpt
)
if
err
!=
nil
{
panic
(
err
)
}
return
table
}
//RuleRow table meta 结构
type
RuleRow
struct
{
*
auty
.
AutonomyProposalRule
}
//NewRuleRow 新建一个meta 结构
func
NewRuleRow
()
*
RuleRow
{
return
&
RuleRow
{
AutonomyProposalRule
:
&
auty
.
AutonomyProposalRule
{}}
}
//CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存heightindex)
func
(
r
*
RuleRow
)
CreateRow
()
*
table
.
Row
{
return
&
table
.
Row
{
Data
:
&
auty
.
AutonomyProposalRule
{}}
}
//SetPayload 设置数据
func
(
r
*
RuleRow
)
SetPayload
(
data
types
.
Message
)
error
{
if
d
,
ok
:=
data
.
(
*
auty
.
AutonomyProposalRule
);
ok
{
r
.
AutonomyProposalRule
=
d
return
nil
}
return
types
.
ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func
(
r
*
RuleRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"heightindex"
{
return
[]
byte
(
dapp
.
HeightIndexStr
(
r
.
Height
,
int64
(
r
.
Index
))),
nil
}
else
if
key
==
"status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
r
.
Status
)),
nil
}
else
if
key
==
"addr"
{
return
[]
byte
(
r
.
Address
),
nil
}
else
if
key
==
"addr_status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
r
.
Address
,
r
.
Status
)),
nil
}
return
nil
,
types
.
ErrNotFound
}
plugin/dapp/autonomy/proto/board.proto
View file @
9b962259
...
@@ -65,12 +65,12 @@ message LocalProposalBoard {
...
@@ -65,12 +65,12 @@ message LocalProposalBoard {
// query
// query
message
ReqQueryProposalBoard
{
message
ReqQueryProposalBoard
{
int32
count
=
1
;
int32
status
=
1
;
int32
direction
=
2
;
string
addr
=
2
;
int
64
height
=
3
;
int
32
count
=
3
;
int32
index
=
4
;
int32
direction
=
4
;
int
32
status
=
5
;
int
64
height
=
5
;
string
addr
=
6
;
int32
index
=
6
;
}
}
message
ReplyQueryProposalBoard
{
message
ReplyQueryProposalBoard
{
...
...
plugin/dapp/autonomy/proto/project.proto
View file @
9b962259
...
@@ -82,12 +82,12 @@ message LocalProposalProject {
...
@@ -82,12 +82,12 @@ message LocalProposalProject {
// query
// query
message
ReqQueryProposalProject
{
message
ReqQueryProposalProject
{
int32
count
=
1
;
int32
status
=
1
;
int32
direction
=
2
;
string
addr
=
2
;
int
64
height
=
3
;
int
32
count
=
3
;
int32
index
=
4
;
int32
direction
=
4
;
int
32
status
=
5
;
int
64
height
=
5
;
string
addr
=
6
;
int32
index
=
6
;
}
}
message
ReplyQueryProposalProject
{
message
ReplyQueryProposalProject
{
...
...
plugin/dapp/autonomy/proto/rule.proto
View file @
9b962259
...
@@ -61,12 +61,12 @@ message LocalProposalRule {
...
@@ -61,12 +61,12 @@ message LocalProposalRule {
// query
// query
message
ReqQueryProposalRule
{
message
ReqQueryProposalRule
{
int32
count
=
1
;
int32
status
=
1
;
int32
direction
=
2
;
string
addr
=
2
;
int
64
height
=
3
;
int
32
count
=
3
;
int32
index
=
4
;
int32
direction
=
4
;
int
32
status
=
5
;
int
64
height
=
5
;
string
addr
=
6
;
int32
index
=
6
;
}
}
message
ReplyQueryProposalRule
{
message
ReplyQueryProposalRule
{
...
@@ -98,7 +98,8 @@ message ReqQueryProposalComment {
...
@@ -98,7 +98,8 @@ message ReqQueryProposalComment {
string
proposalID
=
1
;
string
proposalID
=
1
;
int32
count
=
2
;
int32
count
=
2
;
int32
direction
=
3
;
int32
direction
=
3
;
int64
index
=
4
;
int64
height
=
4
;
int32
index
=
5
;
}
}
message
RelationCmt
{
message
RelationCmt
{
...
...
plugin/dapp/autonomy/types/board.pb.go
View file @
9b962259
...
@@ -262,12 +262,12 @@ func (m *LocalProposalBoard) GetComments() []string {
...
@@ -262,12 +262,12 @@ func (m *LocalProposalBoard) GetComments() []string {
// query
// query
type
ReqQueryProposalBoard
struct
{
type
ReqQueryProposalBoard
struct
{
Count
int32
`protobuf:"varint,1,opt,name=count" json:"count
,omitempty"`
Status
int32
`protobuf:"varint,1,opt,name=status" json:"status
,omitempty"`
Direction
int32
`protobuf:"varint,2,opt,name=direction" json:"direction
,omitempty"`
Addr
string
`protobuf:"bytes,2,opt,name=addr" json:"addr
,omitempty"`
Height
int64
`protobuf:"varint,3,opt,name=height" json:"heigh
t,omitempty"`
Count
int32
`protobuf:"varint,3,opt,name=count" json:"coun
t,omitempty"`
Index
int32
`protobuf:"varint,4,opt,name=index" json:"index
,omitempty"`
Direction
int32
`protobuf:"varint,4,opt,name=direction" json:"direction
,omitempty"`
Status
int32
`protobuf:"varint,5,opt,name=status" json:"status
,omitempty"`
Height
int64
`protobuf:"varint,5,opt,name=height" json:"height
,omitempty"`
Addr
string
`protobuf:"bytes,6,opt,name=addr" json:"addr
,omitempty"`
Index
int32
`protobuf:"varint,6,opt,name=index" json:"index
,omitempty"`
}
}
func
(
m
*
ReqQueryProposalBoard
)
Reset
()
{
*
m
=
ReqQueryProposalBoard
{}
}
func
(
m
*
ReqQueryProposalBoard
)
Reset
()
{
*
m
=
ReqQueryProposalBoard
{}
}
...
@@ -275,46 +275,46 @@ func (m *ReqQueryProposalBoard) String() string { return proto.Compac
...
@@ -275,46 +275,46 @@ func (m *ReqQueryProposalBoard) String() string { return proto.Compac
func
(
*
ReqQueryProposalBoard
)
ProtoMessage
()
{}
func
(
*
ReqQueryProposalBoard
)
ProtoMessage
()
{}
func
(
*
ReqQueryProposalBoard
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor1
,
[]
int
{
7
}
}
func
(
*
ReqQueryProposalBoard
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor1
,
[]
int
{
7
}
}
func
(
m
*
ReqQueryProposalBoard
)
Get
Count
()
int32
{
func
(
m
*
ReqQueryProposalBoard
)
Get
Status
()
int32
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Count
return
m
.
Status
}
}
return
0
return
0
}
}
func
(
m
*
ReqQueryProposalBoard
)
Get
Direction
()
int32
{
func
(
m
*
ReqQueryProposalBoard
)
Get
Addr
()
string
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Direction
return
m
.
Addr
}
}
return
0
return
""
}
}
func
(
m
*
ReqQueryProposalBoard
)
Get
Height
()
int64
{
func
(
m
*
ReqQueryProposalBoard
)
Get
Count
()
int32
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Heigh
t
return
m
.
Coun
t
}
}
return
0
return
0
}
}
func
(
m
*
ReqQueryProposalBoard
)
Get
Index
()
int32
{
func
(
m
*
ReqQueryProposalBoard
)
Get
Direction
()
int32
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Index
return
m
.
Direction
}
}
return
0
return
0
}
}
func
(
m
*
ReqQueryProposalBoard
)
Get
Status
()
int32
{
func
(
m
*
ReqQueryProposalBoard
)
Get
Height
()
int64
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Status
return
m
.
Height
}
}
return
0
return
0
}
}
func
(
m
*
ReqQueryProposalBoard
)
Get
Addr
()
string
{
func
(
m
*
ReqQueryProposalBoard
)
Get
Index
()
int32
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Addr
return
m
.
Index
}
}
return
""
return
0
}
}
type
ReplyQueryProposalBoard
struct
{
type
ReplyQueryProposalBoard
struct
{
...
@@ -348,40 +348,39 @@ func init() {
...
@@ -348,40 +348,39 @@ func init() {
func
init
()
{
proto
.
RegisterFile
(
"board.proto"
,
fileDescriptor1
)
}
func
init
()
{
proto
.
RegisterFile
(
"board.proto"
,
fileDescriptor1
)
}
var
fileDescriptor1
=
[]
byte
{
var
fileDescriptor1
=
[]
byte
{
// 54
5
bytes of a gzipped FileDescriptorProto
// 54
4
bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x94
,
0x54
,
0x4d
,
0x6f
,
0xd3
,
0x40
,
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x94
,
0x54
,
0x4d
,
0x6f
,
0xd3
,
0x40
,
0x10
,
0x
95
,
0xe3
,
0x38
,
0x1f
,
0x53
,
0x15
,
0xb5
,
0x4b
,
0x5a
,
0xac
,
0xaa
,
0x42
,
0x91
,
0x0f
,
0x28
,
0x10
,
0x
d5
,
0x26
,
0x71
,
0x3e
,
0xa6
,
0x2a
,
0x6a
,
0x97
,
0xb4
,
0x58
,
0x55
,
0x85
,
0x22
,
0x1f
,
0x50
,
0x0
2
,
0x29
,
0x82
,
0xf2
,
0x21
,
0x0e
,
0x5c
,
0x08
,
0x20
,
0x81
,
0x04
,
0x12
,
0xac
,
0x10
,
0x9c
,
0xb7
,
0x0
4
,
0x52
,
0x04
,
0xe5
,
0x43
,
0x1c
,
0xb8
,
0x10
,
0x40
,
0x02
,
0x09
,
0x24
,
0x58
,
0x21
,
0x38
,
0xbb
,
0xf6
,
0xb4
,
0xb1
,
0xea
,
0xec
,
0x2e
,
0xeb
,
0x75
,
0x
44
,
0x6e
,
0xfc
,
0x19
,
0x4e
,
0xfc
,
0x30
,
0xfe
,
0xf6
,
0xb4
,
0xb1
,
0xea
,
0xec
,
0x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fe
,
0x57
,
0xf6
,
0xf8
,
0x4f
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0x4e
,
0x49
,
0x65
,
0xe0
,
0xef
,
0x04
,
0x00
,
0xca
,
0x1e
,
0xff
,
0x09
,
0x00
,
0x00
,
0xff
,
0xff
,
0x3d
,
0x91
,
0x96
,
0xe2
,
0xef
,
0x04
,
0x00
,
0x00
,
0x00
,
}
}
plugin/dapp/autonomy/types/project.pb.go
View file @
9b962259
This diff is collapsed.
Click to expand it.
plugin/dapp/autonomy/types/rule.pb.go
View file @
9b962259
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