-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix store #3149
Fix store #3149
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ | |
|
||
private ImmutableList<object> services = ImmutableList<object>.Empty; | ||
private readonly IStore store; | ||
private readonly IStoreProvider storageProvider; | ||
private ChannelsConfig start_message = null; | ||
private int suspend = 0; | ||
|
||
|
@@ -113,22 +114,25 @@ | |
/// 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)) | ||
/// <param name="storageProvider">The storage engine used to create the <see cref="IStoreProvider"/> 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="storageProvider"/> is the default in-memory storage engine, this parameter is ignored.</param> | ||
public NeoSystem(ProtocolSettings settings, string? storageProvider = null, string? storagePath = null) : | ||
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (ubuntu-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (ubuntu-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (ubuntu-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (ubuntu-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (windows-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (windows-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (windows-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (windows-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (macos-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (macos-latest)
Check warning on line 119 in src/Neo/NeoSystem.cs GitHub Actions / Test (macos-latest)
|
||
this(settings, StoreFactory.GetStoreProvider(storageProvider ?? nameof(MemoryStore)), storagePath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vncoelho the default is memory |
||
{ | ||
} | ||
|
||
/// <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="storage">The <see cref="IStore"/> to use.</param> | ||
public NeoSystem(ProtocolSettings settings, IStore storage) | ||
/// <param name="storageProvider">The <see cref="IStoreProvider"/> to use.</param> | ||
/// <param name="storagePath">The path of the storage. If <paramref name="storageProvider"/> is the default in-memory storage engine, this parameter is ignored.</param> | ||
public NeoSystem(ProtocolSettings settings, IStoreProvider storageProvider, string? storagePath = null) | ||
Check warning on line 130 in src/Neo/NeoSystem.cs GitHub Actions / Test (ubuntu-latest)
Check warning on line 130 in src/Neo/NeoSystem.cs GitHub Actions / Test (ubuntu-latest)
Check warning on line 130 in src/Neo/NeoSystem.cs GitHub Actions / Test (windows-latest)
Check warning on line 130 in src/Neo/NeoSystem.cs GitHub Actions / Test (windows-latest)
Check warning on line 130 in src/Neo/NeoSystem.cs GitHub Actions / Test (macos-latest)
|
||
{ | ||
this.Settings = settings; | ||
this.GenesisBlock = CreateGenesisBlock(settings); | ||
this.store = storage; | ||
this.storageProvider = storageProvider; | ||
this.store = storageProvider.GetStore(storagePath); | ||
this.MemPool = new MemoryPool(this); | ||
this.Blockchain = ActorSystem.ActorOf(Ledger.Blockchain.Props(this)); | ||
this.LocalNode = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this)); | ||
|
@@ -225,7 +229,7 @@ | |
/// <returns>The loaded <see cref="IStore"/>.</returns> | ||
public IStore LoadStore(string path) | ||
{ | ||
return StoreFactory.GetStore(store.GetType().Name, path); | ||
return storageProvider.GetStore(path); | ||
} | ||
|
||
/// <summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2015-2024 The Neo Project. | ||
// | ||
// MemoryStoreProvider.cs file belongs to the neo project and is free | ||
// software distributed under the MIT software license, see the | ||
// accompanying file LICENSE in the main directory of the | ||
// repository or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
namespace Neo.Persistence | ||
{ | ||
internal class MemoryStoreProvider : IStoreProvider | ||
{ | ||
public string Name => nameof(MemoryStore); | ||
public IStore GetStore(string path) => new MemoryStore(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what will be the default store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory