예제 #1
0
        public static void RegisteBlockChain()
        {
            FileStream   fss           = null;
            const string PeerStatePath = "peers.dat";

            if (File.Exists(PeerStatePath))
            {
                using (fss = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fss);
                }
            }

            using (Blockchain.RegisterBlockchain(new LevelDBBlockchain(Settings.Default.Paths.Chain)))
            {
                using (LocalNode = new LocalNode())
                {
                    LocalNode.UpnpEnabled = true;
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.ShowDialog();
                    App.Current.MainWindow = mainWindow;
                }
            }
            using (FileStream fs = new FileStream(PeerStatePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                LocalNode.SaveState(fs);
            }
        }
예제 #2
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            WindowsFormsSynchronizationContext.AutoInstall = false;
            MainForm = new MainForm();
            const string path = "nodes.dat";

            if (File.Exists(path))
            {
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }
            using (LevelDBBlockchain blockchain = new LevelDBBlockchain(Settings.Default.ChainPath))
                using (LocalNode = new LocalNode())
                {
                    Blockchain.RegisterBlockchain(blockchain);
                    LocalNode.Start();
                    Application.Run(MainForm);
                }
            using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                LocalNode.SaveState(fs);
            }
        }
예제 #3
0
        static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if DEBUG
            Debug.WriteLine("Wallet starting ...");
            //AllocConsole();
