Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
upgrade to 2.1.0
Browse files Browse the repository at this point in the history
1. Fix #1, #21, #27, #30
2. Remember the setting of not installing the certificate
3. Save peers state to file
  • Loading branch information
Erik Zhang committed Aug 20, 2017
1 parent 1d7f298 commit 815cb86
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 11 deletions.
3 changes: 3 additions & 0 deletions neo-gui/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<setting name="NeedUpgrade" serializeAs="String">
<value>True</value>
</setting>
<setting name="InstallCertificate" serializeAs="String">
<value>True</value>
</setting>
</Neo.Properties.Settings>
</userSettings>
</configuration>
18 changes: 17 additions & 1 deletion neo-gui/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
}
}
}
2 changes: 1 addition & 1 deletion neo-gui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("2.0.*")]
[assembly: AssemblyVersion("2.1.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
12 changes: 12 additions & 0 deletions neo-gui/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions neo-gui/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
<Setting Name="NeedUpgrade" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="InstallCertificate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
10 changes: 9 additions & 1 deletion neo-gui/UI/DeveloperToolsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/UI/InvokeContractDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void button5_Click(object sender, EventArgs e)
DataCache<StorageKey, StorageItem> storages = blockchain.GetTable<StorageKey, StorageItem>();
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())
{
Expand Down
9 changes: 5 additions & 4 deletions neo-gui/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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[]
{
Expand Down Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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<ListViewItem>().Select(p => (AssetState)p.Tag).All(p => p.AssetType != AssetType.SystemShare && p.AssetType != AssetType.SystemCoin);
删除DToolStripMenuItem1.Enabled = listView2.SelectedItems.OfType<ListViewItem>().Select(p => (AssetState)p.Tag).All(p => p.AssetType != AssetType.GoverningToken && p.AssetType != AssetType.UtilityToken);
}
}

Expand Down
4 changes: 2 additions & 2 deletions neo-gui/neo-gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
</Reference>
<Reference Include="Neo, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Neo.2.0.2\lib\net461\Neo.dll</HintPath>
<Reference Include="Neo, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Neo.2.1.0\lib\net461\Neo.dll</HintPath>
</Reference>
<Reference Include="Neo.VM, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Neo.VM.2.0.0\lib\net461\Neo.VM.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<package id="Microsoft.Net.Http.Headers" version="1.1.1" targetFramework="net461" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net461" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" />
<package id="Neo" version="2.0.2" targetFramework="net461" />
<package id="Neo" version="2.1.0" targetFramework="net461" />
<package id="Neo.VM" version="2.0.0" targetFramework="net461" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
Expand Down

0 comments on commit 815cb86

Please sign in to comment.