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
0bdc5921
Commit
0bdc5921
authored
Sep 25, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix reset timer
parent
29677ba5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
10 deletions
+7
-10
consensus_state.go
plugin/consensus/dpos/consensus_state.go
+4
-7
state_machine.go
plugin/consensus/dpos/state_machine.go
+3
-3
No files found.
plugin/consensus/dpos/consensus_state.go
View file @
0bdc5921
...
@@ -193,14 +193,11 @@ func (cs *ConsensusState) Stop() {
...
@@ -193,14 +193,11 @@ func (cs *ConsensusState) Stop() {
// Attempt to reset the timer
// Attempt to reset the timer
func
(
cs
*
ConsensusState
)
resetTimer
(
duration
time
.
Duration
,
stateType
int
)
{
func
(
cs
*
ConsensusState
)
resetTimer
(
duration
time
.
Duration
,
stateType
int
)
{
dposlog
.
Info
(
"set timer"
,
"duration"
,
duration
,
"state"
,
StateTypeMapping
[
stateType
])
dposlog
.
Info
(
"set timer"
,
"duration"
,
duration
,
"state"
,
StateTypeMapping
[
stateType
])
cs
.
timer
.
Reset
(
duration
)
}
// Attempt to reset the timer
func
(
cs
*
ConsensusState
)
stopAndResetTimer
(
duration
time
.
Duration
,
stateType
int
)
{
dposlog
.
Info
(
"set timer"
,
"duration"
,
duration
,
"state"
,
StateTypeMapping
[
stateType
])
if
!
cs
.
timer
.
Stop
()
{
if
!
cs
.
timer
.
Stop
()
{
<-
cs
.
timer
.
C
select
{
case
<-
cs
.
timer
.
C
:
default
:
}
}
}
cs
.
timer
.
Reset
(
duration
)
cs
.
timer
.
Reset
(
duration
)
}
}
...
...
plugin/consensus/dpos/state_machine.go
View file @
0bdc5921
...
@@ -529,7 +529,7 @@ func (voting *VotingState) recvVote(cs *ConsensusState, vote *dpostype.DPosVote)
...
@@ -529,7 +529,7 @@ func (voting *VotingState) recvVote(cs *ConsensusState, vote *dpostype.DPosVote)
}
}
}
}
//1s后检查是否出块,是否需要重新投票
//1s后检查是否出块,是否需要重新投票
cs
.
stopAndR
esetTimer
(
time
.
Millisecond
*
500
,
VotedStateType
)
cs
.
r
esetTimer
(
time
.
Millisecond
*
500
,
VotedStateType
)
}
else
if
result
==
continueToVote
{
}
else
if
result
==
continueToVote
{
dposlog
.
Info
(
"VotingState get a vote, but don't get an agreement,waiting for new votes..."
)
dposlog
.
Info
(
"VotingState get a vote, but don't get an agreement,waiting for new votes..."
)
}
else
{
}
else
{
...
@@ -538,7 +538,7 @@ func (voting *VotingState) recvVote(cs *ConsensusState, vote *dpostype.DPosVote)
...
@@ -538,7 +538,7 @@ func (voting *VotingState) recvVote(cs *ConsensusState, vote *dpostype.DPosVote)
cs
.
ClearVotes
()
cs
.
ClearVotes
()
cs
.
SetState
(
InitStateObj
)
cs
.
SetState
(
InitStateObj
)
dposlog
.
Info
(
"Change state because of vote failed."
,
"from"
,
"VotingState"
,
"to"
,
"InitState"
)
dposlog
.
Info
(
"Change state because of vote failed."
,
"from"
,
"VotingState"
,
"to"
,
"InitState"
)
cs
.
stopAndR
esetTimer
(
time
.
Duration
(
timeoutCheckConnections
)
*
time
.
Millisecond
,
InitStateType
)
cs
.
r
esetTimer
(
time
.
Duration
(
timeoutCheckConnections
)
*
time
.
Millisecond
,
InitStateType
)
}
}
}
}
...
@@ -776,7 +776,7 @@ func (voted *VotedState) recvNotify(cs *ConsensusState, notify *dpostype.DPosNot
...
@@ -776,7 +776,7 @@ func (voted *VotedState) recvNotify(cs *ConsensusState, notify *dpostype.DPosNot
cs
.
ClearVotes
()
cs
.
ClearVotes
()
cs
.
SetState
(
WaitNotifyStateObj
)
cs
.
SetState
(
WaitNotifyStateObj
)
dposlog
.
Info
(
"Change state because of recv notify."
,
"from"
,
"VotedState"
,
"to"
,
"WaitNotifyState"
)
dposlog
.
Info
(
"Change state because of recv notify."
,
"from"
,
"VotedState"
,
"to"
,
"WaitNotifyState"
)
cs
.
stopAndR
esetTimer
(
time
.
Duration
(
timeoutWaitNotify
)
*
time
.
Millisecond
,
WaitNotifyStateType
)
cs
.
r
esetTimer
(
time
.
Duration
(
timeoutWaitNotify
)
*
time
.
Millisecond
,
WaitNotifyStateType
)
if
cs
.
cachedNotify
!=
nil
{
if
cs
.
cachedNotify
!=
nil
{
cs
.
dposState
.
recvNotify
(
cs
,
cs
.
cachedNotify
)
cs
.
dposState
.
recvNotify
(
cs
,
cs
.
cachedNotify
)
}
}
...
...
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