From d50a33ef599b06b10b097a6b8a1055ee3b35b105 Mon Sep 17 00:00:00 2001 From: Sng Ping Chiang Date: Tue, 1 Jan 2019 22:30:54 +0800 Subject: [PATCH] Pass ApplicationExecution to IPersistencePlugin (#531) --- neo/Ledger/Blockchain.cs | 11 ++++++++--- neo/Plugins/IPersistencePlugin.cs | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/neo/Ledger/Blockchain.cs b/neo/Ledger/Blockchain.cs index 73f123c5af..94a7ec2274 100644 --- a/neo/Ledger/Blockchain.cs +++ b/neo/Ledger/Blockchain.cs @@ -455,6 +455,7 @@ private void Persist(Block block) { using (Snapshot snapshot = GetSnapshot()) { + List all_application_executed = new List(); snapshot.PersistingBlock = block; snapshot.Blocks.Add(block.Hash, new BlockState { @@ -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; @@ -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(); diff --git a/neo/Plugins/IPersistencePlugin.cs b/neo/Plugins/IPersistencePlugin.cs index d70afc53fa..cf4ee697fd 100644 --- a/neo/Plugins/IPersistencePlugin.cs +++ b/neo/Plugins/IPersistencePlugin.cs @@ -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 applicationExecutedList); } }