diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 3affde9016..6ff6b01bdb 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -62,7 +62,6 @@ public class MemoryPool : IReadOnlyCollection private int _maxTxPerBlock; private long _feePerByte; - private bool _policyChanged; /// /// Total maximum capacity of transactions the pool can hold. @@ -101,12 +100,13 @@ public MemoryPool(NeoSystem system, int capacity) Capacity = capacity; } - internal void LoadPolicy(Snapshot snapshot) + internal bool LoadPolicy(Snapshot snapshot) { _maxTxPerBlock = (int)NativeContract.Policy.GetMaxTransactionsPerBlock(snapshot); long newFeePerByte = NativeContract.Policy.GetFeePerByte(snapshot); - _policyChanged = newFeePerByte > _feePerByte; + bool policyChanged = newFeePerByte > _feePerByte; _feePerByte = newFeePerByte; + return policyChanged; } /// @@ -342,12 +342,12 @@ internal void InvalidateVerifiedTransactions() // Note: this must only be called from a single thread (the Blockchain actor) internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) { - LoadPolicy(snapshot); + bool policyChanged = LoadPolicy(snapshot); _txRwLock.EnterWriteLock(); try { - if (_policyChanged) + if (policyChanged) { _unsortedTransactions.Clear(); _sortedTransactions.Clear(); @@ -374,7 +374,7 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) // If we know about headers of future blocks, no point in verifying transactions from the unverified tx pool // until we get caught up. - if (block.Index > 0 && block.Index < Blockchain.Singleton.HeaderHeight || _policyChanged) + if (block.Index > 0 && block.Index < Blockchain.Singleton.HeaderHeight || policyChanged) return; ReverifyTransactions(_sortedTransactions, _unverifiedSortedTransactions,