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

Run Blockchain actor on its own thread using a PinnedDispatcher. #681

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions neo/IO/Data/LevelDB/WriteOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Neo.IO.Data.LevelDB
public class WriteOptions
{
public static readonly WriteOptions Default = new WriteOptions();
public static readonly WriteOptions DefaultSync = new WriteOptions { Sync = true };
internal readonly IntPtr handle = Native.leveldb_writeoptions_create();

public bool Sync
Expand Down
5 changes: 3 additions & 2 deletions neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class NeoSystem : IDisposable
$"task-manager-mailbox {{ mailbox-type: \"{typeof(TaskManagerMailbox).AssemblyQualifiedName}\" }}" +
$"remote-node-mailbox {{ mailbox-type: \"{typeof(RemoteNodeMailbox).AssemblyQualifiedName}\" }}" +
$"protocol-handler-mailbox {{ mailbox-type: \"{typeof(ProtocolHandlerMailbox).AssemblyQualifiedName}\" }}" +
$"consensus-service-mailbox {{ mailbox-type: \"{typeof(ConsensusServiceMailbox).AssemblyQualifiedName}\" }}");
$"consensus-service-mailbox {{ mailbox-type: \"{typeof(ConsensusServiceMailbox).AssemblyQualifiedName}\" }}" +
$"blockchain-dispatcher {{ type = PinnedDispatcher }}");
public IActorRef Blockchain { get; }
public IActorRef LocalNode { get; }
internal IActorRef TaskManager { get; }
Expand All @@ -35,7 +36,7 @@ public NeoSystem(Store store)
{
this.store = store;
Plugin.LoadPlugins(this);
this.Blockchain = ActorSystem.ActorOf(Ledger.Blockchain.Props(this, store));
this.Blockchain = ActorSystem.ActorOf(Ledger.Blockchain.Props(this, store).WithDispatcher("blockchain-dispatcher"));
this.LocalNode = ActorSystem.ActorOf(Network.P2P.LocalNode.Props(this));
this.TaskManager = ActorSystem.ActorOf(Network.P2P.TaskManager.Props(this));
Plugin.NotifyPluginsLoadedAfterSystemConstructed();
Expand Down
2 changes: 1 addition & 1 deletion neo/Persistence/LevelDB/DbSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public DbSnapshot(DB db)
public override void Commit()
{
base.Commit();
db.Write(WriteOptions.Default, batch);
db.Write(WriteOptions.DefaultSync, batch);
}

public override void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion neo/Persistence/LevelDB/LevelDBStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public override void Put(byte prefix, byte[] key, byte[] value)

public override void PutSync(byte prefix, byte[] key, byte[] value)
{
db.Put(new WriteOptions { Sync = true }, SliceBuilder.Begin(prefix).Add(key), value);
db.Put(WriteOptions.DefaultSync, SliceBuilder.Begin(prefix).Add(key), value);
}
}
}