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
1ff6da03
Commit
1ff6da03
authored
May 01, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linter warnings
parent
c37744b2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
consensus_state.go
plugin/consensus/dpos/consensus_state.go
+2
-2
state_machine.go
plugin/consensus/dpos/state_machine.go
+3
-3
state_machine_test.go
plugin/consensus/dpos/state_machine_test.go
+2
-2
No files found.
plugin/consensus/dpos/consensus_state.go
View file @
1ff6da03
...
...
@@ -77,7 +77,7 @@ type ConsensusState struct {
Quit
chan
struct
{}
//当前状态
dposState
Dpos
State
dposState
State
//所有选票,包括自己的和从网络中接收到的
dposVotes
[]
*
dpostype
.
DPosVote
...
...
@@ -296,7 +296,7 @@ func (cs *ConsensusState) IsProposer() bool {
}
// SetState method
func
(
cs
*
ConsensusState
)
SetState
(
state
Dpos
State
)
{
func
(
cs
*
ConsensusState
)
SetState
(
state
State
)
{
cs
.
dposState
=
state
}
...
...
plugin/consensus/dpos/state_machine.go
View file @
1ff6da03
...
...
@@ -42,7 +42,7 @@ var VotedStateObj = &VotedState{}
var
WaitNotifyStateObj
=
&
WaitNofifyState
{}
// DPosTask 为计算当前时间所属周期的数据结构
type
DPos
Task
struct
{
type
Task
struct
{
nodeID
int64
cycleStart
int64
cycleStop
int64
...
...
@@ -53,7 +53,7 @@ type DPosTask struct {
}
// DecideTaskByTime 根据时间戳计算所属的周期,包括cycle周期,负责出块周期,当前出块周期
func
DecideTaskByTime
(
now
int64
)
(
task
DPos
Task
)
{
func
DecideTaskByTime
(
now
int64
)
(
task
Task
)
{
task
.
nodeID
=
now
%
dposCycle
/
dposPeriod
task
.
cycleStart
=
now
-
now
%
dposCycle
...
...
@@ -69,7 +69,7 @@ func DecideTaskByTime(now int64) (task DPosTask) {
}
// DposState is the base class of dpos state machine, it defines some interfaces.
type
Dpos
State
interface
{
type
State
interface
{
timeOut
(
cs
*
ConsensusState
)
sendVote
(
cs
*
ConsensusState
,
vote
*
dpostype
.
DPosVote
)
recvVote
(
cs
*
ConsensusState
,
vote
*
dpostype
.
DPosVote
)
...
...
plugin/consensus/dpos/state_machine_test.go
View file @
1ff6da03
...
...
@@ -26,7 +26,7 @@ func setParams(delegateNum int64, blockInterval int64, continueBlockNum int64) {
dposPeriod
=
int64
(
dposBlockInterval
*
dposContinueBlockNum
)
}
func
printTask
(
now
int64
,
task
*
DPos
Task
)
{
func
printTask
(
now
int64
,
task
*
Task
)
{
fmt
.
Printf
(
"now:%v|cycleStart:%v|cycleStop:%v|periodStart:%v|periodStop:%v|blockStart:%v|blockStop:%v|nodeId:%v
\n
"
,
now
,
task
.
cycleStart
,
...
...
@@ -37,7 +37,7 @@ func printTask(now int64, task *DPosTask) {
task
.
blockStop
,
task
.
nodeID
)
}
func
assertTask
(
task
*
DPos
Task
,
t
*
testing
.
T
)
{
func
assertTask
(
task
*
Task
,
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
true
,
task
.
nodeID
>=
0
&&
task
.
nodeID
<
dposDelegateNum
)
assert
.
Equal
(
t
,
true
,
task
.
cycleStart
<=
task
.
periodStart
&&
task
.
periodStart
<=
task
.
blockStart
&&
task
.
blockStop
<=
task
.
periodStop
&&
task
.
periodStop
<=
task
.
cycleStop
)
...
...
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