Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: configure necessary plugins in the config and install them automatically #3041

Closed
wants to merge 15 commits into from
Closed
4 changes: 4 additions & 0 deletions src/Neo.CLI/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ public async void Start(CommandLineOptions options)
bool verifyImport = !(options.NoVerify ?? false);

ProtocolSettings protocol = ProtocolSettings.Load("config.json");

// install configured plugins
Settings.Default.Plugins.Install.Where(p => !string.IsNullOrEmpty(p)).ToList().ForEach(p => InstallPluginAsync(p).GetAwaiter().GetResult());

CustomProtocolSettings(options, protocol);
CustomApplicationSettings(options, Settings.Default);
NeoSystem = new NeoSystem(protocol, Settings.Default.Storage.Engine, string.Format(Settings.Default.Storage.Path, protocol.Network.ToString("X8")));
Expand Down
4 changes: 4 additions & 0 deletions src/Neo.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Neo.Network.P2P;
using Neo.Persistence;
using System;
using System.Linq;
using System.Reflection;
using System.Threading;

Expand Down Expand Up @@ -169,11 +170,14 @@ public class PluginsSettings
public bool Prerelease { get; init; } = false;
public Version Version { get; init; } = Assembly.GetExecutingAssembly().GetName().Version!;

public string?[] Install { get; init; } = Array.Empty<string>();

public PluginsSettings(IConfigurationSection section)
{
if (section.Exists())
{
DownloadUrl = section.GetValue(nameof(DownloadUrl), DownloadUrl)!;
Install = section.GetSection(nameof(Install)).GetChildren().Select(p => p.Value).ToArray();
#if DEBUG
Prerelease = section.GetValue(nameof(Prerelease), Prerelease);
Version = section.GetValue(nameof(Version), Version)!;
Expand Down
3 changes: 2 additions & 1 deletion src/Neo.CLI/config.fs.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"NeoNameService": "0x7061fbd31562664b58f422c3dee4acfd70dba8af"
},
"Plugins": {
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases"
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases",
"Install": []
}
},
"ProtocolConfiguration": {
Expand Down
3 changes: 2 additions & 1 deletion src/Neo.CLI/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"NeoNameService": "0x50ac1c37690cc2cfc594472833cf57505d5f46de"
},
"Plugins": {
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases"
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases",
"Install": ["LevelDBStore"]
}
},
"ProtocolConfiguration": {
Expand Down
3 changes: 2 additions & 1 deletion src/Neo.CLI/config.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"NeoNameService": "0x50ac1c37690cc2cfc594472833cf57505d5f46de"
},
"Plugins": {
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases"
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases",
"Install": ["LevelDBStore"]
}
},
"ProtocolConfiguration": {
Expand Down
3 changes: 2 additions & 1 deletion src/Neo.CLI/config.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"NeoNameService": "0x50ac1c37690cc2cfc594472833cf57505d5f46de"
},
"Plugins": {
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases"
"DownloadUrl": "https://api.github.com/repos/neo-project/neo-modules/releases",
"Install": ["LevelDBStore"]
}
},
"ProtocolConfiguration": {
Expand Down