Skip to content

Commit

Permalink
Remove unnecessary logic from Mempool (neo-project#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
vncoelho authored and Tommo-L committed Jun 22, 2020
1 parent a1c2aef commit 97d1466
Showing 1 changed file with 4 additions and 6 deletions.
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;
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

0 comments on commit 97d1466

Please sign in to comment.