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
15fc6a0d
Commit
15fc6a0d
authored
Apr 20, 2021
by
jiangpeng
Committed by
vipwzw
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vote:check vote time in tx execution stage
parent
d9cf7b75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
action.go
plugin/dapp/vote/executor/action.go
+13
-1
checktx.go
plugin/dapp/vote/executor/checktx.go
+1
-8
checktx_test.go
plugin/dapp/vote/executor/checktx_test.go
+4
-4
No files found.
plugin/dapp/vote/executor/action.go
View file @
15fc6a0d
...
@@ -165,9 +165,21 @@ func (a *action) commitVote(commit *vty.CommitVote) (*types.Receipt, error) {
...
@@ -165,9 +165,21 @@ func (a *action) commitVote(commit *vty.CommitVote) (*types.Receipt, error) {
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
vote
,
err
:=
a
.
getVoteInfo
(
commit
.
VoteID
)
vote
,
err
:=
a
.
getVoteInfo
(
commit
.
VoteID
)
if
err
!=
nil
{
if
err
!=
nil
{
elog
.
Error
(
"vote exec commitVote"
,
"txHash"
,
a
.
txHash
,
"get vote err"
,
err
)
elog
.
Error
(
"vote exec commitVote"
,
"txHash"
,
a
.
txHash
,
"
vid"
,
commit
.
VoteID
,
"
get vote err"
,
err
)
return
nil
,
errStateDBGet
return
nil
,
errStateDBGet
}
}
// 由于目前底层检测交易阶段提供区块时间可能不是最新区块的,依赖区块时间的比较需要放在执行阶段处理
if
vote
.
BeginTimestamp
>
a
.
blockTime
{
elog
.
Error
(
"vote exec commitVote"
,
"txHash"
,
a
.
txHash
,
"vid"
,
commit
.
VoteID
,
"beginTime"
,
vote
.
BeginTimestamp
,
"blockTime"
,
a
.
blockTime
,
"err"
,
errVoteNotStarted
)
return
nil
,
errVoteNotStarted
}
if
vote
.
EndTimestamp
<=
a
.
blockTime
{
elog
.
Error
(
"vote exec commitVote"
,
"txHash"
,
a
.
txHash
,
"vid"
,
commit
.
VoteID
,
"endTime"
,
vote
.
EndTimestamp
,
"blockTime"
,
a
.
blockTime
,
"err"
,
errVoteAlreadyFinished
)
return
nil
,
errVoteAlreadyFinished
}
group
,
err
:=
a
.
getGroupInfo
(
vote
.
GroupID
)
group
,
err
:=
a
.
getGroupInfo
(
vote
.
GroupID
)
if
err
!=
nil
{
if
err
!=
nil
{
elog
.
Error
(
"vote exec commitVote"
,
"txHash"
,
a
.
txHash
,
"get group err"
,
err
)
elog
.
Error
(
"vote exec commitVote"
,
"txHash"
,
a
.
txHash
,
"get group err"
,
err
)
...
...
plugin/dapp/vote/executor/checktx.go
View file @
15fc6a0d
...
@@ -37,7 +37,7 @@ func (v *vote) CheckTx(tx *types.Transaction, index int) error {
...
@@ -37,7 +37,7 @@ func (v *vote) CheckTx(tx *types.Transaction, index int) error {
}
}
if
err
!=
nil
{
if
err
!=
nil
{
elog
.
Error
(
"vote CheckTx"
,
"txHash"
,
txHash
,
"actionName"
,
tx
.
ActionName
(),
"err"
,
err
,
"actionData"
,
action
)
elog
.
Error
(
"vote CheckTx"
,
"txHash"
,
txHash
,
"actionName"
,
tx
.
ActionName
(),
"err"
,
err
,
"actionData"
,
action
.
String
()
)
}
}
return
err
return
err
}
}
...
@@ -152,13 +152,6 @@ func (v *vote) checkCommitVote(commit *vty.CommitVote, tx *types.Transaction, in
...
@@ -152,13 +152,6 @@ func (v *vote) checkCommitVote(commit *vty.CommitVote, tx *types.Transaction, in
return
err
return
err
}
}
if
voteInfo
.
BeginTimestamp
>
action
.
blockTime
{
return
errVoteNotStarted
}
if
voteInfo
.
EndTimestamp
<=
action
.
blockTime
{
return
errVoteAlreadyFinished
}
if
voteInfo
.
Status
==
voteStatusClosed
{
if
voteInfo
.
Status
==
voteStatusClosed
{
return
errVoteAlreadyClosed
return
errVoteAlreadyClosed
}
}
...
...
plugin/dapp/vote/executor/checktx_test.go
View file @
15fc6a0d
...
@@ -146,7 +146,6 @@ func TestVote_CheckTx_CommitVote(t *testing.T) {
...
@@ -146,7 +146,6 @@ func TestVote_CheckTx_CommitVote(t *testing.T) {
groupID
:=
formatGroupID
(
dapp
.
HeightIndexStr
(
testHeight
,
0
))
groupID
:=
formatGroupID
(
dapp
.
HeightIndexStr
(
testHeight
,
0
))
voteID
:=
formatVoteID
(
dapp
.
HeightIndexStr
(
testHeight
,
1
))
voteID
:=
formatVoteID
(
dapp
.
HeightIndexStr
(
testHeight
,
1
))
vote2
:=
formatVoteID
(
dapp
.
HeightIndexStr
(
testHeight
,
7
))
tcArr
:=
[]
*
testcase
{{
tcArr
:=
[]
*
testcase
{{
index
:
0
,
index
:
0
,
payload
:
&
vty
.
CreateGroup
{
Name
:
"test"
,
Members
:
[]
*
vty
.
GroupMember
{{
Addr
:
testAddrs
[
0
]}}},
payload
:
&
vty
.
CreateGroup
{
Name
:
"test"
,
Members
:
[]
*
vty
.
GroupMember
{{
Addr
:
testAddrs
[
0
]}}},
...
@@ -192,9 +191,10 @@ func TestVote_CheckTx_CommitVote(t *testing.T) {
...
@@ -192,9 +191,10 @@ func TestVote_CheckTx_CommitVote(t *testing.T) {
},
},
execType
:
testTypeExecLocal
,
execType
:
testTypeExecLocal
,
},
{
},
{
index
:
8
,
index
:
8
,
payload
:
&
vty
.
CommitVote
{
VoteID
:
vote2
},
payload
:
&
vty
.
CommitVote
{
VoteID
:
formatVoteID
(
dapp
.
HeightIndexStr
(
testHeight
,
7
))},
expectCheckErr
:
errVoteNotStarted
,
execType
:
testTypeExec
,
expectExecErr
:
errVoteNotStarted
,
}}
}}
testExec
(
t
,
nil
,
testTypeCheckTx
,
tcArr
,
privKeys
[
0
])
testExec
(
t
,
nil
,
testTypeCheckTx
,
tcArr
,
privKeys
[
0
])
...
...
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