Commit f4739e66 authored by mdj33's avatar mdj33 Committed by 33cn

genesis time support config

parent ef360cb4
......@@ -33,7 +33,7 @@ import (
const (
minBlockNum = 100 //min block number startHeight before lastHeight in mainchain
genesisBlockTime int64 = 1514533390
defaultGenesisBlockTime int64 = 1514533390
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
minerPrivateKey = "6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
defaultGenesisAmount int64 = 1e8
......@@ -73,6 +73,7 @@ type subConfig struct {
WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"`
StartHeight int64 `json:"startHeight,omitempty"`
GenesisBlockTime int64 `json:"genesisBlockTime,omitempty"`
GenesisStartHeightSame bool `json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval []string `json:"emptyBlockInterval,omitempty"`
AuthAccount string `json:"authAccount,omitempty"`
......@@ -107,6 +108,10 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.WriteBlockSeconds = poolMainBlockSec
}
if subcfg.GenesisBlockTime <= 0 {
subcfg.GenesisBlockTime = defaultGenesisBlockTime
}
emptyInterval, err := parseEmptyBlockInterval(subcfg.EmptyBlockInterval)
if err != nil {
panic("para EmptyBlockInterval config not correct")
......@@ -319,7 +324,7 @@ func (client *client) InitBlock() {
// 创世区块
newblock := &types.Block{}
newblock.Height = 0
newblock.BlockTime = genesisBlockTime
newblock.BlockTime = client.subCfg.GenesisBlockTime
newblock.ParentHash = zeroHash[:]
newblock.MainHash = mainHash
......
......@@ -414,7 +414,9 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
newBlock.BlockTime = localBlock.BlockTime
newBlock.MainHash = localBlock.MainHash
newBlock.MainHeight = localBlock.MainHeight
if newBlock.Height == 1 && newBlock.BlockTime < client.paraClient.subCfg.GenesisBlockTime {
panic("genesisBlockTime bigger than the 1st block time, need rmv db and reset genesisBlockTime")
}
err = client.writeBlock(lastBlock.StateHash, &newBlock)
client.printDebugInfo("Para sync - create new Block",
......
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