From 97d14661bbe322fb58be43050c4d24df9b2c64af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Wed, 13 Nov 2019 12:45:05 -0300 Subject: [PATCH] Remove unnecessary logic from Mempool (#1216) --- neo/Ledger/MemoryPool.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 8f37855a5c..15c647f163 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -17,8 +17,7 @@ namespace Neo.Ledger public class MemoryPool : IReadOnlyCollection { // 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; @@ -428,9 +427,8 @@ private int ReverifyTransactions(SortedSet 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; @@ -478,7 +476,7 @@ private int ReverifyTransactions(SortedSet verifiedSortedTxPool, /// /// Note: this must only be called from a single thread (the Blockchain actor) /// - /// Max transactions to reverify, the value passed cam be >=1 + /// Max transactions to reverify, the value passed can be >=1 /// The snapshot to use for verifying. /// true if more unsorted messages exist, otherwise false internal bool ReVerifyTopUnverifiedTransactionsIfNeeded(int maxToVerify, Snapshot snapshot)