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 persistence plugins to commit as a final step. #568

Merged
merged 5 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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: 15 additions & 0 deletions neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,21 @@ private void Persist(Block block)
foreach (IPersistencePlugin plugin in Plugin.PersistencePlugins)
plugin.OnPersist(snapshot, all_application_executed);
snapshot.Commit();
foreach (IPersistencePlugin plugin in Plugin.PersistencePlugins)
jsolman marked this conversation as resolved.
Show resolved Hide resolved
{
try
{
plugin.OnCommit(snapshot);
}
catch (Exception ex)
{
if (plugin.ShouldThrowExceptionFromCommit(ex))
{
lastException = ex;
}
}
}
if (lastException != null) throw lastException;
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
jsolman marked this conversation as resolved.
Show resolved Hide resolved
}
UpdateCurrentSnapshot();
OnPersistCompleted(block);
Expand Down
2 changes: 2 additions & 0 deletions neo/Plugins/IPersistencePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ namespace Neo.Plugins
public interface IPersistencePlugin
{
void OnPersist(Snapshot snapshot, IReadOnlyList<ApplicationExecuted> applicationExecutedList);
void OnCommit(Snapshot snapshot);
bool ShouldThrowExceptionFromCommit(Exception ex);
}
}