Skip to content

Commit

Permalink
Reverify transactions when policy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Jul 4, 2019
1 parent 6361bf3 commit d829748
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions neo/Ledger/MemoryPool.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Akka.Actor;
using Akka.Util.Internal;
using Neo.Network.P2P;
using Neo.Network.P2P.Payloads;
Expand Down Expand Up @@ -347,25 +348,23 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot)
_txRwLock.EnterWriteLock();
try
{
// First remove the transactions verified in the block.
foreach (Transaction tx in block.Transactions)
{
if (TryRemoveVerified(tx.Hash, out _)) continue;
TryRemoveUnVerified(tx.Hash, out _);
}

// Add all the previously verified transactions back to the unverified transactions
InvalidateVerifiedTransactions();

if (policyChanged)
{
_unsortedTransactions.Clear();
_sortedTransactions.Clear();
foreach (PoolItem item in _unverifiedSortedTransactions.Reverse())
_system.Blockchain.Tell(item.Tx, ActorRefs.NoSender);
_unverifiedTransactions.Clear();
_unverifiedSortedTransactions.Clear();
}
else
{
// First remove the transactions verified in the block.
foreach (Transaction tx in block.Transactions)
{
if (TryRemoveVerified(tx.Hash, out _)) continue;
TryRemoveUnVerified(tx.Hash, out _);
}

// Add all the previously verified transactions back to the unverified transactions
InvalidateVerifiedTransactions();
}
}
finally
{
Expand Down

0 comments on commit d829748

Please sign in to comment.