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
5a0b57b3
Commit
5a0b57b3
authored
Sep 04, 2019
by
张振华
Browse files
Options
Browse Files
Download
Plain Diff
update
parents
a70c378e
d19a436b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
56 additions
and
38 deletions
+56
-38
consensus_state.go
plugin/consensus/dpos/consensus_state.go
+3
-2
dpos.go
plugin/consensus/dpos/dpos.go
+8
-7
ticker_test.go
plugin/consensus/dpos/ticker_test.go
+2
-1
dpos_msg.pb.go
plugin/consensus/dpos/types/dpos_msg.pb.go
+7
-3
genesis_test.go
plugin/consensus/dpos/types/genesis_test.go
+3
-2
priv_validator_test.go
plugin/consensus/dpos/types/priv_validator_test.go
+7
-6
signable.go
plugin/consensus/dpos/types/signable.go
+2
-1
signable_test.go
plugin/consensus/dpos/types/signable_test.go
+1
-0
util_test.go
plugin/consensus/dpos/types/util_test.go
+5
-4
validator_set_test.go
plugin/consensus/dpos/types/validator_set_test.go
+3
-2
validator_manager.go
plugin/consensus/dpos/validator_manager.go
+1
-0
validator_manager_test.go
plugin/consensus/dpos/validator_manager_test.go
+2
-1
vote.go
plugin/dapp/dposvote/commands/vote.go
+2
-1
dposvotedb.go
plugin/dapp/dposvote/executor/dposvotedb.go
+3
-3
exec_local.go
plugin/dapp/dposvote/executor/exec_local.go
+1
-0
const.go
plugin/dapp/dposvote/types/const.go
+5
-5
dposvote.pb.go
plugin/dapp/dposvote/types/dposvote.pb.go
+0
-0
msg.go
plugin/dapp/dposvote/types/msg.go
+1
-0
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+0
-0
No files found.
plugin/consensus/dpos/consensus_state.go
View file @
5a0b57b3
...
...
@@ -10,13 +10,14 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/33cn/chain33/types"
"reflect"
"runtime/debug"
"sync"
"sync/atomic"
"time"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/common/crypto"
dpostype
"github.com/33cn/plugin/plugin/consensus/dpos/types"
ttypes
"github.com/33cn/plugin/plugin/consensus/dpos/types"
...
...
@@ -33,7 +34,7 @@ const (
voteFail
=
2
//VrfQueryTypeM vrf query type 为查询M信息
VrfQueryTypeM
=
0
VrfQueryTypeM
=
0
//VrfQueryTypeRP vrf query type 为查询RP信息
VrfQueryTypeRP
=
1
...
...
plugin/consensus/dpos/dpos.go
View file @
5a0b57b3
...
...
@@ -8,11 +8,12 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/util"
"strings"
"time"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/common/merkle"
...
...
@@ -49,11 +50,11 @@ var (
dposPeriod
=
dposBlockInterval
*
dposContinueBlockNum
zeroHash
[
32
]
byte
dposPort
=
"36656"
shuffleType
int32
=
dposShuffleTypeOrderByVrfInfo
//shuffleType为1表示使用固定出块顺序,为2表示使用vrf信息进行出块顺序洗牌
whetherUpdateTopN
=
false
//是否更新topN,如果为true,根据下面几个配置项定期更新topN节点;如果为false,则一直使用初始配置的节点,不关注投票结果
blockNumToUpdateDelegate
int64
=
20000
registTopNHeightLimit
int64
=
100
updateTopNHeightLimit
int64
=
200
shuffleType
int32
=
dposShuffleTypeOrderByVrfInfo
//shuffleType为1表示使用固定出块顺序,为2表示使用vrf信息进行出块顺序洗牌
whetherUpdateTopN
=
false
//是否更新topN,如果为true,根据下面几个配置项定期更新topN节点;如果为false,则一直使用初始配置的节点,不关注投票结果
blockNumToUpdateDelegate
int64
=
20000
registTopNHeightLimit
int64
=
100
updateTopNHeightLimit
int64
=
200
)
func
init
()
{
...
...
plugin/consensus/dpos/ticker_test.go
View file @
5a0b57b3
package
dpos
import
(
"github.com/stretchr/testify/assert"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func
TestTicker
(
t
*
testing
.
T
)
{
...
...
plugin/consensus/dpos/types/dpos_msg.pb.go
View file @
5a0b57b3
...
...
@@ -18,9 +18,13 @@ It has these top-level messages:
*/
package
types
import
proto
"github.com/golang/protobuf/proto"
import
fmt
"fmt"
import
math
"math"
import
(
fmt
"fmt"
proto
"github.com/golang/protobuf/proto"
math
"math"
)
// Reference imports to suppress errors if they are not otherwise used.
var
_
=
proto
.
Marshal
...
...
plugin/consensus/dpos/types/genesis_test.go
View file @
5a0b57b3
package
types
import
(
"os"
"testing"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"testing"
)
const
(
...
...
plugin/consensus/dpos/types/priv_validator_test.go
View file @
5a0b57b3
...
...
@@ -5,22 +5,23 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io"
"os"
"sort"
"strings"
"testing"
"time"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const
(
privValidatorFile
=
`{"address":"2FA286246F0222C4FF93210E91AECE0C66723F15","pub_key":{"type":"secp256k1","data":"03EF0E1D3112CF571743A3318125EDE2E52A4EB904BCBAA4B1F75020C2846A7EB4"},"last_height":1679,"last_round":0,"last_step":3,"last_signature":{"type":"secp256k1","data":"37892A916D6E487ADF90F9E88FE37024597677B6C6FED47444AD582F74144B3D6E4B364EAF16AF03A4E42827B6D3C86415D734A5A6CCA92E114B23EB9265AF09"},"last_signbytes":"7B22636861696E5F6964223A22636861696E33332D5A326367466A222C22766F7465223A7B22626C6F636B5F6964223A7B2268617368223A224F6A657975396B2B4149426A6E4859456739584765356A7A462B673D222C227061727473223A7B2268617368223A6E756C6C2C22746F74616C223A307D7D2C22686569676874223A313637392C22726F756E64223A302C2274696D657374616D70223A22323031382D30382D33315430373A35313A34332E3935395A222C2274797065223A327D7D","priv_key":{"type":"secp256k1","data":"5A6A14DA6F5A42835E529D75D87CC8904544F59EEE5387A37D87EEAD194D7EB2"}}`
strAddr
=
"2FA286246F0222C4FF93210E91AECE0C66723F15"
strPubkey
=
"03EF0E1D3112CF571743A3318125EDE2E52A4EB904BCBAA4B1F75020C2846A7EB4"
strAddr
=
"2FA286246F0222C4FF93210E91AECE0C66723F15"
strPubkey
=
"03EF0E1D3112CF571743A3318125EDE2E52A4EB904BCBAA4B1F75020C2846A7EB4"
addr1
=
"79F9608B6826762CACCA843E81AE86837ABFFB21"
addr2
=
"3480088E35099CBA75958DAE7A364A8AAD2C1BD0"
...
...
plugin/consensus/dpos/types/signable.go
View file @
5a0b57b3
...
...
@@ -9,10 +9,11 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/33cn/chain33/common/address"
"io"
"time"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/log/log15"
)
...
...
plugin/consensus/dpos/types/signable_test.go
View file @
5a0b57b3
...
...
@@ -2,6 +2,7 @@ package types
import
(
"encoding/json"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
...
...
plugin/consensus/dpos/types/util_test.go
View file @
5a0b57b3
...
...
@@ -3,14 +3,15 @@ package types
import
(
"bytes"
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"os/signal"
"strings"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func
init
()
{
...
...
@@ -91,10 +92,10 @@ func TestKill(t *testing.T) {
}
var
(
goIndex
=
0
goIndex
=
0
goIndexMutex
sync
.
Mutex
goSum
=
0
goSum
=
0
goSumMutex
sync
.
Mutex
)
...
...
plugin/consensus/dpos/types/validator_set_test.go
View file @
5a0b57b3
...
...
@@ -4,12 +4,13 @@ import (
"bytes"
"encoding/hex"
"fmt"
"strings"
"testing"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"strings"
"testing"
)
const
(
...
...
plugin/consensus/dpos/validator_manager.go
View file @
5a0b57b3
...
...
@@ -8,6 +8,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/address"
ttypes
"github.com/33cn/plugin/plugin/consensus/dpos/types"
dty
"github.com/33cn/plugin/plugin/dapp/dposvote/types"
...
...
plugin/consensus/dpos/validator_manager_test.go
View file @
5a0b57b3
...
...
@@ -3,6 +3,7 @@ package dpos
import
(
"bytes"
"encoding/hex"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
ttypes
"github.com/33cn/plugin/plugin/consensus/dpos/types"
...
...
@@ -17,7 +18,7 @@ import (
const
(
genesisContent
=
`{"genesis_time":"2018-08-16T15:38:56.951569432+08:00","chain_id":"chain33-Z2cgFj","validators":[{"pub_key":{"type":"secp256k1","data":"03EF0E1D3112CF571743A3318125EDE2E52A4EB904BCBAA4B1F75020C2846A7EB4"},"name":""},{"pub_key":{"type":"secp256k1","data":"027848E7FA630B759DB406940B5506B666A344B1060794BBF314EB459D40881BB3"},"name":""},{"pub_key":{"type":"secp256k1","data":"03F4AB6659E61E8512C9A24AC385CC1AC4D52B87D10ADBDF060086EA82BE62CDDE"},"name":""}],"app_hash":null}`
pubkey11
=
"03541AB9887951C038273648545072E5B6A46A639BFF535F3957E8150CBE2A70D7"
pubkey11
=
"03541AB9887951C038273648545072E5B6A46A639BFF535F3957E8150CBE2A70D7"
)
var
(
...
...
plugin/dapp/dposvote/commands/vote.go
View file @
5a0b57b3
...
...
@@ -10,12 +10,13 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/crypto"
"math/rand"
"strconv"
"strings"
"time"
"github.com/33cn/chain33/common/crypto"
vrf
"github.com/33cn/chain33/common/vrf/secp256k1"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
...
...
plugin/dapp/dposvote/executor/dposvotedb.go
View file @
5a0b57b3
...
...
@@ -8,6 +8,9 @@ import (
"bytes"
"encoding/hex"
"fmt"
"sort"
"strings"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/db"
...
...
@@ -15,8 +18,6 @@ import (
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
dty
"github.com/33cn/plugin/plugin/dapp/dposvote/types"
"sort"
"strings"
)
const
(
...
...
@@ -99,7 +100,6 @@ func queryVrfByTime(kvdb db.KVDB, req *dty.DposVrfQuery) (types.Message, error)
return
queryVrfByCycle
(
kvdb
,
req
)
}
func
getJSONVrfs
(
vrfs
[]
*
dty
.
VrfInfo
)
[]
*
dty
.
JSONVrfInfo
{
var
jsonVrfs
[]
*
dty
.
JSONVrfInfo
for
i
:=
0
;
i
<
len
(
vrfs
);
i
++
{
...
...
plugin/dapp/dposvote/executor/exec_local.go
View file @
5a0b57b3
...
...
@@ -6,6 +6,7 @@ package executor
import
(
"fmt"
"github.com/33cn/chain33/types"
dty
"github.com/33cn/plugin/plugin/dapp/dposvote/types"
)
...
...
plugin/dapp/dposvote/types/const.go
View file @
5a0b57b3
...
...
@@ -50,22 +50,22 @@ const (
RegistFrozenCoins
=
1000000000000
//VoteTypeNone 非投票类型
VoteTypeNone
int32
=
1
VoteTypeNone
int32
=
1
//VoteTypeVote 投票类型
VoteTypeVote
int32
=
2
VoteTypeVote
int32
=
2
//VoteTypeCancelVote 撤销投票类型
VoteTypeCancelVote
int32
=
3
VoteTypeCancelVote
int32
=
3
//VoteTypeCancelAllVote 撤销所有投票类型
VoteTypeCancelAllVote
int32
=
4
//TopNCandidatorsVoteInit topN投票状态:初始状态
TopNCandidatorsVoteInit
int64
=
0
TopNCandidatorsVoteInit
int64
=
0
//TopNCandidatorsVoteMajorOK topN投票状态:2/3多数达成一致
TopNCandidatorsVoteMajorOK
int64
=
1
TopNCandidatorsVoteMajorOK
int64
=
1
//TopNCandidatorsVoteMajorFail topN投票状态:2/3多数达成一致失败
TopNCandidatorsVoteMajorFail
int64
=
2
...
...
plugin/dapp/dposvote/types/dposvote.pb.go
View file @
5a0b57b3
This diff is collapsed.
Click to expand it.
plugin/dapp/dposvote/types/msg.go
View file @
5a0b57b3
...
...
@@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/33cn/chain33/common/crypto"
ttypes
"github.com/33cn/plugin/plugin/consensus/dpos/types"
)
...
...
plugin/dapp/guess/types/guess.pb.go
View file @
5a0b57b3
This diff is collapsed.
Click to expand it.
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