Commit a70c378e authored by 张振华's avatar 张振华

update

parent 5cb3a78c
...@@ -997,8 +997,6 @@ func (cs *ConsensusState) InitCycleVrfInfos(task Task) { ...@@ -997,8 +997,6 @@ func (cs *ConsensusState) InitCycleVrfInfos(task Task) {
//cs.cycleBoundaryMap[task.cycle] = info //cs.cycleBoundaryMap[task.cycle] = info
cs.UpdateVrfInfos(task.Cycle, infos) cs.UpdateVrfInfos(task.Cycle, infos)
} }
return
} }
// UpdateVrfInfos method // UpdateVrfInfos method
......
...@@ -194,10 +194,10 @@ func checkVrf(cs *ConsensusState) { ...@@ -194,10 +194,10 @@ func checkVrf(cs *ConsensusState) {
dposlog.Info("SendRegistVrfMTx", "pubkey", vrfM.Pubkey, "cycle", vrfM.Cycle, "M", vrfM.M) dposlog.Info("SendRegistVrfMTx", "pubkey", vrfM.Pubkey, "cycle", vrfM.Cycle, "M", vrfM.M)
cs.SendRegistVrfMTx(vrfM) cs.SendRegistVrfMTx(vrfM)
} else { } else {
dposlog.Info("No avaliable LastCBInfo, so don't SendRegistVrfMTx, just wait another cycle") dposlog.Info("No available LastCBInfo, so don't SendRegistVrfMTx, just wait another cycle")
} }
} else { } else {
dposlog.Info("VrfM is already registed", "now", now, "middle", middleTime, "cycle", task.Cycle, "pubkey", strings.ToUpper(hex.EncodeToString(cs.privValidator.GetPubKey().Bytes()))) dposlog.Info("VrfM is already registered", "now", now, "middle", middleTime, "cycle", task.Cycle, "pubkey", strings.ToUpper(hex.EncodeToString(cs.privValidator.GetPubKey().Bytes())))
} }
LastCheckVrfMTime = now LastCheckVrfMTime = now
} else { } else {
......
...@@ -22,8 +22,8 @@ func setParams(delegateNum int64, blockInterval int64, continueBlockNum int64) { ...@@ -22,8 +22,8 @@ func setParams(delegateNum int64, blockInterval int64, continueBlockNum int64) {
dposDelegateNum = delegateNum //委托节点个数,从配置读取,以后可以根据投票结果来定 dposDelegateNum = delegateNum //委托节点个数,从配置读取,以后可以根据投票结果来定
dposBlockInterval = blockInterval //出块间隔,当前按3s dposBlockInterval = blockInterval //出块间隔,当前按3s
dposContinueBlockNum = continueBlockNum //一个委托节点当选后,一次性持续出块数量 dposContinueBlockNum = continueBlockNum //一个委托节点当选后,一次性持续出块数量
dposCycle = int64(dposDelegateNum * dposBlockInterval * dposContinueBlockNum) dposCycle = dposDelegateNum * dposBlockInterval * dposContinueBlockNum
dposPeriod = int64(dposBlockInterval * dposContinueBlockNum) dposPeriod = dposBlockInterval * dposContinueBlockNum
} }
func printTask(now int64, task *Task) { func printTask(now int64, task *Task) {
......
package types package types
import ( import (
"bytes"
"github.com/33cn/chain33/common/crypto" "github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
...@@ -65,7 +64,7 @@ func TestSaveAs(t *testing.T) { ...@@ -65,7 +64,7 @@ func TestSaveAs(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
assert.True(t, genDoc.ChainID == genDoc2.ChainID) assert.True(t, genDoc.ChainID == genDoc2.ChainID)
assert.True(t, genDoc.GenesisTime == genDoc2.GenesisTime) assert.True(t, genDoc.GenesisTime == genDoc2.GenesisTime)
assert.True(t, bytes.Equal(genDoc.AppHash, genDoc2.AppHash)) //assert.True(t, bytes.Equal(genDoc.AppHash, genDoc2.AppHash))
assert.True(t, genDoc.Validators[0].Name == genDoc2.Validators[0].Name) assert.True(t, genDoc.Validators[0].Name == genDoc2.Validators[0].Name)
assert.True(t, genDoc.Validators[0].PubKey.Data == genDoc2.Validators[0].PubKey.Data) assert.True(t, genDoc.Validators[0].PubKey.Data == genDoc2.Validators[0].PubKey.Data)
......
...@@ -115,9 +115,15 @@ func TestParallel(t *testing.T) { ...@@ -115,9 +115,15 @@ func TestParallel(t *testing.T) {
f2 := test f2 := test
f2() f2()
goSumMutex.Lock()
goSum = 0 goSum = 0
goSumMutex.Unlock()
Parallel(f1, f2) Parallel(f1, f2)
goSumMutex.Lock()
assert.True(t, goSum == 2) assert.True(t, goSum == 2)
goSumMutex.Unlock()
} }
func TestRandInt63n(t *testing.T) { func TestRandInt63n(t *testing.T) {
......
...@@ -9,16 +9,10 @@ import ( ...@@ -9,16 +9,10 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/33cn/chain33/common/address" "github.com/33cn/chain33/common/address"
"math/rand"
ttypes "github.com/33cn/plugin/plugin/consensus/dpos/types" ttypes "github.com/33cn/plugin/plugin/consensus/dpos/types"
dty "github.com/33cn/plugin/plugin/dapp/dposvote/types" dty "github.com/33cn/plugin/plugin/dapp/dposvote/types"
) )
var (
r *rand.Rand
)
const ( const (
//ShuffleTypeNoVrf shuffle type: NoVrf, use default address order //ShuffleTypeNoVrf shuffle type: NoVrf, use default address order
...@@ -145,7 +139,7 @@ func MakeGenesisValidatorMgr(genDoc *ttypes.GenesisDoc) (ValidatorMgr, error) { ...@@ -145,7 +139,7 @@ func MakeGenesisValidatorMgr(genDoc *ttypes.GenesisDoc) (ValidatorMgr, error) {
} }
// GetValidatorByIndex method // GetValidatorByIndex method
func (s *ValidatorMgr) GetValidatorByIndex(index int) (addres []byte, val *ttypes.Validator) { func (s *ValidatorMgr) GetValidatorByIndex(index int) (addr []byte, val *ttypes.Validator) {
if index < 0 || index >= len(s.Validators.Validators) { if index < 0 || index >= len(s.Validators.Validators) {
return nil, nil return nil, nil
} }
......
...@@ -1029,7 +1029,7 @@ func (action *Action) RegistVrfM(vrfMReg *dty.DposVrfMRegist) (*types.Receipt, e ...@@ -1029,7 +1029,7 @@ func (action *Action) RegistVrfM(vrfMReg *dty.DposVrfMRegist) (*types.Receipt, e
query := vrfMTable.GetQuery(action.localDB) query := vrfMTable.GetQuery(action.localDB)
_, err = query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfMReg.Cycle)), nil, 1, 0) _, err = query.ListIndex("pubkey_cycle", []byte(fmt.Sprintf("%X:%018d", bPubkey, vrfMReg.Cycle)), nil, 1, 0)
if err == nil { if err == nil {
logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "VrfM already is registed", logger.Error("RegistVrfM failed", "addr", action.fromaddr, "execaddr", action.execaddr, "VrfM already is registered",
vrfMReg.String()) vrfMReg.String())
return nil, dty.ErrVrfMAlreadyRegisted return nil, dty.ErrVrfMAlreadyRegisted
} }
......
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