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

Pass ApplicationExecution to IPersistencePlugin #531

Merged
11 changes: 8 additions & 3 deletions neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ private void Persist(Block block)
{
using (Snapshot snapshot = GetSnapshot())
{
List<ApplicationExecuted> all_application_executed = new List<ApplicationExecuted>();
Copy link
Contributor

Choose a reason for hiding this comment

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

I know there already isn’t consistency, but I think it is better if we start adopting camel case instead of underscores in the variable naming convention.

snapshot.PersistingBlock = block;
snapshot.Blocks.Add(block.Hash, new BlockState
{
Expand Down Expand Up @@ -605,11 +606,15 @@ private void Persist(Block block)
break;
}
if (execution_results.Count > 0)
Distribute(new ApplicationExecuted
{
ApplicationExecuted application_executed = new ApplicationExecuted
{
Transaction = tx,
ExecutionResults = execution_results.ToArray()
});
};
Distribute(application_executed);
all_application_executed.Add(application_executed);
}
}
snapshot.BlockHashIndex.GetAndChange().Hash = block.Hash;
snapshot.BlockHashIndex.GetAndChange().Index = block.Index;
Expand All @@ -620,7 +625,7 @@ private void Persist(Block block)
snapshot.HeaderHashIndex.GetAndChange().Index = block.Index;
}
foreach (IPersistencePlugin plugin in Plugin.PersistencePlugins)
plugin.OnPersist(snapshot);
plugin.OnPersist(snapshot, all_application_executed);
snapshot.Commit();
}
UpdateCurrentSnapshot();
Expand Down
7 changes: 5 additions & 2 deletions neo/Plugins/IPersistencePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Neo.Persistence;
using Neo.Ledger;
using Neo.Persistence;
using System.Collections.Generic;
using static Neo.Ledger.Blockchain;

namespace Neo.Plugins
{
public interface IPersistencePlugin
{
void OnPersist(Snapshot snapshot);
void OnPersist(Snapshot snapshot, List<ApplicationExecuted> applicationExecutedList);
}
}