Skip to content

Commit

Permalink
Pass ApplicationExecution to IPersistencePlugin (neo-project#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
GulfOfAlaska authored and rodoufu committed Mar 3, 2019
1 parent 59d3c2d commit d50a33e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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>();
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
4 changes: 3 additions & 1 deletion neo/Plugins/IPersistencePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
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, IReadOnlyList<ApplicationExecuted> applicationExecutedList);
}
}

0 comments on commit d50a33e

Please sign in to comment.