public static ChainSpec LoadFromFile(this IChainSpecLoader chainSpecLoader, string filePath) { filePath = filePath.GetApplicationResourcePath(); if (!File.Exists(filePath)) { StringBuilder missingChainspecFileMessage = new StringBuilder($"Chainspec file does not exist {filePath}"); try { missingChainspecFileMessage.AppendLine().AppendLine("Did you mean any of these:"); string[] configFiles = Directory.GetFiles(Path.GetDirectoryName(filePath), "*.json"); for (int i = 0; i < configFiles.Length; i++) { missingChainspecFileMessage.AppendLine($" * {configFiles[i]}"); } } catch (Exception) { // do nothing - the lines above just give extra info and config is loaded at the beginning so unlikely we have any catastrophic errors here } finally { throw new Exception(missingChainspecFileMessage.ToString()); } } return(chainSpecLoader.Load(File.ReadAllBytes(filePath))); }
private void LoadChainSpec() { _logger.Info($"Loading chain spec from {_initConfig.ChainSpecPath}"); IChainSpecLoader loader = string.Equals(_initConfig.ChainSpecFormat, "ChainSpec", StringComparison.InvariantCultureIgnoreCase) ? (IChainSpecLoader) new ChainSpecLoader(_ethereumJsonSerializer) : new GenesisFileLoader(_ethereumJsonSerializer); _chainSpec = loader.LoadFromFile(_initConfig.ChainSpecPath); _chainSpec.Bootnodes = _chainSpec.Bootnodes?.Where(n => !n.NodeId?.Equals(_nodeKey.PublicKey) ?? false).ToArray() ?? new NetworkNode[0]; }
private void LoadChainSpec() { if (_logger.IsInfo) { _logger.Info($"Loading chain spec from {_initConfig.ChainSpecPath}"); } IChainSpecLoader loader = string.Equals(_initConfig.ChainSpecFormat, "ChainSpec", StringComparison.InvariantCultureIgnoreCase) ? (IChainSpecLoader) new ChainSpecLoader(_ethereumJsonSerializer) : new GenesisFileLoader(_ethereumJsonSerializer); if (HiveEnabled) { if (_logger.IsInfo) { _logger.Info($"HIVE chainspec:{Environment.NewLine}{File.ReadAllText(_initConfig.ChainSpecPath)}"); } } _chainSpec = loader.LoadFromFile(_initConfig.ChainSpecPath); _chainSpec.Bootnodes = _chainSpec.Bootnodes?.Where(n => !n.NodeId?.Equals(_nodeKey.PublicKey) ?? false).ToArray() ?? new NetworkNode[0]; }