Commit 7f223ab0 authored by 张振华's avatar 张振华

bugfix

parents dfd16cdf c1cfde4e
......@@ -9,7 +9,7 @@ import (
"encoding/json"
"math"
"time"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/crypto"
dpostype "github.com/33cn/plugin/plugin/consensus/dpos/types"
......@@ -17,11 +17,11 @@ import (
var (
// InitStateType 为状态机的初始状态
InitStateType = 1
InitStateType = 1
// VotingStateType 为状态机的投票状态
VotingStateType = 2
VotingStateType = 2
// VotedStateType 为状态机的已投票状态
VotedStateType = 3
VotedStateType = 3
// WaitNotifyStateType 为状态机的等待通知状态
WaitNotifyStateType = 4
......@@ -31,10 +31,13 @@ var (
// InitStateObj is the InitState obj
var InitStateObj = &InitState{}
// VotingStateObj is the VotingState obj
var VotingStateObj = &VotingState{}
// VotedStateObj is the VotedState obj
var VotedStateObj = &VotedState{}
// WaitNotifyStateObj is the WaitNotifyState obj
var WaitNotifyStateObj = &WaitNofifyState{}
......@@ -56,7 +59,7 @@ func DecideTaskByTime(now int64) (task DPosTask) {
task.cycleStart = now - now%dposCycle
task.cycleStop = task.cycleStart + dposCycle - 1
task.periodStart = task.cycleStart + task.nodeID * dposBlockInterval * dposContinueBlockNum
task.periodStart = task.cycleStart + task.nodeID*dposBlockInterval*dposContinueBlockNum
task.periodStop = task.periodStart + dposPeriod - 1
task.blockStart = task.periodStart + now%dposCycle%dposPeriod/dposBlockInterval*dposBlockInterval
......@@ -363,12 +366,12 @@ func (voted *VotedState) timeOut(cs *ConsensusState) {
cs.client.SetBlockTime(task.blockStop)
cs.client.CreateBlock()
cs.scheduleDPosTimeout(time.Millisecond * 500, VotedStateType)
cs.scheduleDPosTimeout(time.Millisecond*500, VotedStateType)
return
}
dposlog.Info("Wait time to create block near blockStop.")
cs.scheduleDPosTimeout(time.Millisecond * 500, VotedStateType)
cs.scheduleDPosTimeout(time.Millisecond*500, VotedStateType)
return
} else {
......
......@@ -6,13 +6,14 @@ package dpos
import (
"fmt"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"math/rand"
"testing"
"time"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
_ "github.com/33cn/chain33/system"
_ "github.com/33cn/plugin/plugin/dapp/init"
_ "github.com/33cn/plugin/plugin/store/init"
......
......@@ -9,10 +9,11 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/log/log15"
"io"
"time"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/log/log15"
)
// error defines
......
......@@ -8,8 +8,9 @@ import (
"bytes"
"encoding/json"
"fmt"
ttypes "github.com/33cn/plugin/plugin/consensus/dpos/types"
"math/rand"
ttypes "github.com/33cn/plugin/plugin/consensus/dpos/types"
)
const fee = 1e6
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: dpos_msg.proto
// source: guess.proto
package types
......@@ -2059,7 +2059,7 @@ func init() {
proto.RegisterType((*GuessGameRecords)(nil), "types.GuessGameRecords")
}
func init() { proto.RegisterFile("dpos_msg.proto", fileDescriptor_7574406c5d3430e8) }
func init() { proto.RegisterFile("guess.proto", fileDescriptor_7574406c5d3430e8) }
var fileDescriptor_7574406c5d3430e8 = []byte{
// 1367 bytes of a gzipped FileDescriptorProto
......@@ -2362,5 +2362,5 @@ var _Guess_serviceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "dpos_msg.proto",
Metadata: "guess.proto",
}
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