diff --git a/neo-gui/App.config b/neo-gui/App.config index 4f5f2a99..3dc20bcf 100644 --- a/neo-gui/App.config +++ b/neo-gui/App.config @@ -72,6 +72,9 @@ True + + True + diff --git a/neo-gui/Program.cs b/neo-gui/Program.cs index b44d7568..f1d6e846 100644 --- a/neo-gui/Program.cs +++ b/neo-gui/Program.cs @@ -46,6 +46,7 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc private static bool InstallCertificate() { + if (!Settings.Default.InstallCertificate) return true; using (X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine)) using (X509Certificate2 cert = new X509Certificate2(Resources.OnchainCertificate)) { @@ -62,7 +63,12 @@ private static bool InstallCertificate() return true; } catch (CryptographicException) { } - if (MessageBox.Show(Strings.InstallCertificateText, Strings.InstallCertificateCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) return true; + if (MessageBox.Show(Strings.InstallCertificateText, Strings.InstallCertificateCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) + { + Settings.Default.InstallCertificate = false; + Settings.Default.Save(); + return true; + } try { Process.Start(new ProcessStartInfo @@ -106,12 +112,22 @@ public static void Main() } } 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); + } } } } diff --git a/neo-gui/Properties/AssemblyInfo.cs b/neo-gui/Properties/AssemblyInfo.cs index de1d03d2..3b6a68c8 100644 --- a/neo-gui/Properties/AssemblyInfo.cs +++ b/neo-gui/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ // // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: -[assembly: AssemblyVersion("2.0.*")] +[assembly: AssemblyVersion("2.1.*")] //[assembly: AssemblyVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/neo-gui/Properties/Settings.Designer.cs b/neo-gui/Properties/Settings.Designer.cs index 11a595e7..1cf2cebd 100644 --- a/neo-gui/Properties/Settings.Designer.cs +++ b/neo-gui/Properties/Settings.Designer.cs @@ -46,5 +46,17 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio this["NeedUpgrade"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool InstallCertificate { + get { + return ((bool)(this["InstallCertificate"])); + } + set { + this["InstallCertificate"] = value; + } + } } } diff --git a/neo-gui/Properties/Settings.settings b/neo-gui/Properties/Settings.settings index 21db6c21..102f41c5 100644 --- a/neo-gui/Properties/Settings.settings +++ b/neo-gui/Properties/Settings.settings @@ -8,5 +8,8 @@ True + + True + \ No newline at end of file diff --git a/neo-gui/UI/DeveloperToolsForm.cs b/neo-gui/UI/DeveloperToolsForm.cs index 5e1e2b10..db95d71f 100644 --- a/neo-gui/UI/DeveloperToolsForm.cs +++ b/neo-gui/UI/DeveloperToolsForm.cs @@ -57,7 +57,15 @@ private void button1_Click(object sender, EventArgs e) { string input = InputBox.Show("SignatureContext", "SignatureContext"); if (string.IsNullOrEmpty(input)) return; - context = SignatureContext.Parse(input); + try + { + context = SignatureContext.Parse(input); + } + catch (FormatException ex) + { + MessageBox.Show(ex.Message); + return; + } listBox1.Items.Clear(); listBox2.Items.Clear(); textBox1.Clear(); diff --git a/neo-gui/UI/InvokeContractDialog.cs b/neo-gui/UI/InvokeContractDialog.cs index 5341a655..3bc393de 100644 --- a/neo-gui/UI/InvokeContractDialog.cs +++ b/neo-gui/UI/InvokeContractDialog.cs @@ -140,7 +140,7 @@ private void button5_Click(object sender, EventArgs e) DataCache storages = blockchain.GetTable(); CachedScriptTable script_table = new CachedScriptTable(contracts); StateMachine service = new StateMachine(accounts, validators, assets, contracts, storages); - ApplicationEngine engine = new ApplicationEngine(tx, script_table, service, Fixed8.Zero, true); + ApplicationEngine engine = new ApplicationEngine(TriggerType.Application, tx, script_table, service, Fixed8.Zero, true); engine.LoadScript(tx.Script, false); if (engine.Execute()) { diff --git a/neo-gui/UI/MainForm.cs b/neo-gui/UI/MainForm.cs index 0f3e6dd9..7b964966 100644 --- a/neo-gui/UI/MainForm.cs +++ b/neo-gui/UI/MainForm.cs @@ -287,6 +287,7 @@ private void timer1_Tick(object sender, EventArgs e) lbl_height.Text = $"{Blockchain.Default.Height}/{Blockchain.Default.HeaderHeight}"; lbl_count_node.Text = Program.LocalNode.RemoteNodeCount.ToString(); TimeSpan persistence_span = DateTime.Now - persistence_time; + if (persistence_span < TimeSpan.Zero) persistence_span = TimeSpan.Zero; if (persistence_span > Blockchain.TimePerBlock) { toolStripProgressBar1.Style = ProgressBarStyle.Marquee; @@ -345,8 +346,8 @@ private void timer1_Tick(object sender, EventArgs e) } else { - string asset_name = asset.Asset.AssetType == AssetType.SystemShare ? "NEO" : - asset.Asset.AssetType == AssetType.SystemCoin ? "NeoGas" : + string asset_name = asset.Asset.AssetType == AssetType.GoverningToken ? "NEO" : + asset.Asset.AssetType == AssetType.UtilityToken ? "NeoGas" : asset.Asset.GetName(); listView2.Items.Add(new ListViewItem(new[] { @@ -386,7 +387,7 @@ private void timer1_Tick(object sender, EventArgs e) ListViewItem.ListViewSubItem subitem = item.SubItems["issuer"]; AssetState asset = (AssetState)item.Tag; CertificateQueryResult result; - if (asset.AssetType == AssetType.SystemShare || asset.AssetType == AssetType.SystemCoin) + if (asset.AssetType == AssetType.GoverningToken || asset.AssetType == AssetType.UtilityToken) { result = new CertificateQueryResult { Type = CertificateQueryResultType.System }; } @@ -830,7 +831,7 @@ private void contextMenuStrip2_Opening(object sender, CancelEventArgs e) 删除DToolStripMenuItem1.Enabled = listView2.SelectedIndices.Count > 0; if (删除DToolStripMenuItem1.Enabled) { - 删除DToolStripMenuItem1.Enabled = listView2.SelectedItems.OfType().Select(p => (AssetState)p.Tag).All(p => p.AssetType != AssetType.SystemShare && p.AssetType != AssetType.SystemCoin); + 删除DToolStripMenuItem1.Enabled = listView2.SelectedItems.OfType().Select(p => (AssetState)p.Tag).All(p => p.AssetType != AssetType.GoverningToken && p.AssetType != AssetType.UtilityToken); } } diff --git a/neo-gui/neo-gui.csproj b/neo-gui/neo-gui.csproj index 644d96ed..80294466 100644 --- a/neo-gui/neo-gui.csproj +++ b/neo-gui/neo-gui.csproj @@ -164,8 +164,8 @@ ..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll - - ..\packages\Neo.2.0.2\lib\net461\Neo.dll + + ..\packages\Neo.2.1.0\lib\net461\Neo.dll ..\packages\Neo.VM.2.0.0\lib\net461\Neo.VM.dll diff --git a/neo-gui/packages.config b/neo-gui/packages.config index 9b5a015b..3d657eae 100644 --- a/neo-gui/packages.config +++ b/neo-gui/packages.config @@ -37,7 +37,7 @@ - +