chain = ctx.String(ChainFlag.Name)
if strings.HasPrefix(chain, "dynamic") {
configFilePath := ctx.String(ConfigFlag.Name)
if configFilePath == "" {
Fatalf("Config file is required for dynamic chain")
}
// Be sure to set this first
params.DynamicChainConfigPath = filepath.Dir(configFilePath)
filename := path.Join(params.DynamicChainConfigPath, chain+"-conf.json")
genesis := core.GenesisBlockByChainName(chain)
dConf := DynamicConfig{}
if _, err := os.Stat(filename); err == nil {
dConfBytes, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
if err := json.Unmarshal(dConfBytes, &dConf); err != nil {
panic(err)
}
}
genesis.Timestamp = dConf.Timestamp
genesis.GasLimit = dConf.GasLimit
genesis.Difficulty = big.NewInt(dConf.Difficulty)
cfg.Genesis = genesis
genesisHash := libcommon.HexToHash(dConf.Root)
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkID = params.NetworkIDByChainName(chain)
}
SetDNSDiscoveryDefaults(cfg, genesisHash)
} else {
switch chain {
default:
genesis := core.GenesisBlockByChainName(chain)
genesisHash := params.GenesisHashByChainName(chain)
if (genesis == nil) || (genesisHash == nil) {
Fatalf("ChainDB name is not recognized: %s", chain)
新建的自定义链,名称需要以dynamic
关键词,例如dynamic-bcskill-testnet
, 否则会获取对应的hash进行比对
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://www.bcskill.com/index.php/archives/1986.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!