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(ProtocolSettings.Load("config.json"), Settings.Default.Storage.Engine, Settings.Default.Storage.Path); 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) { 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}\""); } catch (Exception ex) { Console.WriteLine($"error: {ex.GetBaseException().Message}"); } } }
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}\""); } } }