protected internal override void OnStart(string[] args) { bool useRPC = false; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/rpc": case "--rpc": case "-r": useRPC = true; break; } } store = new LevelDBStore(Path.GetFullPath(Settings.Default.Paths.Chain)); system = new NeoSystem(store); system.StartNode(new ChannelsConfig { Tcp = new IPEndPoint(IPAddress.Any, Settings.Default.P2P.Port), WebSocket = new IPEndPoint(IPAddress.Any, Settings.Default.P2P.WsPort), MinDesiredConnections = Settings.Default.P2P.MinDesiredConnections, MaxConnections = Settings.Default.P2P.MaxConnections, MaxConnectionsPerAddress = Settings.Default.P2P.MaxConnectionsPerAddress }); if (Settings.Default.UnlockWallet.IsActive) { try { Program.Wallet = OpenWallet(Settings.Default.UnlockWallet.Path, Settings.Default.UnlockWallet.Password); } catch (CryptographicException) { Console.WriteLine($"failed to open file \"{Settings.Default.UnlockWallet.Path}\""); } if (Settings.Default.UnlockWallet.StartConsensus && Program.Wallet != null) { OnStartConsensusCommand(null); } } if (useRPC) { system.StartRpc(Settings.Default.RPC.BindAddress, Settings.Default.RPC.Port, wallet: Program.Wallet, sslCert: Settings.Default.RPC.SslCert, password: Settings.Default.RPC.SslCertPassword, maxGasInvoke: Settings.Default.RPC.MaxGasInvoke); } }
public static Task RunAsync(Store store, ExpressConsensusNode node, TextWriter writer, CancellationToken cancellationToken) { var tcs = new TaskCompletionSource <bool>(); Task.Run(() => { try { var wallet = DevWallet.FromExpressWallet(node.Wallet); using (var system = new NeoSystem(store)) { var logPlugin = new LogPlugin(writer); var rpcPlugin = new ExpressNodeRpcPlugin(store); system.StartNode(node.TcpPort, node.WebSocketPort); system.StartConsensus(wallet); system.StartRpc(IPAddress.Loopback, node.RpcPort, wallet); { using var snapshot = Blockchain.Singleton.GetSnapshot(); var validators = snapshot.GetValidators(); ; } cancellationToken.WaitHandle.WaitOne(); } } catch (Exception ex) { tcs.SetException(ex); } finally { if (store is IDisposable disposable) { disposable.Dispose(); } tcs.TrySetResult(true); } }); return(tcs.Task); }
protected internal override void OnStart(string[] args) { bool useRPC = false; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/rpc": case "--rpc": case "-r": useRPC = true; break; } } store = new LevelDBStore(Path.GetFullPath(Settings.Default.Paths.Chain)); system = new NeoSystem(store); system.StartNode(Settings.Default.P2P.Port, Settings.Default.P2P.WsPort); if (Settings.Default.UnlockWallet.IsActive) { try { Program.Wallet = OpenWallet(GetIndexer(), Settings.Default.UnlockWallet.Path, Settings.Default.UnlockWallet.Password); } catch (CryptographicException) { Console.WriteLine($"failed to open file \"{Settings.Default.UnlockWallet.Path}\""); } if (Settings.Default.UnlockWallet.StartConsensus && Program.Wallet != null) { OnStartConsensusCommand(null); } } if (useRPC) { system.StartRpc(Settings.Default.RPC.BindAddress, Settings.Default.RPC.Port, wallet: Program.Wallet, sslCert: Settings.Default.RPC.SslCert, password: Settings.Default.RPC.SslCertPassword); } }
protected internal override void OnStart(string[] args) { bool useRPC = false; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/rpc": case "--rpc": case "-r": useRPC = true; break; case "/testnet": case "--testnet": case "-t": ProtocolSettings.Initialize(new ConfigurationBuilder().AddJsonFile("protocol.testnet.json").Build()); Settings.Initialize(new ConfigurationBuilder().AddJsonFile("config.testnet.json").Build()); break; case "/mainnet": case "--mainnet": case "-m": ProtocolSettings.Initialize(new ConfigurationBuilder().AddJsonFile("protocol.mainnet.json").Build()); Settings.Initialize(new ConfigurationBuilder().AddJsonFile("config.mainnet.json").Build()); break; } } system = new NeoSystem(); system.StartNode(new ChannelsConfig { Tcp = new IPEndPoint(IPAddress.Any, Settings.Default.P2P.Port), WebSocket = new IPEndPoint(IPAddress.Any, Settings.Default.P2P.WsPort), MinDesiredConnections = Settings.Default.P2P.MinDesiredConnections, MaxConnections = Settings.Default.P2P.MaxConnections, MaxConnectionsPerAddress = Settings.Default.P2P.MaxConnectionsPerAddress }); if (Settings.Default.UnlockWallet.IsActive) { try { Program.Wallet = OpenWallet(Settings.Default.UnlockWallet.Path, Settings.Default.UnlockWallet.Password); } catch (FileNotFoundException) { Console.WriteLine($"Warning: wallet file \"{Settings.Default.UnlockWallet.Path}\" not found."); } catch (CryptographicException) { Console.WriteLine($"failed to open file \"{Settings.Default.UnlockWallet.Path}\""); } if (Settings.Default.UnlockWallet.StartConsensus && Program.Wallet != null) { OnStartConsensusCommand(null); } } if (useRPC) { system.StartRpc(Settings.Default.RPC.BindAddress, Settings.Default.RPC.Port, wallet: Program.Wallet, sslCert: Settings.Default.RPC.SslCert, password: Settings.Default.RPC.SslCertPassword, maxGasInvoke: Settings.Default.RPC.MaxGasInvoke); } }