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

Remove unnecessary logic from Mempool #1216

Merged
merged 4 commits into from
Nov 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions neo/Ledger/MemoryPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace Neo.Ledger
public class MemoryPool : IReadOnlyCollection<Transaction>
{
// 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 const int BlocksTillRebroadcast = 10;
vncoelho marked this conversation as resolved.
Show resolved Hide resolved
private int RebroadcastMultiplierThreshold => Capacity / 10;

private static readonly double MaxMillisecondsToReverifyTx = (double)Blockchain.MillisecondsPerBlock / 3;
Expand Down Expand Up @@ -428,9 +427,8 @@ private int ReverifyTransactions(SortedSet<PoolItem> verifiedSortedTxPool,
_txRwLock.EnterWriteLock();
try
{
int blocksTillRebroadcast = Object.ReferenceEquals(unverifiedSortedTxPool, _sortedTransactions)
? BlocksTillRebroadcastHighPriorityPoolTx : BlocksTillRebroadcastLowPriorityPoolTx;

int blocksTillRebroadcast = BlocksTillRebroadcast;
// Increases, proportionally, blocksTillRebroadcast if mempool has more items than threshold bigger RebroadcastMultiplierThreshold
if (Count > RebroadcastMultiplierThreshold)
blocksTillRebroadcast = blocksTillRebroadcast * Count / RebroadcastMultiplierThreshold;

Expand Down Expand Up @@ -478,7 +476,7 @@ private int ReverifyTransactions(SortedSet<PoolItem> verifiedSortedTxPool,
///
/// Note: this must only be called from a single thread (the Blockchain actor)
/// </summary>
/// <param name="maxToVerify">Max transactions to reverify, the value passed cam be >=1</param>
/// <param name="maxToVerify">Max transactions to reverify, the value passed can be >=1</param>
/// <param name="snapshot">The snapshot to use for verifying.</param>
/// <returns>true if more unsorted messages exist, otherwise false</returns>
internal bool ReVerifyTopUnverifiedTransactionsIfNeeded(int maxToVerify, Snapshot snapshot)
Expand Down