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
996f4ff5
Commit
996f4ff5
authored
Aug 06, 2019
by
liuyuhang
Committed by
33cn
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add auto rollback
parent
401ebb9e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
558 additions
and
137 deletions
+558
-137
chain33.para.toml
chain33.para.toml
+1
-0
chain33.toml
chain33.toml
+1
-0
autonomy.go
plugin/dapp/autonomy/executor/autonomy.go
+3
-2
board.go
plugin/dapp/autonomy/executor/board.go
+22
-2
board_test.go
plugin/dapp/autonomy/executor/board_test.go
+120
-43
exec_del_local.go
plugin/dapp/autonomy/executor/exec_del_local.go
+42
-0
exec_local.go
plugin/dapp/autonomy/executor/exec_local.go
+42
-0
project.go
plugin/dapp/autonomy/executor/project.go
+12
-2
project_test.go
plugin/dapp/autonomy/executor/project_test.go
+122
-44
rule.go
plugin/dapp/autonomy/executor/rule.go
+20
-0
rule_test.go
plugin/dapp/autonomy/executor/rule_test.go
+173
-44
No files found.
chain33.para.toml
View file @
996f4ff5
...
@@ -179,6 +179,7 @@ paraConsensusStopBlocks=30000
...
@@ -179,6 +179,7 @@ paraConsensusStopBlocks=30000
[exec.sub.autonomy]
[exec.sub.autonomy]
total
=
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
total
=
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
useBalance
=
false
useBalance
=
false
autoRollback
=
false
#系统中所有的fork,默认用chain33的测试网络的
#系统中所有的fork,默认用chain33的测试网络的
...
...
chain33.toml
View file @
996f4ff5
...
@@ -226,4 +226,5 @@ paraConsensusStopBlocks=30000
...
@@ -226,4 +226,5 @@ paraConsensusStopBlocks=30000
[exec.sub.autonomy]
[exec.sub.autonomy]
total
=
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
total
=
"16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
useBalance
=
false
useBalance
=
false
autoRollback
=
false
plugin/dapp/autonomy/executor/autonomy.go
View file @
996f4ff5
...
@@ -13,8 +13,9 @@ import (
...
@@ -13,8 +13,9 @@ import (
)
)
type
subConfig
struct
{
type
subConfig
struct
{
Total
string
`json:"total"`
Total
string
`json:"total"`
UseBalance
bool
`json:"useBalance"`
UseBalance
bool
`json:"useBalance"`
AutoRollback
bool
`json:"autoRollback"`
}
}
var
(
var
(
...
...
plugin/dapp/autonomy/executor/board.go
View file @
996f4ff5
...
@@ -10,8 +10,17 @@ import (
...
@@ -10,8 +10,17 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
)
func
(
a
*
Autonomy
)
execLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execAutoLocalBoard
(
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
a
.
execLocalBoard
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
[]
byte
(
tx
.
Execer
),
set
.
KV
)
return
dbSet
,
nil
}
func
(
a
*
Autonomy
)
execLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
table
:=
NewBoardTable
(
a
.
GetLocalDB
())
table
:=
NewBoardTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
switch
log
.
Ty
{
...
@@ -39,12 +48,22 @@ func (a *Autonomy) execLocalBoard(receiptData *types.ReceiptData) (*types.LocalD
...
@@ -39,12 +48,22 @@ func (a *Autonomy) execLocalBoard(receiptData *types.ReceiptData) (*types.LocalD
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
func
(
a
*
Autonomy
)
execDelLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execAutoDelLocal
(
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
kvs
,
err
:=
a
.
DelRollbackKV
(
tx
,
[]
byte
(
tx
.
Execer
))
if
err
!=
nil
{
return
nil
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
}
func
(
a
*
Autonomy
)
execDelLocalBoard
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
table
:=
NewBoardTable
(
a
.
GetLocalDB
())
table
:=
NewBoardTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
var
receipt
auty
.
ReceiptProposalBoard
var
receipt
auty
.
ReceiptProposalBoard
...
@@ -78,6 +97,7 @@ func (a *Autonomy) execDelLocalBoard(receiptData *types.ReceiptData) (*types.Loc
...
@@ -78,6 +97,7 @@ func (a *Autonomy) execDelLocalBoard(receiptData *types.ReceiptData) (*types.Loc
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
...
...
plugin/dapp/autonomy/executor/board_test.go
View file @
996f4ff5
...
@@ -17,6 +17,11 @@ import (
...
@@ -17,6 +17,11 @@ import (
)
)
func
TestExecLocalBoard
(
t
*
testing
.
T
)
{
func
TestExecLocalBoard
(
t
*
testing
.
T
)
{
testexecLocalBoard
(
t
,
false
)
testexecLocalBoard
(
t
,
true
)
}
func
testexecLocalBoard
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
...
@@ -39,7 +44,17 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -39,7 +44,17 @@ func TestExecLocalBoard(t *testing.T) {
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
},
},
}
}
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
var
set
*
types
.
LocalDBSet
var
err
error
if
auto
==
false
{
set
,
err
=
au
.
execLocalBoard
(
receipt
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalBoard
(
tx
,
receipt
)
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
//save to database
//save to database
...
@@ -55,11 +70,23 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -55,11 +70,23 @@ func TestExecLocalBoard(t *testing.T) {
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
if
auto
==
false
{
Logs
:
[]
*
types
.
ReceiptLog
{
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
{
Ty
:
auty
.
TyLogRvkPropBoard
,
Log
:
types
.
Encode
(
receiptBoard1
)},
Logs
:
[]
*
types
.
ReceiptLog
{
},
{
Ty
:
auty
.
TyLogRvkPropBoard
,
Log
:
types
.
Encode
(
receiptBoard1
)},
})
},
})
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalBoard
(
tx
,
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogRvkPropBoard
,
Log
:
types
.
Encode
(
receiptBoard1
)},
},
})
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
...
@@ -71,22 +98,30 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -71,22 +98,30 @@ func TestExecLocalBoard(t *testing.T) {
// TyLogVotePropBoard
// TyLogVotePropBoard
cur
.
Status
=
auty
.
AutonomyStatusProposalBoard
cur
.
Status
=
auty
.
AutonomyStatusProposalBoard
cur
.
Height
=
1
cur
.
Index
=
2
pre2
:=
copyAutonomyProposalBoard
(
cur
)
pre2
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Height
=
1
cur
.
Index
=
2
cur
.
Address
=
"2222222222222"
cur
.
Address
=
"2222222222222"
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
Prev
:
pre2
,
Prev
:
pre2
,
Current
:
cur
,
Current
:
cur
,
}
}
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
if
auto
==
false
{
Logs
:
[]
*
types
.
ReceiptLog
{
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
Logs
:
[]
*
types
.
ReceiptLog
{
},
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
})
},
})
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalBoard
(
tx
,
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
},
})
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
//save to database
//save to database
...
@@ -96,6 +131,11 @@ func TestExecLocalBoard(t *testing.T) {
...
@@ -96,6 +131,11 @@ func TestExecLocalBoard(t *testing.T) {
}
}
func
TestExecDelLocalBoard
(
t
*
testing
.
T
)
{
func
TestExecDelLocalBoard
(
t
*
testing
.
T
)
{
testexecDelLocalBoard
(
t
,
false
)
testexecDelLocalBoard
(
t
,
true
)
}
func
testexecDelLocalBoard
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
...
@@ -118,16 +158,33 @@ func TestExecDelLocalBoard(t *testing.T) {
...
@@ -118,16 +158,33 @@ func TestExecDelLocalBoard(t *testing.T) {
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
{
Ty
:
auty
.
TyLogPropBoard
,
Log
:
types
.
Encode
(
receiptBoard
)},
},
},
}
}
var
set
*
types
.
LocalDBSet
var
err
error
// 先执行local然后进行删除
// 先执行local然后进行删除
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
if
auto
==
false
{
require
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execLocalBoard
(
receipt
)
require
.
NotNil
(
t
,
set
)
require
.
NoError
(
t
,
err
)
saveKvs
(
sdb
,
set
.
KV
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execDelLocalBoard
(
receipt
)
set
,
err
=
au
.
execDelLocalBoard
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
saveKvs
(
sdb
,
set
.
KV
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execAutoLocalBoard
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
// check
// check
table
:=
NewBoardTable
(
au
.
GetLocalDB
())
table
:=
NewBoardTable
(
au
.
GetLocalDB
())
...
@@ -144,35 +201,55 @@ func TestExecDelLocalBoard(t *testing.T) {
...
@@ -144,35 +201,55 @@ func TestExecDelLocalBoard(t *testing.T) {
// TyLogVotePropBoard
// TyLogVotePropBoard
pre1
:=
copyAutonomyProposalBoard
(
cur
)
pre1
:=
copyAutonomyProposalBoard
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Status
=
auty
.
AutonomyStatusVotePropBoard
cur
.
Height
=
1
cur
.
Index
=
2
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
receiptBoard2
:=
&
auty
.
ReceiptProposalBoard
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
// 先执行local然后进行删除
recpt
:=
&
types
.
ReceiptData
{
set
,
err
=
au
.
execLocalBoard
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
},
}}
})
// 先执行local然后进行删除
require
.
NoError
(
t
,
err
)
if
auto
==
false
{
require
.
NotNil
(
t
,
set
)
set
,
err
=
au
.
execLocalBoard
(
recpt
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execDelLocalBoard
(
&
types
.
ReceiptData
{
require
.
NoError
(
t
,
err
)
Logs
:
[]
*
types
.
ReceiptLog
{
require
.
NotNil
(
t
,
set
)
{
Ty
:
auty
.
TyLogVotePropBoard
,
Log
:
types
.
Encode
(
receiptBoard2
)},
saveKvs
(
sdb
,
set
.
KV
)
},
// check
})
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
set
,
err
=
au
.
execDelLocalBoard
(
recpt
)
saveKvs
(
sdb
,
set
.
KV
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
else
{
// 自动回退测试时候,需要先设置一个前置状态
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execAutoLocalBoard
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// 正常测试退回
tx
,
err
=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalBoard
(
tx
,
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalBoard
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
// check
// check
checkExecLocalBoard
(
t
,
kvdb
,
pre1
)
checkExecLocalBoard
(
t
,
kvdb
,
pre1
)
}
}
func
TestGetProposalBoard
(
t
*
testing
.
T
)
{
func
TestGetProposalBoard
(
t
*
testing
.
T
)
{
...
...
plugin/dapp/autonomy/executor/exec_del_local.go
View file @
996f4ff5
...
@@ -13,21 +13,33 @@ import (
...
@@ -13,21 +13,33 @@ import (
// ExecDelLocal_PropBoard 创建提案董事会
// ExecDelLocal_PropBoard 创建提案董事会
func
(
a
*
Autonomy
)
ExecDelLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalBoard
(
receiptData
)
return
a
.
execDelLocalBoard
(
receiptData
)
}
}
// ExecDelLocal_RvkPropBoard 撤销提案
// ExecDelLocal_RvkPropBoard 撤销提案
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalBoard
(
receiptData
)
return
a
.
execDelLocalBoard
(
receiptData
)
}
}
// ExecDelLocal_VotePropBoard 投票提案
// ExecDelLocal_VotePropBoard 投票提案
func
(
a
*
Autonomy
)
ExecDelLocal_VotePropBoard
(
payload
*
auty
.
VoteProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_VotePropBoard
(
payload
*
auty
.
VoteProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalBoard
(
receiptData
)
return
a
.
execDelLocalBoard
(
receiptData
)
}
}
// ExecDelLocal_TmintPropBoard 终止提案
// ExecDelLocal_TmintPropBoard 终止提案
func
(
a
*
Autonomy
)
ExecDelLocal_TmintPropBoard
(
payload
*
auty
.
TerminateProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_TmintPropBoard
(
payload
*
auty
.
TerminateProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalBoard
(
receiptData
)
return
a
.
execDelLocalBoard
(
receiptData
)
}
}
...
@@ -35,26 +47,41 @@ func (a *Autonomy) ExecDelLocal_TmintPropBoard(payload *auty.TerminateProposalBo
...
@@ -35,26 +47,41 @@ func (a *Autonomy) ExecDelLocal_TmintPropBoard(payload *auty.TerminateProposalBo
// ExecDelLocal_PropProject 创建提案项目
// ExecDelLocal_PropProject 创建提案项目
func
(
a
*
Autonomy
)
ExecDelLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalProject
(
receiptData
)
return
a
.
execDelLocalProject
(
receiptData
)
}
}
// ExecDelLocal_RvkPropProject 撤销提案
// ExecDelLocal_RvkPropProject 撤销提案
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalProject
(
receiptData
)
return
a
.
execDelLocalProject
(
receiptData
)
}
}
// ExecDelLocal_VotePropProject 投票提案
// ExecDelLocal_VotePropProject 投票提案
func
(
a
*
Autonomy
)
ExecDelLocal_VotePropProject
(
payload
*
auty
.
VoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_VotePropProject
(
payload
*
auty
.
VoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalProject
(
receiptData
)
return
a
.
execDelLocalProject
(
receiptData
)
}
}
// ExecDelLocal_PubVotePropProject 投票提案
// ExecDelLocal_PubVotePropProject 投票提案
func
(
a
*
Autonomy
)
ExecDelLocal_PubVotePropProject
(
payload
*
auty
.
PubVoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_PubVotePropProject
(
payload
*
auty
.
PubVoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalProject
(
receiptData
)
return
a
.
execDelLocalProject
(
receiptData
)
}
}
// ExecDelLocal_TmintPropProject 终止提案
// ExecDelLocal_TmintPropProject 终止提案
func
(
a
*
Autonomy
)
ExecDelLocal_TmintPropProject
(
payload
*
auty
.
TerminateProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_TmintPropProject
(
payload
*
auty
.
TerminateProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalProject
(
receiptData
)
return
a
.
execDelLocalProject
(
receiptData
)
}
}
...
@@ -62,25 +89,40 @@ func (a *Autonomy) ExecDelLocal_TmintPropProject(payload *auty.TerminateProposal
...
@@ -62,25 +89,40 @@ func (a *Autonomy) ExecDelLocal_TmintPropProject(payload *auty.TerminateProposal
// ExecDelLocal_PropRule 创建提案规则
// ExecDelLocal_PropRule 创建提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalRule
(
receiptData
)
return
a
.
execDelLocalRule
(
receiptData
)
}
}
// ExecDelLocal_RvkPropRule 撤销提案规则
// ExecDelLocal_RvkPropRule 撤销提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalRule
(
receiptData
)
return
a
.
execDelLocalRule
(
receiptData
)
}
}
// ExecDelLocal_VotePropRule 投票提案规则
// ExecDelLocal_VotePropRule 投票提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_VotePropRule
(
payload
*
auty
.
VoteProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_VotePropRule
(
payload
*
auty
.
VoteProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalRule
(
receiptData
)
return
a
.
execDelLocalRule
(
receiptData
)
}
}
// ExecDelLocal_TmintPropRule 终止提案规则
// ExecDelLocal_TmintPropRule 终止提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_TmintPropRule
(
payload
*
auty
.
TerminateProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_TmintPropRule
(
payload
*
auty
.
TerminateProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalRule
(
receiptData
)
return
a
.
execDelLocalRule
(
receiptData
)
}
}
// ExecDelLocal_CommentProp 终止提案规则
// ExecDelLocal_CommentProp 终止提案规则
func
(
a
*
Autonomy
)
ExecDelLocal_CommentProp
(
payload
*
auty
.
Comment
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecDelLocal_CommentProp
(
payload
*
auty
.
Comment
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoDelLocal
(
tx
,
receiptData
)
}
return
a
.
execDelLocalCommentProp
(
receiptData
)
return
a
.
execDelLocalCommentProp
(
receiptData
)
}
}
plugin/dapp/autonomy/executor/exec_local.go
View file @
996f4ff5
...
@@ -13,21 +13,33 @@ import (
...
@@ -13,21 +13,33 @@ import (
// ExecLocal_PropBoard 创建提案
// ExecLocal_PropBoard 创建提案
func
(
a
*
Autonomy
)
ExecLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_PropBoard
(
payload
*
auty
.
ProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalBoard
(
tx
,
receiptData
)
}
return
a
.
execLocalBoard
(
receiptData
)
return
a
.
execLocalBoard
(
receiptData
)
}
}
// ExecLocal_RvkPropBoard 撤销提案
// ExecLocal_RvkPropBoard 撤销提案
func
(
a
*
Autonomy
)
ExecLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_RvkPropBoard
(
payload
*
auty
.
RevokeProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalBoard
(
tx
,
receiptData
)
}
return
a
.
execLocalBoard
(
receiptData
)
return
a
.
execLocalBoard
(
receiptData
)
}
}
// ExecLocal_VotePropBoard 投票提案
// ExecLocal_VotePropBoard 投票提案
func
(
a
*
Autonomy
)
ExecLocal_VotePropBoard
(
payload
*
auty
.
VoteProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_VotePropBoard
(
payload
*
auty
.
VoteProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalBoard
(
tx
,
receiptData
)
}
return
a
.
execLocalBoard
(
receiptData
)
return
a
.
execLocalBoard
(
receiptData
)
}
}
// ExecLocal_TmintPropBoard 终止提案
// ExecLocal_TmintPropBoard 终止提案
func
(
a
*
Autonomy
)
ExecLocal_TmintPropBoard
(
payload
*
auty
.
TerminateProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_TmintPropBoard
(
payload
*
auty
.
TerminateProposalBoard
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalBoard
(
tx
,
receiptData
)
}
return
a
.
execLocalBoard
(
receiptData
)
return
a
.
execLocalBoard
(
receiptData
)
}
}
...
@@ -35,26 +47,41 @@ func (a *Autonomy) ExecLocal_TmintPropBoard(payload *auty.TerminateProposalBoard
...
@@ -35,26 +47,41 @@ func (a *Autonomy) ExecLocal_TmintPropBoard(payload *auty.TerminateProposalBoard
// ExecLocal_PropProject 创建提案项目
// ExecLocal_PropProject 创建提案项目
func
(
a
*
Autonomy
)
ExecLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_PropProject
(
payload
*
auty
.
ProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalProject
(
tx
,
receiptData
)
}
return
a
.
execLocalProject
(
receiptData
)
return
a
.
execLocalProject
(
receiptData
)
}
}
// ExecLocal_RvkPropProject 撤销提案项目
// ExecLocal_RvkPropProject 撤销提案项目
func
(
a
*
Autonomy
)
ExecLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_RvkPropProject
(
payload
*
auty
.
RevokeProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalProject
(
tx
,
receiptData
)
}
return
a
.
execLocalProject
(
receiptData
)
return
a
.
execLocalProject
(
receiptData
)
}
}
// ExecLocal_VotePropProject 投票提案项目
// ExecLocal_VotePropProject 投票提案项目
func
(
a
*
Autonomy
)
ExecLocal_VotePropProject
(
payload
*
auty
.
VoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_VotePropProject
(
payload
*
auty
.
VoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalProject
(
tx
,
receiptData
)
}
return
a
.
execLocalProject
(
receiptData
)
return
a
.
execLocalProject
(
receiptData
)
}
}
// ExecLocal_PubVotePropProject 全体投票提案项目
// ExecLocal_PubVotePropProject 全体投票提案项目
func
(
a
*
Autonomy
)
ExecLocal_PubVotePropProject
(
payload
*
auty
.
PubVoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_PubVotePropProject
(
payload
*
auty
.
PubVoteProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalProject
(
tx
,
receiptData
)
}
return
a
.
execLocalProject
(
receiptData
)
return
a
.
execLocalProject
(
receiptData
)
}
}
// ExecLocal_TmintPropProject 终止提案项目
// ExecLocal_TmintPropProject 终止提案项目
func
(
a
*
Autonomy
)
ExecLocal_TmintPropProject
(
payload
*
auty
.
TerminateProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_TmintPropProject
(
payload
*
auty
.
TerminateProposalProject
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalProject
(
tx
,
receiptData
)
}
return
a
.
execLocalProject
(
receiptData
)
return
a
.
execLocalProject
(
receiptData
)
}
}
...
@@ -62,25 +89,40 @@ func (a *Autonomy) ExecLocal_TmintPropProject(payload *auty.TerminateProposalPro
...
@@ -62,25 +89,40 @@ func (a *Autonomy) ExecLocal_TmintPropProject(payload *auty.TerminateProposalPro
// ExecLocal_PropRule 创建提案规则
// ExecLocal_PropRule 创建提案规则
func
(
a
*
Autonomy
)
ExecLocal_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_PropRule
(
payload
*
auty
.
ProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalRule
(
tx
,
receiptData
)
}
return
a
.
execLocalRule
(
receiptData
)
return
a
.
execLocalRule
(
receiptData
)
}
}
// ExecLocal_RvkPropRule 撤销提案规则
// ExecLocal_RvkPropRule 撤销提案规则
func
(
a
*
Autonomy
)
ExecLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_RvkPropRule
(
payload
*
auty
.
RevokeProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalRule
(
tx
,
receiptData
)
}
return
a
.
execLocalRule
(
receiptData
)
return
a
.
execLocalRule
(
receiptData
)
}
}
// ExecLocal_VotePropRule 投票提案规则
// ExecLocal_VotePropRule 投票提案规则
func
(
a
*
Autonomy
)
ExecLocal_VotePropRule
(
payload
*
auty
.
VoteProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_VotePropRule
(
payload
*
auty
.
VoteProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalRule
(
tx
,
receiptData
)
}
return
a
.
execLocalRule
(
receiptData
)
return
a
.
execLocalRule
(
receiptData
)
}
}
// ExecLocal_TmintPropRule 终止提案规则
// ExecLocal_TmintPropRule 终止提案规则
func
(
a
*
Autonomy
)
ExecLocal_TmintPropRule
(
payload
*
auty
.
TerminateProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_TmintPropRule
(
payload
*
auty
.
TerminateProposalRule
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalRule
(
tx
,
receiptData
)
}
return
a
.
execLocalRule
(
receiptData
)
return
a
.
execLocalRule
(
receiptData
)
}
}
// ExecLocal_CommentProp 评论提案
// ExecLocal_CommentProp 评论提案
func
(
a
*
Autonomy
)
ExecLocal_CommentProp
(
payload
*
auty
.
Comment
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
ExecLocal_CommentProp
(
payload
*
auty
.
Comment
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
cfg
.
AutoRollback
{
return
a
.
execAutoLocalCommentProp
(
tx
,
receiptData
)
}
return
a
.
execLocalCommentProp
(
receiptData
)
return
a
.
execLocalCommentProp
(
receiptData
)
}
}
plugin/dapp/autonomy/executor/project.go
View file @
996f4ff5
...
@@ -10,8 +10,17 @@ import (
...
@@ -10,8 +10,17 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
)
func
(
a
*
Autonomy
)
execLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execAutoLocalProject
(
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
a
.
execLocalProject
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
[]
byte
(
tx
.
Execer
),
set
.
KV
)
return
dbSet
,
nil
}
func
(
a
*
Autonomy
)
execLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
table
:=
NewProjectTable
(
a
.
GetLocalDB
())
table
:=
NewProjectTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
Ty
{
switch
log
.
Ty
{
...
@@ -39,12 +48,12 @@ func (a *Autonomy) execLocalProject(receiptData *types.ReceiptData) (*types.Loca
...
@@ -39,12 +48,12 @@ func (a *Autonomy) execLocalProject(receiptData *types.ReceiptData) (*types.Loca
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
func
(
a
*
Autonomy
)
execDelLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execDelLocalProject
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
table
:=
NewProjectTable
(
a
.
GetLocalDB
())
table
:=
NewProjectTable
(
a
.
GetLocalDB
())
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
var
receipt
auty
.
ReceiptProposalProject
var
receipt
auty
.
ReceiptProposalProject
...
@@ -79,6 +88,7 @@ func (a *Autonomy) execDelLocalProject(receiptData *types.ReceiptData) (*types.L
...
@@ -79,6 +88,7 @@ func (a *Autonomy) execDelLocalProject(receiptData *types.ReceiptData) (*types.L
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
...
...
plugin/dapp/autonomy/executor/project_test.go
View file @
996f4ff5
...
@@ -17,6 +17,11 @@ import (
...
@@ -17,6 +17,11 @@ import (
)
)
func
TestExecLocalProject
(
t
*
testing
.
T
)
{
func
TestExecLocalProject
(
t
*
testing
.
T
)
{
testexecLocalProject
(
t
,
false
)
testexecLocalProject
(
t
,
true
)
}
func
testexecLocalProject
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
...
@@ -41,7 +46,17 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -41,7 +46,17 @@ func TestExecLocalProject(t *testing.T) {
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
},
},
}
}
set
,
err
:=
au
.
execLocalProject
(
receipt
)
var
set
*
types
.
LocalDBSet
var
err
error
if
auto
==
false
{
set
,
err
=
au
.
execLocalProject
(
receipt
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalProject
(
tx
,
receipt
)
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
//save to database
//save to database
...
@@ -57,11 +72,23 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -57,11 +72,23 @@ func TestExecLocalProject(t *testing.T) {
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
if
auto
==
false
{
{
Ty
:
auty
.
TyLogRvkPropProject
,
Log
:
types
.
Encode
(
receiptProject1
)},
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
},
Logs
:
[]
*
types
.
ReceiptLog
{
})
{
Ty
:
auty
.
TyLogRvkPropProject
,
Log
:
types
.
Encode
(
receiptProject1
)},
},
})
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalProject
(
tx
,
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogRvkPropProject
,
Log
:
types
.
Encode
(
receiptProject1
)},
},
})
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
...
@@ -73,22 +100,30 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -73,22 +100,30 @@ func TestExecLocalProject(t *testing.T) {
// TyLogVotePropProject
// TyLogVotePropProject
cur
.
Status
=
auty
.
AutonomyStatusProposalProject
cur
.
Status
=
auty
.
AutonomyStatusProposalProject
cur
.
Height
=
1
cur
.
Index
=
2
pre2
:=
copyAutonomyProposalProject
(
cur
)
pre2
:=
copyAutonomyProposalProject
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Height
=
1
cur
.
Index
=
2
cur
.
Address
=
"2222222222222"
cur
.
Address
=
"2222222222222"
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
Prev
:
pre2
,
Prev
:
pre2
,
Current
:
cur
,
Current
:
cur
,
}
}
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
if
auto
==
false
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
set
,
err
=
au
.
execLocalProject
(
&
types
.
ReceiptData
{
},
Logs
:
[]
*
types
.
ReceiptLog
{
})
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
},
})
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalProject
(
tx
,
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
},
})
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
...
@@ -100,6 +135,11 @@ func TestExecLocalProject(t *testing.T) {
...
@@ -100,6 +135,11 @@ func TestExecLocalProject(t *testing.T) {
}
}
func
TestExecDelLocalProject
(
t
*
testing
.
T
)
{
func
TestExecDelLocalProject
(
t
*
testing
.
T
)
{
testexecDelLocalProject
(
t
,
false
)
testexecDelLocalProject
(
t
,
true
)
}
func
testexecDelLocalProject
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
...
@@ -124,19 +164,36 @@ func TestExecDelLocalProject(t *testing.T) {
...
@@ -124,19 +164,36 @@ func TestExecDelLocalProject(t *testing.T) {
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
{
Ty
:
auty
.
TyLogPropProject
,
Log
:
types
.
Encode
(
receiptProject
)},
},
},
}
}
var
set
*
types
.
LocalDBSet
var
err
error
// 先执行local然后进行删除
// 先执行local然后进行删除
set
,
err
:=
au
.
execLocalProject
(
receipt
)
if
auto
==
false
{
require
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execLocalProject
(
receipt
)
require
.
NotNil
(
t
,
set
)
require
.
NoError
(
t
,
err
)
saveKvs
(
sdb
,
set
.
KV
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execDelLocalProject
(
receipt
)
set
,
err
=
au
.
execDelLocalProject
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
saveKvs
(
sdb
,
set
.
KV
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execAutoLocalProject
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
// check
// check
table
:=
New
Board
Table
(
au
.
GetLocalDB
())
table
:=
New
Project
Table
(
au
.
GetLocalDB
())
query
:=
table
.
GetQuery
(
kvdb
)
query
:=
table
.
GetQuery
(
kvdb
)
_
,
err
=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
_
,
err
=
query
.
ListIndex
(
"primary"
,
nil
,
nil
,
10
,
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
...
@@ -150,32 +207,53 @@ func TestExecDelLocalProject(t *testing.T) {
...
@@ -150,32 +207,53 @@ func TestExecDelLocalProject(t *testing.T) {
// TyLogVotePropProject
// TyLogVotePropProject
pre1
:=
copyAutonomyProposalProject
(
cur
)
pre1
:=
copyAutonomyProposalProject
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Status
=
auty
.
AutonomyStatusVotePropProject
cur
.
Height
=
1
cur
.
Index
=
2
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
receiptProject2
:=
&
auty
.
ReceiptProposalProject
{
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
// 先执行local然后进行删除
recpt
:=
&
types
.
ReceiptData
{
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
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
{
Ty
:
auty
.
TyLogVotePropProject
,
Log
:
types
.
Encode
(
receiptProject2
)},
},
}}
})
// 先执行local然后进行删除
require
.
NoError
(
t
,
err
)
if
auto
==
false
{
require
.
NotNil
(
t
,
set
)
set
,
err
=
au
.
execLocalProject
(
recpt
)
saveKvs
(
sdb
,
set
.
KV
)
// check
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalProject
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execDelLocalProject
(
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
else
{
// 自动回退测试时候,需要先设置一个前置状态
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execAutoLocalProject
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// 正常测试退回
tx
,
err
=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalProject
(
tx
,
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalProject
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
checkExecLocalProject
(
t
,
kvdb
,
pre1
)
checkExecLocalProject
(
t
,
kvdb
,
pre1
)
}
}
...
...
plugin/dapp/autonomy/executor/rule.go
View file @
996f4ff5
...
@@ -10,6 +10,16 @@ import (
...
@@ -10,6 +10,16 @@ import (
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
)
)
func
(
a
*
Autonomy
)
execAutoLocalRule
(
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
a
.
execLocalRule
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
[]
byte
(
tx
.
Execer
),
set
.
KV
)
return
dbSet
,
nil
}
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
{}
table
:=
NewRuleTable
(
a
.
GetLocalDB
())
table
:=
NewRuleTable
(
a
.
GetLocalDB
())
...
@@ -153,6 +163,16 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa
...
@@ -153,6 +163,16 @@ func (a *Autonomy) listProposalRule(req *auty.ReqQueryProposalRule) (types.Messa
return
&
rep
,
nil
return
&
rep
,
nil
}
}
func
(
a
*
Autonomy
)
execAutoLocalCommentProp
(
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
a
.
execLocalCommentProp
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
[]
byte
(
tx
.
Execer
),
set
.
KV
)
return
dbSet
,
nil
}
func
(
a
*
Autonomy
)
execLocalCommentProp
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
Autonomy
)
execLocalCommentProp
(
receiptData
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
var
set
[]
*
types
.
KeyValue
var
set
[]
*
types
.
KeyValue
...
...
plugin/dapp/autonomy/executor/rule_test.go
View file @
996f4ff5
...
@@ -17,6 +17,11 @@ import (
...
@@ -17,6 +17,11 @@ import (
)
)
func
TestExecLocalRule
(
t
*
testing
.
T
)
{
func
TestExecLocalRule
(
t
*
testing
.
T
)
{
testexecLocalRule
(
t
,
false
)
testexecLocalRule
(
t
,
true
)
}
func
testexecLocalRule
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
...
@@ -39,7 +44,17 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -39,7 +44,17 @@ func TestExecLocalRule(t *testing.T) {
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
},
},
}
}
set
,
err
:=
au
.
execLocalRule
(
receipt
)
var
set
*
types
.
LocalDBSet
var
err
error
if
auto
==
false
{
set
,
err
=
au
.
execLocalRule
(
receipt
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalRule
(
tx
,
receipt
)
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
//save to database
//save to database
...
@@ -55,11 +70,23 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -55,11 +70,23 @@ func TestExecLocalRule(t *testing.T) {
Prev
:
pre1
,
Prev
:
pre1
,
Current
:
cur
,
Current
:
cur
,
}
}
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
if
auto
==
false
{
Logs
:
[]
*
types
.
ReceiptLog
{
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
{
Ty
:
auty
.
TyLogRvkPropRule
,
Log
:
types
.
Encode
(
receiptRule1
)},
Logs
:
[]
*
types
.
ReceiptLog
{
},
{
Ty
:
auty
.
TyLogRvkPropRule
,
Log
:
types
.
Encode
(
receiptRule1
)},
})
},
})
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalRule
(
tx
,
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogRvkPropRule
,
Log
:
types
.
Encode
(
receiptRule1
)},
},
})
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
//save to database
//save to database
...
@@ -70,22 +97,30 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -70,22 +97,30 @@ func TestExecLocalRule(t *testing.T) {
// TyLogVotePropRule
// TyLogVotePropRule
cur
.
Status
=
auty
.
AutonomyStatusProposalRule
cur
.
Status
=
auty
.
AutonomyStatusProposalRule
cur
.
Height
=
1
cur
.
Index
=
2
pre2
:=
copyAutonomyProposalRule
(
cur
)
pre2
:=
copyAutonomyProposalRule
(
cur
)
cur
.
Status
=
auty
.
AutonomyStatusVotePropRule
cur
.
Status
=
auty
.
AutonomyStatusVotePropRule
cur
.
Height
=
1
cur
.
Index
=
2
cur
.
Address
=
"2222222222222"
cur
.
Address
=
"2222222222222"
receiptRule2
:=
&
auty
.
ReceiptProposalRule
{
receiptRule2
:=
&
auty
.
ReceiptProposalRule
{
Prev
:
pre2
,
Prev
:
pre2
,
Current
:
cur
,
Current
:
cur
,
}
}
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
if
auto
==
false
{
Logs
:
[]
*
types
.
ReceiptLog
{
set
,
err
=
au
.
execLocalRule
(
&
types
.
ReceiptData
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
Logs
:
[]
*
types
.
ReceiptLog
{
},
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
})
},
})
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalRule
(
tx
,
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
},
})
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
//save to database
//save to database
...
@@ -95,6 +130,11 @@ func TestExecLocalRule(t *testing.T) {
...
@@ -95,6 +130,11 @@ func TestExecLocalRule(t *testing.T) {
}
}
func
TestExecDelLocalRule
(
t
*
testing
.
T
)
{
func
TestExecDelLocalRule
(
t
*
testing
.
T
)
{
testexecDelLocalRule
(
t
,
false
)
testexecDelLocalRule
(
t
,
true
)
}
func
testexecDelLocalRule
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
au
.
SetLocalDB
(
kvdb
)
...
@@ -117,16 +157,33 @@ func TestExecDelLocalRule(t *testing.T) {
...
@@ -117,16 +157,33 @@ func TestExecDelLocalRule(t *testing.T) {
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
{
Ty
:
auty
.
TyLogPropRule
,
Log
:
types
.
Encode
(
receiptRule
)},
},
},
}
}
var
set
*
types
.
LocalDBSet
var
err
error
// 先执行local然后进行删除
// 先执行local然后进行删除
set
,
err
:=
au
.
execLocalRule
(
receipt
)
if
auto
==
false
{
require
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execLocalRule
(
receipt
)
require
.
NotNil
(
t
,
set
)
require
.
NoError
(
t
,
err
)
saveKvs
(
sdb
,
set
.
KV
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execDelLocalRule
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execAutoLocalRule
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
set
,
err
=
au
.
execDelLocalRule
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
// check
table
:=
NewRuleTable
(
au
.
GetLocalDB
())
table
:=
NewRuleTable
(
au
.
GetLocalDB
())
query
:=
table
.
GetQuery
(
kvdb
)
query
:=
table
.
GetQuery
(
kvdb
)
...
@@ -146,26 +203,51 @@ func TestExecDelLocalRule(t *testing.T) {
...
@@ -146,26 +203,51 @@ func TestExecDelLocalRule(t *testing.T) {
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
{
recpt
:=
&
types
.
ReceiptData
{
Logs
:
[]
*
types
.
ReceiptLog
{
Logs
:
[]
*
types
.
ReceiptLog
{
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
{
Ty
:
auty
.
TyLogVotePropRule
,
Log
:
types
.
Encode
(
receiptRule2
)},
},
}}
})
// 先执行local然后进行删除
require
.
NoError
(
t
,
err
)
if
auto
==
false
{
require
.
NotNil
(
t
,
set
)
set
,
err
=
au
.
execLocalRule
(
recpt
)
saveKvs
(
sdb
,
set
.
KV
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalRule
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execDelLocalRule
(
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
else
{
// 自动回退测试时候,需要先设置一个前置状态
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
:=
au
.
execAutoLocalRule
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// 正常测试退回
tx
,
err
=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalRule
(
tx
,
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
// check
checkExecLocalRule
(
t
,
kvdb
,
cur
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
recpt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
}
// check
// check
checkExecLocalRule
(
t
,
kvdb
,
pre1
)
checkExecLocalRule
(
t
,
kvdb
,
pre1
)
}
}
...
@@ -329,7 +411,14 @@ func TestListProposalRule(t *testing.T) {
...
@@ -329,7 +411,14 @@ func TestListProposalRule(t *testing.T) {
}
}
func
TestExecLocalCommentProp
(
t
*
testing
.
T
)
{
func
TestExecLocalCommentProp
(
t
*
testing
.
T
)
{
testexecLocalCommentProp
(
t
,
false
)
testexecLocalCommentProp
(
t
,
true
)
}
func
testexecLocalCommentProp
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
propID
:=
"11111111111111"
propID
:=
"11111111111111"
Repcmt
:=
"2222222222"
Repcmt
:=
"2222222222"
comment
:=
"3333333333"
comment
:=
"3333333333"
...
@@ -347,7 +436,16 @@ func TestExecLocalCommentProp(t *testing.T) {
...
@@ -347,7 +436,16 @@ func TestExecLocalCommentProp(t *testing.T) {
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
},
},
}
}
set
,
err
:=
au
.
execLocalCommentProp
(
receipt
)
var
set
*
types
.
LocalDBSet
var
err
error
if
auto
==
false
{
set
,
err
=
au
.
execLocalCommentProp
(
receipt
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalCommentProp
(
tx
,
receipt
)
}
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
require
.
NotNil
(
t
,
set
)
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcCommentHeight
(
propID
,
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcCommentHeight
(
propID
,
...
@@ -356,7 +454,14 @@ func TestExecLocalCommentProp(t *testing.T) {
...
@@ -356,7 +454,14 @@ func TestExecLocalCommentProp(t *testing.T) {
}
}
func
TestExecDelLocalCommentProp
(
t
*
testing
.
T
)
{
func
TestExecDelLocalCommentProp
(
t
*
testing
.
T
)
{
testexecDelLocalCommentProp
(
t
,
false
)
testexecDelLocalCommentProp
(
t
,
true
)
}
func
testexecDelLocalCommentProp
(
t
*
testing
.
T
,
auto
bool
)
{
_
,
sdb
,
kvdb
:=
util
.
CreateTestDB
()
au
:=
&
Autonomy
{}
au
:=
&
Autonomy
{}
au
.
SetLocalDB
(
kvdb
)
propID
:=
"11111111111111"
propID
:=
"11111111111111"
Repcmt
:=
"2222222222"
Repcmt
:=
"2222222222"
comment
:=
"3333333333"
comment
:=
"3333333333"
...
@@ -374,9 +479,33 @@ func TestExecDelLocalCommentProp(t *testing.T) {
...
@@ -374,9 +479,33 @@ func TestExecDelLocalCommentProp(t *testing.T) {
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
{
Ty
:
auty
.
TyLogCommentProp
,
Log
:
types
.
Encode
(
receiptCmt
)},
},
},
}
}
set
,
err
:=
au
.
execDelLocalCommentProp
(
receipt
)
var
set
*
types
.
LocalDBSet
require
.
NoError
(
t
,
err
)
var
err
error
require
.
NotNil
(
t
,
set
)
// 先执行local然后进行删除
if
auto
==
false
{
set
,
err
=
au
.
execLocalCommentProp
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execDelLocalCommentProp
(
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
}
else
{
tx
,
err
:=
types
.
CreateFormatTx
(
types
.
ExecName
(
auty
.
AutonomyX
),
nil
)
assert
.
NoError
(
t
,
err
)
set
,
err
=
au
.
execAutoLocalCommentProp
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
saveKvs
(
sdb
,
set
.
KV
)
set
,
err
=
au
.
execAutoDelLocal
(
tx
,
receipt
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
set
)
}
// check
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcCommentHeight
(
propID
,
require
.
Equal
(
t
,
set
.
KV
[
0
]
.
Key
,
calcCommentHeight
(
propID
,
dapp
.
HeightIndexStr
(
receiptCmt
.
Height
,
int64
(
receiptCmt
.
Index
))))
dapp
.
HeightIndexStr
(
receiptCmt
.
Height
,
int64
(
receiptCmt
.
Index
))))
require
.
Nil
(
t
,
set
.
KV
[
0
]
.
Value
)
require
.
Nil
(
t
,
set
.
KV
[
0
]
.
Value
)
...
...
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