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
a6fa5ca5
Commit
a6fa5ca5
authored
Apr 20, 2021
by
jiangpeng
Committed by
vipwzw
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vote:fix group voteNum in update group
parent
095c7c43
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
exec_local.go
plugin/dapp/vote/executor/exec_local.go
+9
-1
execlocal_test.go
plugin/dapp/vote/executor/execlocal_test.go
+8
-3
readme.md
plugin/dapp/vote/readme.md
+1
-0
No files found.
plugin/dapp/vote/executor/exec_local.go
View file @
a6fa5ca5
...
@@ -44,6 +44,14 @@ func (v *vote) ExecLocal_UpdateGroup(update *vty.UpdateGroup, tx *types.Transact
...
@@ -44,6 +44,14 @@ func (v *vote) ExecLocal_UpdateGroup(update *vty.UpdateGroup, tx *types.Transact
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
groupInfo
:=
decodeGroupInfo
(
receiptData
.
Logs
[
0
]
.
Log
)
groupInfo
:=
decodeGroupInfo
(
receiptData
.
Logs
[
0
]
.
Log
)
table
:=
newGroupTable
(
v
.
GetLocalDB
())
table
:=
newGroupTable
(
v
.
GetLocalDB
())
row
,
err
:=
table
.
GetData
([]
byte
(
groupInfo
.
ID
))
if
err
!=
nil
{
elog
.
Error
(
"execLocal updateGroup"
,
"txHash"
,
hex
.
EncodeToString
(
tx
.
Hash
()),
"groupTable get"
,
err
)
return
nil
,
err
}
oldInfo
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
// 状态数据中未保存投票个数信息,需要进行赋值
groupInfo
.
VoteNum
=
oldInfo
.
VoteNum
kvs
,
err
:=
v
.
updateAndSaveTable
(
table
.
Replace
,
table
.
Save
,
groupInfo
,
tx
,
vty
.
NameUpdateGroupAction
,
"group"
)
kvs
,
err
:=
v
.
updateAndSaveTable
(
table
.
Replace
,
table
.
Save
,
groupInfo
,
tx
,
vty
.
NameUpdateGroupAction
,
"group"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -88,7 +96,7 @@ func (v *vote) ExecLocal_CreateVote(payload *vty.CreateVote, tx *types.Transacti
...
@@ -88,7 +96,7 @@ func (v *vote) ExecLocal_CreateVote(payload *vty.CreateVote, tx *types.Transacti
gTable
:=
newGroupTable
(
v
.
GetLocalDB
())
gTable
:=
newGroupTable
(
v
.
GetLocalDB
())
row
,
err
:=
gTable
.
GetData
([]
byte
(
voteInfo
.
GroupID
))
row
,
err
:=
gTable
.
GetData
([]
byte
(
voteInfo
.
GroupID
))
if
err
!=
nil
{
if
err
!=
nil
{
elog
.
Error
(
"execLocal createVote"
,
"txHash"
,
hex
.
EncodeToString
(
tx
.
Hash
()),
"
vote
Table get"
,
err
)
elog
.
Error
(
"execLocal createVote"
,
"txHash"
,
hex
.
EncodeToString
(
tx
.
Hash
()),
"
group
Table get"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
groupInfo
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
groupInfo
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
...
...
plugin/dapp/vote/executor/execlocal_test.go
View file @
a6fa5ca5
...
@@ -98,9 +98,13 @@ func TestVote_ExecLocal_UpdateGroup(t *testing.T) {
...
@@ -98,9 +98,13 @@ func TestVote_ExecLocal_UpdateGroup(t *testing.T) {
payload
:
&
vty
.
CreateGroup
{
Name
:
"test"
},
payload
:
&
vty
.
CreateGroup
{
Name
:
"test"
},
},
{
},
{
index
:
1
,
index
:
1
,
payload
:
&
vty
.
UpdateGroup
{
GroupID
:
groupID
,
RemoveAdmins
:
[]
string
{
testAddrs
[
0
]},
AddAdmins
:
[]
string
{
testAddrs
[
1
]}},
payload
:
&
vty
.
CreateVote
{
Name
:
"v1"
,
GroupID
:
groupID
,
VoteOptions
:
[]
string
{
"A"
,
"B"
},
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
},
},
{
},
{
index
:
2
,
index
:
2
,
payload
:
&
vty
.
UpdateGroup
{
GroupID
:
groupID
,
RemoveAdmins
:
[]
string
{
testAddrs
[
0
]},
AddAdmins
:
[]
string
{
testAddrs
[
1
]}},
},
{
index
:
3
,
priv
:
privKeys
[
1
],
priv
:
privKeys
[
1
],
payload
:
&
vty
.
UpdateGroup
{
GroupID
:
groupID
,
RemoveMembers
:
testAddrs
,
AddMembers
:
members
},
payload
:
&
vty
.
UpdateGroup
{
GroupID
:
groupID
,
RemoveMembers
:
testAddrs
,
AddMembers
:
members
},
}}
}}
...
@@ -122,7 +126,7 @@ func TestVote_ExecLocal_UpdateGroup(t *testing.T) {
...
@@ -122,7 +126,7 @@ func TestVote_ExecLocal_UpdateGroup(t *testing.T) {
testTableData
(
t
,
table
,
tcArr1
,
"check member groupIDs"
)
testTableData
(
t
,
table
,
tcArr1
,
"check member groupIDs"
)
table
=
newGroupTable
(
mock
.
exec
.
GetLocalDB
())
table
=
newGroupTable
(
mock
.
exec
.
GetLocalDB
())
expectInfo
:=
&
vty
.
GroupInfo
{
ID
:
groupID
,
Name
:
"test"
,
Admins
:
[]
string
{
testAddrs
[
1
]},
expectInfo
:=
&
vty
.
GroupInfo
{
ID
:
groupID
,
Name
:
"test"
,
Admins
:
[]
string
{
testAddrs
[
1
]},
Members
:
members
,
MemberNum
:
1
,
Creator
:
testAddrs
[
0
]}
Members
:
members
,
MemberNum
:
1
,
Creator
:
testAddrs
[
0
]
,
VoteNum
:
1
}
testTableData
(
t
,
table
,
[]
*
tableCase
{{
testTableData
(
t
,
table
,
[]
*
tableCase
{{
index
:
0
,
index
:
0
,
key
:
[]
byte
(
groupID
),
key
:
[]
byte
(
groupID
),
...
@@ -136,7 +140,8 @@ func TestVote_ExecLocal_UpdateGroup(t *testing.T) {
...
@@ -136,7 +140,8 @@ func TestVote_ExecLocal_UpdateGroup(t *testing.T) {
tx
:=
util
.
CreateNoneTx
(
mock
.
cfg
,
privKeys
[
0
])
tx
:=
util
.
CreateNoneTx
(
mock
.
cfg
,
privKeys
[
0
])
group
,
err
:=
newAction
(
mock
.
exec
,
tx
,
0
)
.
getGroupInfo
(
groupID
)
group
,
err
:=
newAction
(
mock
.
exec
,
tx
,
0
)
.
getGroupInfo
(
groupID
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
group
.
String
(),
expectInfo
.
String
())
group
.
VoteNum
=
1
require
.
Equal
(
t
,
expectInfo
.
String
(),
group
.
String
())
}
}
func
TestVote_ExecLocal_CreateVote
(
t
*
testing
.
T
)
{
func
TestVote_ExecLocal_CreateVote
(
t
*
testing
.
T
)
{
...
...
plugin/dapp/vote/readme.md
View file @
a6fa5ca5
...
@@ -223,6 +223,7 @@ message VoteInfo {
...
@@ -223,6 +223,7 @@ message VoteInfo {
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
string
description
=
9
;
//描述信息
string
description
=
9
;
//描述信息
uint32
status
=
10
;
//状态,1即将开始,2正在进行,3已经结束,4已关闭
uint32
status
=
10
;
//状态,1即将开始,2正在进行,3已经结束,4已关闭
string
groupName
=
11
;
//所属投票组名称
}
}
```
```
...
...
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