Commit 0b7ef948 authored by mdj33's avatar mdj33 Committed by vipwzw

para start wait height config

parent 998d1f1b
......@@ -110,14 +110,14 @@ halvePeriod=1000
ParaRemoteGrpcClient="localhost:8802"
#主链指定高度的区块开始同步
startHeight=345850
#主链指定高度后等待块数,防止主链回滚,联盟链最小为1,小于1则采用缺省高度100
#waitMainBlockNum=100
#打包时间间隔,单位秒
writeBlockSeconds=2
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount=""
#创世地址额度
genesisAmount=100000000
#创世区块时间,新部署链可以修改,缺省2017/12/29
#genesisBlockTime=1514533390
#主链计算blockhash forkheight,需要和主链保持严格一致,不可修改,209186是bityuan主链对应高度, ycc或其他按实际修改
mainBlockHashForkHeight=209186
#主链支持平行链共识tx分叉高度,需要和主链保持严格一致,不可修改,2270000是bityuan主链对应高度, ycc或其他按实际修改
......
......@@ -29,7 +29,7 @@ import (
)
const (
minBlockNum = 100 //min block number startHeight before lastHeight in mainchain
defaultWaitMinBlockNum = 100 //min block number startHeight before lastHeight in mainchain
defaultGenesisBlockTime int64 = 1514533390
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
......@@ -73,6 +73,7 @@ type subConfig struct {
WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"`
StartHeight int64 `json:"startHeight,omitempty"`
WaitMainBlockNum int64 `json:"waitMainBlockNum,omitempty"`
GenesisStartHeightSame bool `json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval []string `json:"emptyBlockInterval,omitempty"`
AuthAccount string `json:"authAccount,omitempty"`
......@@ -109,6 +110,11 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.WriteBlockSeconds = poolMainBlockSec
}
//WaitMainBlockNum 配置最小为1,因为genesis块是startHeight-1, wait=1和startHeight相等
if subcfg.WaitMainBlockNum <= 0 {
subcfg.WaitMainBlockNum = defaultWaitMinBlockNum
}
//最初平行链toml GenesisBlockTime=1514533394,但是未被使用,一直使用的内置的1514533390,最新版本开始适配cfg.GenesisBlockTime,并且
//时间也缺省改为1514533390,支持修改时间, 如果有以前的旧的配置未修改,panic强制修改
if cfg.GenesisBlockTime == 1514533394 {
......@@ -287,7 +293,7 @@ func (client *client) GetStartMainHash(height int64) []byte {
if height > 0 {
hint := time.NewTicker(time.Second * time.Duration(client.subCfg.WriteBlockSeconds))
for lastHeight < height+minBlockNum {
for lastHeight < height+client.subCfg.WaitMainBlockNum {
select {
case <-hint.C:
plog.Info("Waiting lastHeight increase......", "lastHeight", lastHeight, "startHeight", height)
......@@ -300,7 +306,7 @@ func (client *client) GetStartMainHash(height int64) []byte {
}
}
hint.Stop()
plog.Info(fmt.Sprintf("lastHeight more than %d blocks after startHeight", minBlockNum), "lastHeight", lastHeight, "startHeight", height)
plog.Info(fmt.Sprintf("lastHeight more than %d blocks after startHeight", client.subCfg.WaitMainBlockNum), "lastHeight", lastHeight, "startHeight", height)
}
hash, err := client.GetHashByHeightOnMainChain(height)
......
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