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

Allow to load store from a specified path #2172

Merged
merged 2 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class NeoSystem : IDisposable
internal IActorRef TaskManager { get; }
public IActorRef Consensus { get; private set; }

private readonly string storage_engine;
private readonly IStore store;
private ChannelsConfig start_message = null;
private bool suspend = false;
Expand All @@ -32,12 +33,11 @@ static NeoSystem()
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}

public NeoSystem(string storageEngine = null)
public NeoSystem(string storageEngine = null, string storagePath = null)
{
Plugin.LoadPlugins(this);
this.store = string.IsNullOrEmpty(storageEngine) || storageEngine == nameof(MemoryStore)
? new MemoryStore()
: Plugin.Storages[storageEngine].GetStore();
this.storage_engine = storageEngine;
this.store = LoadStore(storagePath);
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));
Expand Down Expand Up @@ -69,6 +69,13 @@ public void EnsureStoped(IActorRef actor)
inbox.Receive(TimeSpan.FromMinutes(5));
}

public IStore LoadStore(string path)
{
return string.IsNullOrEmpty(storage_engine) || storage_engine == nameof(MemoryStore)
? new MemoryStore()
: Plugin.Storages[storage_engine].GetStore(path);
}

internal void ResumeNodeStartup()
{
suspend = false;
Expand Down
2 changes: 1 addition & 1 deletion src/neo/Plugins/IStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Neo.Plugins
{
public interface IStorageProvider
{
IStore GetStore();
IStore GetStore(string path);
}
}