Skip to content

Commit

Permalink
put _policyChanged in local scope
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Jul 1, 2019
1 parent bcdc435 commit e80bb72
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions neo/Ledger/MemoryPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public class MemoryPool : IReadOnlyCollection<Transaction>

private int _maxTxPerBlock;
private long _feePerByte;
private bool _policyChanged;

/// <summary>
/// Total maximum capacity of transactions the pool can hold.
Expand Down Expand Up @@ -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;
}

/// <summary>
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit e80bb72

Please sign in to comment.