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

[Neo Fix] fix the store crash issue #3124

Merged
merged 4 commits into from
Feb 8, 2024
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
3 changes: 1 addition & 2 deletions src/Neo.CLI/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ public async void Start(CommandLineOptions options)
ProtocolSettings protocol = ProtocolSettings.Load("config.json");
CustomProtocolSettings(options, protocol);
CustomApplicationSettings(options, Settings.Default);
var store = StoreFactory.GetStore(Settings.Default.Storage.Engine, string.Format(Settings.Default.Storage.Path, protocol.Network.ToString("X8")));
shargon marked this conversation as resolved.
Show resolved Hide resolved
NeoSystem = new NeoSystem(protocol, store);
NeoSystem = new NeoSystem(protocol, Settings.Default.Storage.Engine, string.Format(Settings.Default.Storage.Path, protocol.Network.ToString("X8")));
NeoSystem.AddService(this);

LocalNode = NeoSystem.LocalNode.Ask<LocalNode>(new LocalNode.GetInstance()).Result;
Expand Down
20 changes: 10 additions & 10 deletions src/Neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ static NeoSystem()
Plugin.LoadPlugins();
}

/// <summary>
/// Initializes a new instance of the <see cref="NeoSystem"/> class.
/// </summary>
/// <param name="settings">The protocol settings of the <see cref="NeoSystem"/>.</param>
/// <param name="storageEngine">The storage engine used to create the <see cref="IStore"/> objects. If this parameter is <see langword="null"/>, a default in-memory storage engine will be used.</param>
/// <param name="storagePath">The path of the storage. If <paramref name="storageEngine"/> is the default in-memory storage engine, this parameter is ignored.</param>
public NeoSystem(ProtocolSettings settings, string? storageEngine = null, string? storagePath = null) : this(settings, StoreFactory.GetStore(storageEngine ?? nameof(MemoryStore), storagePath))
{
}

/// <summary>
/// Initializes a new instance of the <see cref="NeoSystem"/> class.
/// </summary>
Expand Down Expand Up @@ -208,16 +218,6 @@ public void EnsureStopped(IActorRef actor)
inbox.Receive(TimeSpan.FromMinutes(5));
}

/// <summary>
/// Loads an <see cref="IStore"/> at the specified path.
/// </summary>
/// <param name="path">The path of the storage.</param>
/// <returns>The loaded <see cref="IStore"/>.</returns>
public IStore LoadStore(string path)
{
return StoreFactory.GetStore(store.GetType().Name, path);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this? This will break plugins

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark as obsolete

Copy link
Contributor Author

@Jim8y Jim8y Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3126 now check it here, wont mark it as absolete, still using it. My bad. Need some rest to work more carefully.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its an public API should be marked as obsolete. If you want to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Factory in modules, it's not a problem, currently only neo use neo library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Factory in modules, it's not a problem, currently only neo use neo library.

No, I have searched, neoxp also use it, not sure any other tools also using it. @cschuchardt88 is right, its public, cant be changed easily.

/// <summary>
/// Resumes the startup process of <see cref="LocalNode"/>.
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Neo/Persistence/StoreFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ static StoreFactory()
RegisterProvider(memProvider);

// Default cases

providers.Add("", memProvider);
providers.Add(null, memProvider);
}

public static void RegisterProvider(IStoreProvider provider)
Expand Down