#endif

            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load("http://localhost/pure/update/update.xml");
            }
            catch { }
            if (xdoc != null)
            {
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value);
                if (version < minimum)
                {
                    using (UpdateWindow dialog = new UpdateWindow(xdoc))
                    {
                        dialog.ShowDialog();
                    }
                    return;
                }
            }

            Form startForm;
            startForm = new MainForm();

            if (File.Exists(Constant.PEER_STATE_PATH))
            {
                using (FileStream fs = new FileStream(Constant.PEER_STATE_PATH, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }
            using (Blockchain.RegisterBlockchain(new LevelDBBlockchain("chain")))
                using (Constant.LocalNode = new LocalNode())
                {
                    Constant.LocalNode.UpnpEnabled = true;
                    Application.Run(startForm);
                }
            using (FileStream fs = new FileStream(Constant.PEER_STATE_PATH, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                LocalNode.SaveState(fs);
            }
        }
예제 #4
0
        public static void Main()
        {
            // Create eventlog.txt for writing event logs to
            using (StreamWriter sw = File.CreateText("eventlog.txt"))
            {
                sw.WriteLine("Event log started at {0}", DateTime.Now.ToString());
                sw.WriteLine();
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load("https://neo.org/client/update.xml");
            }
            catch { }
            if (xdoc != null)
            {
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value);
                if (version < minimum)
                {
                    using (UpdateDialog dialog = new UpdateDialog(xdoc))
                    {
                        dialog.ShowDialog();
                    }
                    return;
                }
            }
            if (!InstallCertificate())
            {
                return;
            }
            const string PeerStatePath = "peers.dat";

            if (File.Exists(PeerStatePath))
            {
                using (FileStream fs = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }
            using (Blockchain.RegisterBlockchain(new LevelDBBlockchain(Settings.Default.Paths.Chain)))
                using (LocalNode = new LocalNode())
                {
                    LocalNode.UpnpEnabled    = true;
                    Application.Run(MainForm = new MainForm(xdoc));
                }
            using (FileStream fs = new FileStream(PeerStatePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                LocalNode.SaveState(fs);
            }
        }
예제 #5
0
파일: Main.cs 프로젝트: RALEx147/NEOSx
        public void startBlockChain(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //XDocument xdoc = null;
            //try
            //{
            //    xdoc = XDocument.Load("https://neo.org/client/update.xml");
            //}
            //catch { }
            //if (xdoc != null)
            //{
            //    Version version = Assembly.GetExecutingAssembly().GetName().Version;
            //    Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value);
            //    if (version < minimum)

            //    {
            //        Console.WriteLine("version behind minuim");
            //            using (UpdateDialog dialog = new UpdateDialog(xdoc))
            //            {
            //                dialog.ShowDialog();
            //            }
            //            return;
            //    }

            //}

            //if (!InstallCertificate()) return;

            const string PeerStatePath = "peers.dat";

            if (File.Exists(PeerStatePath))
            {
                using (FileStream fs = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }

            var chainPath = Properties.Settings.Default.Paths.Chain;

            using (Blockchain.RegisterBlockchain(new LevelDBBlockchain(chainPath)))

                using (LocalNode = new LocalNode())
                {
                    LocalNode.UpnpEnabled = true;
                    //Application.Run(MainForm = new MainForm(xdoc));

                    MainClass mc = new MainClass();
                    mc.runBlockChain();
                    NSApplication.Init();
                    NSApplication.Main(args);
                }
        }
예제 #6
0
파일: Program.cs 프로젝트: PlumpMath/Pure
        public static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);
            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load(Settings.Default.UpdateUrl);
            }
            catch { }
            if (xdoc != null)
            {
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value);
                if (version < minimum)
                {
                    //using (UpdateDialog dialog = new UpdateDialog(xdoc))
                    //{
                    //    dialog.ShowDialog();
                    //}
                    return;
                }
            }
            if (!InstallCertificate())
            {
                return;
            }
            const string PeerStatePath = "peers.dat";

            if (File.Exists(PeerStatePath))
            {
                using (FileStream fs = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }
            using (Blockchain.RegisterBlockchain(new LevelDBBlockchain(Settings.Default.DataDirectoryPath)))
                using (LocalNode = new LocalNode())
                {
                    LocalNode.UpnpEnabled    = true;
                    Application.Run(MainForm = new MainForm(xdoc));
                }
            using (FileStream fs = new FileStream(PeerStatePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                LocalNode.SaveState(fs);
            }
        }
예제 #7
0
        public static void TryLoad()
        {
            if (!File.Exists(PeerStatePath))
            {
                return;
            }

            try
            {
                using (var fileStream = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fileStream);
                }
            }
            catch
            {
                // Swallow exception
                // TODO Log exception somewhere
            }
        }
        private void InitInstance()
        {
            engineTimer          = new DispatcherTimer();
            engineTimer.Tick    += dispatcherTimer_Tick;
            engineTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
            engineTimer.Start();

            currentVerificationContractList = new List <VerificationContract>();

            #region Pages Initializer
            sendPage          = new SendPages();
            receivePage       = new ReceivePage();
            historyPage       = new HistoryPage();
            settingsPage      = new SettingsPage();
            smartContractPage = new SmartContractPage();

            assetInfoPage = new AssetInfoPage();
            taskInfoPage  = new TaskInfoPage();
            #endregion

            #region Pages Event Handlers
            sendPage.TaskChangedEventHandler += TaskChangedEvent;

            settingsPage.ChangeLanguageEvent      += ChangeLanguageEvent;
            settingsPage.UpdateDownloadedFinished += UpdateDownloadedFinishedEvent;
            settingsPage.ResetHistoryEvent        += ResetHistoryEvent;
            settingsPage.TaskChangedEvent         += TaskChangedEvent;
            #endregion

            txHistoryItems = new List <HistoryItem>();
            assetItems     = new List <AssetItem>();

            #region Load Pages
            currentPageStatus = PageStatus.HistoryPage;
            pageMainTransitionControl.ShowPage(historyPage);

            currentSendOrReceivePageStatus = SendOrReceivePageStatus.None;
            currentMenuPageStatus          = MenuPageStatus.AssetPage;
            ShowCurrentMenu();

            #endregion

            if (File.Exists(Constant.PEER_STATE_PATH))
            {
                using (FileStream fs = new FileStream(Constant.PEER_STATE_PATH, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }

            try
            {
                if (Constant.LocalNode == null)
                {
                    Constant.LocalNode             = new LocalNode();
                    Constant.LocalNode.UpnpEnabled = true;
                }
            }
            catch
            {
            }
            finally
            {
            }
        }
예제 #9
0
        static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load("http://13.230.62.42/quras/update/update.xml");
            }
            catch { }
            if (xdoc != null)
            {
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value);
                if (version < minimum)
                {
                    using (UpdateWindow dialog = new UpdateWindow(xdoc))
                    {
                        dialog.ShowDialog();
                        if (dialog.DialogResult != DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
            }
            SplashForm splash = new SplashForm();

            splash.Show();
            Application.DoEvents();
            int zkSnarksKeyStatus = Global.Utils.CheckZKSnarksKeyStatus();

            splash.Hide();
            if (zkSnarksKeyStatus != 0)
            {
                using (DownloadKeyForm dialog = new DownloadKeyForm(zkSnarksKeyStatus))
                {
                    dialog.ShowDialog();
                    if (dialog.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            Form startForm;

            startForm = new WelcomeForm();

            /*
             * if (Settings.Default.LastWalletPath.Length == 0)
             * {
             *  startForm = new WelcomeForm();
             * }
             * else
             * {
             *  startForm = new RestoreWalletForm();
             * }
             */
            FormManager.GetInstance().Push(startForm);

            if (File.Exists(Constant.PEER_STATE_PATH))
            {
                using (FileStream fs = new FileStream(Constant.PEER_STATE_PATH, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fs);
                }
            }
            using (Blockchain.RegisterBlockchain(new LevelDBBlockchain("chain")))
                using (Constant.LocalNode = new LocalNode())
                {
                    Constant.LocalNode.UpnpEnabled = true;
                    Application.Run(startForm);
                }
            using (FileStream fs = new FileStream(Constant.PEER_STATE_PATH, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                LocalNode.SaveState(fs);
            }
        }