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
095c7c43
Commit
095c7c43
authored
Apr 20, 2021
by
jiangpeng
Committed by
vipwzw
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vote:add group name to vote info
parent
15fc6a0d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
+25
-15
exec_local.go
plugin/dapp/vote/executor/exec_local.go
+9
-9
execlocal_test.go
plugin/dapp/vote/executor/execlocal_test.go
+15
-6
vote.proto
plugin/dapp/vote/proto/vote.proto
+1
-0
vote.pb.go
plugin/dapp/vote/types/vote.pb.go
+0
-0
No files found.
plugin/dapp/vote/executor/exec_local.go
View file @
095c7c43
...
@@ -84,21 +84,21 @@ func (v *vote) ExecLocal_UpdateGroup(update *vty.UpdateGroup, tx *types.Transact
...
@@ -84,21 +84,21 @@ func (v *vote) ExecLocal_UpdateGroup(update *vty.UpdateGroup, tx *types.Transact
func
(
v
*
vote
)
ExecLocal_CreateVote
(
payload
*
vty
.
CreateVote
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
v
*
vote
)
ExecLocal_CreateVote
(
payload
*
vty
.
CreateVote
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
voteInfo
:=
decodeVoteInfo
(
receiptData
.
Logs
[
0
]
.
Log
)
voteInfo
:=
decodeVoteInfo
(
receiptData
.
Logs
[
0
]
.
Log
)
table
:=
newVoteTable
(
v
.
GetLocalDB
())
vTable
:=
newVoteTable
(
v
.
GetLocalDB
())
kvs
,
err
:=
v
.
updateAndSaveTable
(
table
.
Add
,
table
.
Save
,
voteInfo
,
tx
,
vty
.
NameCreateVoteAction
,
"vote"
)
gTable
:=
newGroupTable
(
v
.
GetLocalDB
())
if
err
!=
nil
{
row
,
err
:=
gTable
.
GetData
([]
byte
(
voteInfo
.
GroupID
))
return
nil
,
err
}
dbSet
.
KV
=
kvs
table
=
newGroupTable
(
v
.
GetLocalDB
())
row
,
err
:=
table
.
GetData
([]
byte
(
voteInfo
.
GroupID
))
if
err
!=
nil
{
if
err
!=
nil
{
elog
.
Error
(
"execLocal createVote"
,
"txHash"
,
hex
.
EncodeToString
(
tx
.
Hash
()),
"voteTable get"
,
err
)
elog
.
Error
(
"execLocal createVote"
,
"txHash"
,
hex
.
EncodeToString
(
tx
.
Hash
()),
"voteTable get"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
groupInfo
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
groupInfo
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
groupInfo
.
VoteNum
++
groupInfo
.
VoteNum
++
kvs
,
err
=
v
.
updateAndSaveTable
(
table
.
Replace
,
table
.
Save
,
groupInfo
,
tx
,
vty
.
NameCreateVoteAction
,
"group"
)
voteInfo
.
GroupName
=
groupInfo
.
GetName
()
dbSet
.
KV
,
err
=
v
.
updateAndSaveTable
(
vTable
.
Add
,
vTable
.
Save
,
voteInfo
,
tx
,
vty
.
NameCreateVoteAction
,
"vote"
)
if
err
!=
nil
{
return
nil
,
err
}
kvs
,
err
:=
v
.
updateAndSaveTable
(
gTable
.
Replace
,
gTable
.
Save
,
groupInfo
,
tx
,
vty
.
NameCreateVoteAction
,
"group"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
plugin/dapp/vote/executor/execlocal_test.go
View file @
095c7c43
...
@@ -149,18 +149,26 @@ func TestVote_ExecLocal_CreateVote(t *testing.T) {
...
@@ -149,18 +149,26 @@ func TestVote_ExecLocal_CreateVote(t *testing.T) {
options
:=
[]
*
vty
.
VoteOption
{{
Option
:
"A"
},
{
Option
:
"B"
}}
options
:=
[]
*
vty
.
VoteOption
{{
Option
:
"A"
},
{
Option
:
"B"
}}
tcArr
:=
[]
*
testcase
{{
tcArr
:=
[]
*
testcase
{{
index
:
0
,
index
:
0
,
payload
:
&
vty
.
CreateGroup
{
Name
:
"
test
"
},
payload
:
&
vty
.
CreateGroup
{
Name
:
"
g1
"
},
},
{
},
{
index
:
1
,
index
:
1
,
payload
:
&
vty
.
CreateVote
{
Name
:
"test"
,
GroupID
:
groupID
,
VoteOptions
:
[]
string
{
"A"
,
"B"
},
payload
:
&
vty
.
CreateVote
{
Name
:
"v1"
,
GroupID
:
groupID
,
VoteOptions
:
[]
string
{
"A"
,
"B"
},
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
},
},
{
index
:
2
,
payload
:
&
vty
.
CreateVote
{
Name
:
"v2"
,
GroupID
:
groupID
,
VoteOptions
:
[]
string
{
"A"
,
"B"
},
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
},
},
{
index
:
3
,
payload
:
&
vty
.
CreateVote
{
Name
:
"v3"
,
GroupID
:
groupID
,
VoteOptions
:
[]
string
{
"A"
,
"B"
},
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
},
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
},
}}
}}
testExec
(
t
,
mock
,
testTypeExecLocal
,
tcArr
,
privKeys
[
0
])
testExec
(
t
,
mock
,
testTypeExecLocal
,
tcArr
,
privKeys
[
0
])
table
:=
newVoteTable
(
mock
.
exec
.
GetLocalDB
())
table
:=
newVoteTable
(
mock
.
exec
.
GetLocalDB
())
expectVoteInfo
:=
&
vty
.
VoteInfo
{
expectVoteInfo
:=
&
vty
.
VoteInfo
{
Name
:
"
test
"
,
VoteOptions
:
options
,
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
,
Name
:
"
v1
"
,
VoteOptions
:
options
,
BeginTimestamp
:
testBlockTime
,
EndTimestamp
:
testBlockTime
+
1
,
GroupID
:
groupID
,
ID
:
voteID
,
Creator
:
testAddrs
[
0
],
GroupID
:
groupID
,
ID
:
voteID
,
Creator
:
testAddrs
[
0
],
GroupName
:
"g1"
,
}
}
testTableData
(
t
,
table
,
[]
*
tableCase
{{
testTableData
(
t
,
table
,
[]
*
tableCase
{{
index
:
0
,
index
:
0
,
...
@@ -172,11 +180,10 @@ func TestVote_ExecLocal_CreateVote(t *testing.T) {
...
@@ -172,11 +180,10 @@ func TestVote_ExecLocal_CreateVote(t *testing.T) {
row
,
err
:=
table
.
GetData
([]
byte
(
groupID
))
row
,
err
:=
table
.
GetData
([]
byte
(
groupID
))
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
info
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
info
,
_
:=
row
.
Data
.
(
*
vty
.
GroupInfo
)
require
.
Equal
(
t
,
uint32
(
1
),
info
.
VoteNum
)
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
)
group
.
VoteNum
=
info
.
VoteNum
group
.
VoteNum
=
3
require
.
Equal
(
t
,
group
.
String
(),
info
.
String
())
require
.
Equal
(
t
,
group
.
String
(),
info
.
String
())
}
}
...
@@ -208,6 +215,7 @@ func TestVote_ExecLocal_CloseVote(t *testing.T) {
...
@@ -208,6 +215,7 @@ func TestVote_ExecLocal_CloseVote(t *testing.T) {
tx
:=
util
.
CreateNoneTx
(
mock
.
cfg
,
privKeys
[
0
])
tx
:=
util
.
CreateNoneTx
(
mock
.
cfg
,
privKeys
[
0
])
vote
,
err
:=
newAction
(
mock
.
exec
,
tx
,
0
)
.
getVoteInfo
(
voteID
)
vote
,
err
:=
newAction
(
mock
.
exec
,
tx
,
0
)
.
getVoteInfo
(
voteID
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
vote
.
GroupName
=
"test"
require
.
Equal
(
t
,
vote
.
String
(),
info
.
String
())
require
.
Equal
(
t
,
vote
.
String
(),
info
.
String
())
}
}
...
@@ -243,6 +251,7 @@ func TestVote_ExecLocal_CommitVote(t *testing.T) {
...
@@ -243,6 +251,7 @@ func TestVote_ExecLocal_CommitVote(t *testing.T) {
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
vote
.
CommitInfos
[
0
]
.
TxHash
=
info
.
CommitInfos
[
0
]
.
TxHash
vote
.
CommitInfos
[
0
]
.
TxHash
=
info
.
CommitInfos
[
0
]
.
TxHash
vote
.
CommitInfos
[
0
]
.
VoteWeight
=
info
.
CommitInfos
[
0
]
.
VoteWeight
vote
.
CommitInfos
[
0
]
.
VoteWeight
=
info
.
CommitInfos
[
0
]
.
VoteWeight
vote
.
GroupName
=
"test"
require
.
Equal
(
t
,
vote
.
String
(),
info
.
String
())
require
.
Equal
(
t
,
vote
.
String
(),
info
.
String
())
}
}
...
...
plugin/dapp/vote/proto/vote.proto
View file @
095c7c43
...
@@ -104,6 +104,7 @@ message VoteInfo {
...
@@ -104,6 +104,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
;
//所属投票组名称
}
}
message
VoteInfos
{
message
VoteInfos
{
...
...
plugin/dapp/vote/types/vote.pb.go
View file @
095c7c43
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