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
3aad2bec
Commit
3aad2bec
authored
May 01, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linter warnings
parent
7f223ab0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
4 additions
and
26 deletions
+4
-26
consensus_state.go
plugin/consensus/dpos/consensus_state.go
+0
-2
dpos.go
plugin/consensus/dpos/dpos.go
+2
-4
state_machine.go
plugin/consensus/dpos/state_machine.go
+1
-3
state_machine_test.go
plugin/consensus/dpos/state_machine_test.go
+1
-12
validator_set.go
plugin/consensus/dpos/types/validator_set.go
+0
-3
validator_manager.go
plugin/consensus/dpos/validator_manager.go
+0
-2
No files found.
plugin/consensus/dpos/consensus_state.go
View file @
3aad2bec
...
@@ -22,8 +22,6 @@ import (
...
@@ -22,8 +22,6 @@ import (
// Config
// Config
const
(
const
(
proposalHeartbeatIntervalSeconds
=
1
continueToVote
=
0
continueToVote
=
0
voteSuccess
=
1
voteSuccess
=
1
voteFail
=
2
voteFail
=
2
...
...
plugin/consensus/dpos/dpos.go
View file @
3aad2bec
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
package
dpos
package
dpos
import
(
import
(
"sync"
"time"
"time"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
...
@@ -36,8 +35,8 @@ var (
...
@@ -36,8 +35,8 @@ var (
dposDelegateNum
int64
=
3
//委托节点个数,从配置读取,以后可以根据投票结果来定
dposDelegateNum
int64
=
3
//委托节点个数,从配置读取,以后可以根据投票结果来定
dposBlockInterval
int64
=
3
//出块间隔,当前按3s
dposBlockInterval
int64
=
3
//出块间隔,当前按3s
dposContinueBlockNum
int64
=
6
//一个委托节点当选后,一次性持续出块数量
dposContinueBlockNum
int64
=
6
//一个委托节点当选后,一次性持续出块数量
dposCycle
=
int64
(
dposDelegateNum
*
dposBlockInterval
*
dposContinueBlockNum
)
dposCycle
=
dposDelegateNum
*
dposBlockInterval
*
dposContinueBlockNum
dposPeriod
=
int64
(
dposBlockInterval
*
dposContinueBlockNum
)
dposPeriod
=
dposBlockInterval
*
dposContinueBlockNum
zeroHash
[
32
]
byte
zeroHash
[
32
]
byte
)
)
...
@@ -60,7 +59,6 @@ type Client struct {
...
@@ -60,7 +59,6 @@ type Client struct {
stopC
chan
struct
{}
stopC
chan
struct
{}
isDelegator
bool
isDelegator
bool
blockTime
int64
blockTime
int64
once
sync
.
Once
}
}
type
subConfig
struct
{
type
subConfig
struct
{
...
...
plugin/consensus/dpos/state_machine.go
View file @
3aad2bec
...
@@ -133,7 +133,7 @@ func (init *InitState) timeOut(cs *ConsensusState) {
...
@@ -133,7 +133,7 @@ func (init *InitState) timeOut(cs *ConsensusState) {
index
:=
-
1
index
:=
-
1
for
i
:=
0
;
i
<
cs
.
validatorMgr
.
Validators
.
Size
();
i
++
{
for
i
:=
0
;
i
<
cs
.
validatorMgr
.
Validators
.
Size
();
i
++
{
if
bytes
.
Compare
(
cs
.
validatorMgr
.
Validators
.
Validators
[
i
]
.
Address
,
cs
.
privValidator
.
GetAddress
())
==
0
{
if
bytes
.
Equal
(
cs
.
validatorMgr
.
Validators
.
Validators
[
i
]
.
Address
,
cs
.
privValidator
.
GetAddress
())
{
index
=
i
index
=
i
break
break
}
}
...
@@ -456,9 +456,7 @@ func (voted *VotedState) recvNotify(cs *ConsensusState, notify *dpostype.DPosNot
...
@@ -456,9 +456,7 @@ func (voted *VotedState) recvNotify(cs *ConsensusState, notify *dpostype.DPosNot
cs
.
scheduleDPosTimeout
(
time
.
Duration
(
timeoutWaitNotify
)
*
time
.
Millisecond
,
WaitNotifyStateType
)
cs
.
scheduleDPosTimeout
(
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
)
}
}
return
}
}
// WaitNofifyState is the state of dpos state machine to wait notify.
// WaitNofifyState is the state of dpos state machine to wait notify.
...
...
plugin/consensus/dpos/state_machine_test.go
View file @
3aad2bec
...
@@ -6,24 +6,13 @@ package dpos
...
@@ -6,24 +6,13 @@ package dpos
import
(
import
(
"fmt"
"fmt"
"math/rand"
"testing"
"testing"
"time"
"time"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/plugin/plugin/dapp/init"
_
"github.com/33cn/plugin/plugin/dapp/init"
_
"github.com/33cn/plugin/plugin/store/init"
_
"github.com/33cn/plugin/plugin/store/init"
)
"github.com/stretchr/testify/assert"
var
(
random
*
rand
.
Rand
loopCount
=
10
conn
*
grpc
.
ClientConn
c
types
.
Chain33Client
)
)
func
init
()
{
func
init
()
{
...
...
plugin/consensus/dpos/types/validator_set.go
View file @
3aad2bec
...
@@ -10,12 +10,9 @@ import (
...
@@ -10,12 +10,9 @@ import (
"strings"
"strings"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/common/merkle"
"github.com/33cn/chain33/common/merkle"
)
)
var
validatorsetlog
=
log15
.
New
(
"module"
,
"dpos-val"
)
// Validator ...
// Validator ...
type
Validator
struct
{
type
Validator
struct
{
Address
[]
byte
`json:"address"`
Address
[]
byte
`json:"address"`
...
...
plugin/consensus/dpos/validator_manager.go
View file @
3aad2bec
...
@@ -13,8 +13,6 @@ import (
...
@@ -13,8 +13,6 @@ import (
ttypes
"github.com/33cn/plugin/plugin/consensus/dpos/types"
ttypes
"github.com/33cn/plugin/plugin/consensus/dpos/types"
)
)
const
fee
=
1e6
var
(
var
(
r
*
rand
.
Rand
r
*
rand
.
Rand
)
)
...
...
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