Commit 1ff6da03 authored by 张振华's avatar 张振华

fix linter warnings

parent c37744b2
...@@ -77,7 +77,7 @@ type ConsensusState struct { ...@@ -77,7 +77,7 @@ type ConsensusState struct {
Quit chan struct{} Quit chan struct{}
//当前状态 //当前状态
dposState DposState dposState State
//所有选票,包括自己的和从网络中接收到的 //所有选票,包括自己的和从网络中接收到的
dposVotes []*dpostype.DPosVote dposVotes []*dpostype.DPosVote
...@@ -296,7 +296,7 @@ func (cs *ConsensusState) IsProposer() bool { ...@@ -296,7 +296,7 @@ func (cs *ConsensusState) IsProposer() bool {
} }
// SetState method // SetState method
func (cs *ConsensusState) SetState(state DposState) { func (cs *ConsensusState) SetState(state State) {
cs.dposState = state cs.dposState = state
} }
......
...@@ -42,7 +42,7 @@ var VotedStateObj = &VotedState{} ...@@ -42,7 +42,7 @@ var VotedStateObj = &VotedState{}
var WaitNotifyStateObj = &WaitNofifyState{} var WaitNotifyStateObj = &WaitNofifyState{}
// DPosTask 为计算当前时间所属周期的数据结构 // DPosTask 为计算当前时间所属周期的数据结构
type DPosTask struct { type Task struct {
nodeID int64 nodeID int64
cycleStart int64 cycleStart int64
cycleStop int64 cycleStop int64
...@@ -53,7 +53,7 @@ type DPosTask struct { ...@@ -53,7 +53,7 @@ type DPosTask struct {
} }
// DecideTaskByTime 根据时间戳计算所属的周期,包括cycle周期,负责出块周期,当前出块周期 // DecideTaskByTime 根据时间戳计算所属的周期,包括cycle周期,负责出块周期,当前出块周期
func DecideTaskByTime(now int64) (task DPosTask) { func DecideTaskByTime(now int64) (task Task) {
task.nodeID = now % dposCycle / dposPeriod task.nodeID = now % dposCycle / dposPeriod
task.cycleStart = now - now%dposCycle task.cycleStart = now - now%dposCycle
...@@ -69,7 +69,7 @@ func DecideTaskByTime(now int64) (task DPosTask) { ...@@ -69,7 +69,7 @@ func DecideTaskByTime(now int64) (task DPosTask) {
} }
// DposState is the base class of dpos state machine, it defines some interfaces. // DposState is the base class of dpos state machine, it defines some interfaces.
type DposState interface { type State interface {
timeOut(cs *ConsensusState) timeOut(cs *ConsensusState)
sendVote(cs *ConsensusState, vote *dpostype.DPosVote) sendVote(cs *ConsensusState, vote *dpostype.DPosVote)
recvVote(cs *ConsensusState, vote *dpostype.DPosVote) recvVote(cs *ConsensusState, vote *dpostype.DPosVote)
......
...@@ -26,7 +26,7 @@ func setParams(delegateNum int64, blockInterval int64, continueBlockNum int64) { ...@@ -26,7 +26,7 @@ func setParams(delegateNum int64, blockInterval int64, continueBlockNum int64) {
dposPeriod = int64(dposBlockInterval * dposContinueBlockNum) dposPeriod = int64(dposBlockInterval * dposContinueBlockNum)
} }
func printTask(now int64, task *DPosTask) { 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", fmt.Printf("now:%v|cycleStart:%v|cycleStop:%v|periodStart:%v|periodStop:%v|blockStart:%v|blockStop:%v|nodeId:%v\n",
now, now,
task.cycleStart, task.cycleStart,
...@@ -37,7 +37,7 @@ func printTask(now int64, task *DPosTask) { ...@@ -37,7 +37,7 @@ func printTask(now int64, task *DPosTask) {
task.blockStop, task.blockStop,
task.nodeID) task.nodeID)
} }
func assertTask(task *DPosTask, 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.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) assert.Equal(t, true, task.cycleStart <= task.periodStart && task.periodStart <= task.blockStart && task.blockStop <= task.periodStop && task.periodStop <= task.cycleStop)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment