public NeoSystem StartUpNode() { _store = new LevelDBStore(Path.GetFullPath(Settings.Default.Paths.Chain)); _system = new NeoSystem(_store); _system.StartNode( port: Settings.Default.P2P.Port, wsPort: 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(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); } } return(_system); }
private void InitializeNeoSystem() { LevelDBStore store = new LevelDBStore(Settings.Paths.Chain); NeoSystem = new NeoSystem(store); NeoSystem.ActorSystem.ActorOf(NotificationBroadcaster.Props(NeoSystem.Blockchain)); NeoSystem.StartNode(Settings.P2P.Port, Settings.P2P.WsPort); }
private static void InitializeNeoSystem(string[] args) { LevelDBStore store = new LevelDBStore(NeoSettings.Default.DataDirectoryPath); NeoSystem = new NeoSystem(store); NeoSystem.StartNode(NeoSettings.Default.NodePort, NeoSettings.Default.WsPort); CreateWebHostBuilder(args).Build().Run(); }
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); } }
public async void Start(string[] args) { if (NeoSystem != null) { return; } bool verifyImport = true; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/noverify": case "--noverify": verifyImport = false; break; } } _ = new Logger(); NeoSystem = new NeoSystem(Settings.Default.Storage.Engine); foreach (var plugin in Plugin.Plugins) { // Register plugins commands RegisterCommand(plugin, plugin.Name); } using (IEnumerator <Block> blocksBeingImported = GetBlocksFromFile().GetEnumerator()) { while (true) { List <Block> blocksToImport = new List <Block>(); for (int i = 0; i < 10; i++) { if (!blocksBeingImported.MoveNext()) { break; } blocksToImport.Add(blocksBeingImported.Current); } if (blocksToImport.Count == 0) { break; } await NeoSystem.Blockchain.Ask <Blockchain.ImportCompleted>(new Blockchain.Import { Blocks = blocksToImport, Verify = verifyImport }); if (NeoSystem is null) { return; } } } NeoSystem.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 { OpenWallet(Settings.Default.UnlockWallet.Path, Settings.Default.UnlockWallet.Password); } catch (FileNotFoundException) { Console.WriteLine($"Warning: wallet file \"{Settings.Default.UnlockWallet.Path}\" not found."); } catch (System.Security.Cryptography.CryptographicException) { Console.WriteLine($"Failed to open file \"{Settings.Default.UnlockWallet.Path}\""); } if (Settings.Default.UnlockWallet.StartConsensus && CurrentWallet != null) { OnStartConsensusCommand(); } } }
public virtual async Task Start(string[] args) { if (NeoSystem != null) { return; } try { NeoSystem = new NeoSystem(CliSettings.Default.Protocol, CliSettings.Default.Storage.Engine, CliSettings.Default.Storage.Path); NeoSystem.AddService(this); LocalNode = await NeoSystem.LocalNode.Ask <LocalNode>(new LocalNode.GetInstance()); } catch (Exception e) { Console.WriteLine(e); throw; } using (IEnumerator <Block> blocksBeingImported = GetBlocksFromFile().GetEnumerator()) { while (true) { List <Block> blocksToImport = new List <Block>(); for (int i = 0; i < 10; i++) { if (!blocksBeingImported.MoveNext()) { break; } blocksToImport.Add(blocksBeingImported.Current); } if (blocksToImport.Count == 0) { break; } await NeoSystem.Blockchain.Ask <Blockchain.ImportCompleted>(new Blockchain.Import { Blocks = blocksToImport }); if (NeoSystem is null) { return; } } } NeoSystem.StartNode(new ChannelsConfig { Tcp = new IPEndPoint(IPAddress.Any, CliSettings.Default.P2P.Port), WebSocket = new IPEndPoint(IPAddress.Any, CliSettings.Default.P2P.WsPort), MinDesiredConnections = CliSettings.Default.P2P.MinDesiredConnections, MaxConnections = CliSettings.Default.P2P.MaxConnections, MaxConnectionsPerAddress = CliSettings.Default.P2P.MaxConnectionsPerAddress }); if (CliSettings.Default.UnlockWallet.IsActive) { try { OpenWallet(CliSettings.Default.UnlockWallet.Path, CliSettings.Default.UnlockWallet.Password); } catch (FileNotFoundException) { Console.WriteLine($"Warning: wallet file \"{CliSettings.Default.UnlockWallet.Path}\" not found."); } catch (CryptographicException) { Console.WriteLine($"failed to open file \"{CliSettings.Default.UnlockWallet.Path}\""); } } }
public async void Start(string[] args) { if (NeoSystem != null) { return; } bool verifyImport = true; for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/noverify": case "--noverify": verifyImport = false; break; } } _ = new Logger(); ProtocolSettings protocol = ProtocolSettings.Load("config.json"); NeoSystem = new NeoSystem(protocol, Settings.Default.Storage.Engine, string.Format(Settings.Default.Storage.Path, protocol.Network.ToString("X8"))); NeoSystem.AddService(this); LocalNode = NeoSystem.LocalNode.Ask <LocalNode>(new LocalNode.GetInstance()).Result; foreach (var plugin in Plugin.Plugins) { // Register plugins commands RegisterCommand(plugin, plugin.Name); } using (IEnumerator <Block> blocksBeingImported = GetBlocksFromFile().GetEnumerator()) { while (true) { List <Block> blocksToImport = new List <Block>(); for (int i = 0; i < 10; i++) { if (!blocksBeingImported.MoveNext()) { break; } blocksToImport.Add(blocksBeingImported.Current); } if (blocksToImport.Count == 0) { break; } await NeoSystem.Blockchain.Ask <Blockchain.ImportCompleted>(new Blockchain.Import { Blocks = blocksToImport, Verify = verifyImport }); if (NeoSystem is null) { return; } } } NeoSystem.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 { OpenWallet(Settings.Default.UnlockWallet.Path, Settings.Default.UnlockWallet.Password); } catch (FileNotFoundException) { ConsoleHelper.Warning($"wallet file \"{Settings.Default.UnlockWallet.Path}\" not found."); } catch (System.Security.Cryptography.CryptographicException) { ConsoleHelper.Error($"Failed to open file \"{Settings.Default.UnlockWallet.Path}\""); } catch (Exception ex) { ConsoleHelper.Error(ex.GetBaseException().Message); } } }
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); } }