Skip to content

Commit

Permalink
Minor comments update on Mempool class (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
vncoelho authored and jsolman committed Jan 17, 2019
1 parent 0e5434c commit 1aeaf86
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions neo/Ledger/MemoryPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public int CompareTo(PoolItem otherItem)
}
}

// Allow reverified transactions to be rebroadcast if it has been this many block times since last broadcast.
// Allow a reverified transaction to be rebroadcasted if it has been this many block times since last broadcast.
private const int BlocksTillRebroadcastLowPriorityPoolTx = 30;
private const int BlocksTillRebroadcastHighPriorityPoolTx = 10;
private int RebroadcastMultiplierThreshold => Capacity / 10;
Expand Down Expand Up @@ -82,7 +82,6 @@ public int CompareTo(PoolItem otherItem)
/// </summary>
private readonly SortedSet<PoolItem> _sortedLowPrioTransactions = new SortedSet<PoolItem>();


/// <summary>
/// Store the unverified transactions currently in the pool.
///
Expand All @@ -94,13 +93,12 @@ public int CompareTo(PoolItem otherItem)
private readonly SortedSet<PoolItem> _unverifiedSortedHighPriorityTransactions = new SortedSet<PoolItem>();
private readonly SortedSet<PoolItem> _unverifiedSortedLowPriorityTransactions = new SortedSet<PoolItem>();

// internal methods to aid in unit testing
// Internal methods to aid in unit testing
internal int SortedHighPrioTxCount => _sortedHighPrioTransactions.Count;
internal int SortedLowPrioTxCount => _sortedLowPrioTransactions.Count;
internal int UnverifiedSortedHighPrioTxCount => _unverifiedSortedHighPriorityTransactions.Count;
internal int UnverifiedSortedLowPrioTxCount => _unverifiedSortedLowPriorityTransactions.Count;


private int _maxTxPerBlock;
private int _maxLowPriorityTxPerBlock;

Expand Down Expand Up @@ -429,15 +427,15 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot)
SortedSet<PoolItem> unverifiedSortedTxPool, int count, double secondsTimeout, Snapshot snapshot)
{
DateTime reverifyCutOffTimeStamp = DateTime.UtcNow.AddSeconds(secondsTimeout);

List<PoolItem> reverifiedItems = new List<PoolItem>(count);
List<PoolItem> invalidItems = new List<PoolItem>();

// Since unverifiedSortedTxPool is ordered in an ascending manner, we take from the end.
foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count))
{
// Re-verify the top fee max high priority transactions that can be verified in a block
if (item.Transaction.Verify(snapshot, _unsortedTransactions.Select(p => p.Value.Transaction)))
reverifiedItems.Add(item);
else // Transaction no longer valid -- will be removed from unverifiedTxPool.
else // Transaction no longer valid -- it will be removed from unverifiedTxPool.
invalidItems.Add(item);

if (DateTime.UtcNow > reverifyCutOffTimeStamp) break;
Expand Down

0 comments on commit 1aeaf86

Please sign in to comment.