Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor comments update on Mempool class #556

Merged
merged 9 commits into from
Jan 17, 2019
12 changes: 6 additions & 6 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 @@ -434,10 +432,12 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot)
List<PoolItem> invalidItems = new List<PoolItem>();
foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count))
{
// Re-verify the top fee max high priority transactions that can be verified in a block
// Re-verify up to `count` transactions that can be verified in a block
// for high priority txs cut-off is limited to _maxTxPerBlock, while
jsolman marked this conversation as resolved.
Show resolved Hide resolved
// for low priority txs cut-off is limited to _maxLowPriorityTxPerBlock
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