Пример #1
0
 public Task Start(InitParams initParams)
 {
     return(Task.CompletedTask);
 }
Пример #2
0
        protected async Task StartRunners(InitParams initParams)
        {
            try
            {
                //TODO find better way to enforce assemblies with config impl are loaded
                IKeystoreConfig kConfig; INetworkConfig nConfig; IJsonRpcConfig jConfig;

                var configProvider = new JsonConfigProvider();
                var logManager     = new NLogManager(initParams.LogFileName);
                //configProvider.LoadJsonConfig("");

                //discovering and setting local, remote ips for client machine
                var networkHelper = new NetworkHelper(Logger);
                var localHost     = networkHelper.GetLocalIp()?.ToString() ?? "127.0.0.1";
                var networkConfig = configProvider.GetConfig <NetworkConfig>();
                networkConfig.MasterExternalIp = localHost;
                networkConfig.MasterHost       = localHost;

                ChainSpecLoader chainSpecLoader = new ChainSpecLoader(new UnforgivingJsonSerializer());

                string path = initParams.ChainSpecPath;
                if (!Path.IsPathRooted(path))
                {
                    path = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path));
                }

                byte[]    chainSpecData = File.ReadAllBytes(path);
                ChainSpec chainSpec     = chainSpecLoader.Load(chainSpecData);

                //Setting trusted nodes
                var nodes = chainSpec.NetworkNodes.Select(GetNode).ToArray();
                networkConfig.TrustedPeers = nodes;
                networkConfig.BootNodes    = nodes;
                networkConfig.DbBasePath   = initParams.BaseDbPath;

                _ethereumRunner = new EthereumRunner(configProvider, networkHelper, logManager);
                await _ethereumRunner.Start(initParams);

                if (initParams.JsonRpcEnabled)
                {
                    Bootstrap.Instance.ConfigProvider   = configProvider;
                    Bootstrap.Instance.LogManager       = logManager;
                    Bootstrap.Instance.BlockchainBridge = _ethereumRunner.BlockchainBridge;
                    Bootstrap.Instance.EthereumSigner   = _ethereumRunner.EthereumSigner;

                    _jsonRpcRunner = new JsonRpcRunner(configProvider, Logger);
                    await _jsonRpcRunner.Start(initParams);
                }
                else
                {
                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info("Json RPC is disabled");
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("Error while starting Nethermind.Runner", e);
                throw;
            }
        }