Skip to content

Commit

Permalink
Load plugins before initializing the system and call OnPluginsLoaded …
Browse files Browse the repository at this point in the history
…afterward. (#633)
  • Loading branch information
jsolman authored Mar 12, 2019
1 parent d3094c2 commit 432a3f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public class NeoSystem : IDisposable
public NeoSystem(Store store)
{
this.store = store;
Plugin.LoadPlugins(this);
this.Blockchain = ActorSystem.ActorOf(Ledger.Blockchain.Props(this, store));
this.LocalNode = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this));
this.TaskManager = ActorSystem.ActorOf(Network.P2P.TaskManager.Props(this));
Plugin.LoadPlugins(this);
Plugin.NotifyPluginsLoadedAfterSystemConstructed();
}

public void Dispose()
Expand Down
10 changes: 10 additions & 0 deletions neo/Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public static bool CheckPolicy(Transaction tx)

public abstract void Configure();

protected virtual void OnPluginsLoaded()
{
}

private static void ConfigWatcher_Changed(object sender, FileSystemEventArgs e)
{
foreach (var plugin in Plugins)
Expand Down Expand Up @@ -110,6 +114,12 @@ internal static void LoadPlugins(NeoSystem system)
}
}

internal static void NotifyPluginsLoadedAfterSystemConstructed()
{
foreach (var plugin in Plugins)
plugin.OnPluginsLoaded();
}

protected void Log(string message, LogLevel level = LogLevel.Info)
{
Log($"{nameof(Plugin)}:{Name}", level, message);
Expand Down

0 comments on commit 432a3f6

Please sign in to comment.