Skip to content

Commit

Permalink
Send the persisting block to IPersistencePlugin (neo-project#2213)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored and cloud8little committed Jan 24, 2021
1 parent 4aec7b2 commit 93af6a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ private void Persist(Block block)
all_application_executed.Add(application_executed);
}
foreach (IPersistencePlugin plugin in Plugin.PersistencePlugins)
plugin.OnPersist(snapshot, all_application_executed);
plugin.OnPersist(block, snapshot, all_application_executed);
snapshot.Commit();
List<Exception> commitExceptions = null;
foreach (IPersistencePlugin plugin in Plugin.PersistencePlugins)
{
try
{
plugin.OnCommit(snapshot);
plugin.OnCommit(block, snapshot);
}
catch (Exception ex)
{
Expand Down
5 changes: 3 additions & 2 deletions src/neo/Plugins/IPersistencePlugin.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Neo.Network.P2P.Payloads;
using Neo.Persistence;
using System;
using System.Collections.Generic;
Expand All @@ -7,8 +8,8 @@ namespace Neo.Plugins
{
public interface IPersistencePlugin
{
void OnPersist(StoreView snapshot, IReadOnlyList<ApplicationExecuted> applicationExecutedList) { }
void OnCommit(StoreView snapshot) { }
void OnPersist(Block block, StoreView snapshot, IReadOnlyList<ApplicationExecuted> applicationExecutedList) { }
void OnCommit(Block block, StoreView snapshot) { }
bool ShouldThrowExceptionFromCommit(Exception ex) => false;
}
}
4 changes: 2 additions & 2 deletions tests/neo.UnitTests/Plugins/UT_Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void TestIPersistencePlugin()

// With empty default implementation

pp.OnCommit(null);
pp.OnPersist(null, null);
pp.OnCommit(null, null);
pp.OnPersist(null, null, null);
}

[TestMethod]
Expand Down

0 comments on commit 93af6a5

Please sign in to comment.