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
7f223ab0
Commit
7f223ab0
authored
May 01, 2019
by
张振华
Browse files
Options
Browse Files
Download
Plain Diff
bugfix
parents
dfd16cdf
c1cfde4e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
16 deletions
+22
-16
state_machine.go
plugin/consensus/dpos/state_machine.go
+10
-7
state_machine_test.go
plugin/consensus/dpos/state_machine_test.go
+4
-3
signable.go
plugin/consensus/dpos/types/signable.go
+3
-2
validator_manager.go
plugin/consensus/dpos/validator_manager.go
+2
-1
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+3
-3
No files found.
plugin/consensus/dpos/state_machine.go
View file @
7f223ab0
...
...
@@ -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
{
...
...
plugin/consensus/dpos/state_machine_test.go
View file @
7f223ab0
...
...
@@ -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"
...
...
plugin/consensus/dpos/types/signable.go
View file @
7f223ab0
...
...
@@ -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
...
...
plugin/consensus/dpos/validator_manager.go
View file @
7f223ab0
...
...
@@ -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
...
...
plugin/dapp/guess/types/guess.pb.go
View file @
7f223ab0
// 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"
,
}
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