From cea73a26c1bae5f4bab6302b70e16f0a81e1df5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Thu, 17 Jan 2019 12:18:25 -0200 Subject: [PATCH 1/7] Minnor comment update on Mempool class --- neo/Ledger/MemoryPool.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 67de6f05a1..943c12d4b6 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -433,10 +433,12 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) List invalidItems = new List(); 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 fees it is limited to _maxTxPerBlock, while + // for Low Priority fees it 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; From fc0e55a9cb28b4bc9419af83c5cac4f7ab0b8b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Thu, 17 Jan 2019 13:27:33 -0200 Subject: [PATCH 2/7] minor change in the description --- neo/Ledger/MemoryPool.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 943c12d4b6..3edb68c87b 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -434,8 +434,8 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count)) { // Re-verify up to `count` transactions that can be verified in a block - // for High Priority fees it is limited to _maxTxPerBlock, while - // for Low Priority fees it is limited to _maxLowPriorityTxPerBlock + // for high priority txs cut-off is limited to _maxTxPerBlock, while + // 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 -- it will be removed from unverifiedTxPool. From 122386a320655b0f9b4f91c3527c217925584ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Thu, 17 Jan 2019 15:22:58 -0200 Subject: [PATCH 3/7] Other minor comment changes --- neo/Ledger/MemoryPool.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index b187ac505d..1a4c62a271 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -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; @@ -82,7 +82,6 @@ public int CompareTo(PoolItem otherItem) /// private readonly SortedSet _sortedLowPrioTransactions = new SortedSet(); - /// /// Store the unverified transactions currently in the pool. /// @@ -94,13 +93,12 @@ public int CompareTo(PoolItem otherItem) private readonly SortedSet _unverifiedSortedHighPriorityTransactions = new SortedSet(); private readonly SortedSet _unverifiedSortedLowPriorityTransactions = new SortedSet(); - // 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; From 7fc0eb33993215c69cd4675793369e445a7d8939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Thu, 17 Jan 2019 17:46:16 -0200 Subject: [PATCH 4/7] Updating comment --- neo/Ledger/MemoryPool.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index f3b2e150c7..9065fee65c 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -433,8 +433,7 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count)) { // Re-verify up to `count` transactions that can be verified in a block - // for high priority txs cut-off is limited to _maxTxPerBlock, while - // for low priority txs cut-off is limited to _maxLowPriorityTxPerBlock + // since unverifiedSortedTxPool is ordered in an ascending manner, we take the end of it if (item.Transaction.Verify(snapshot, _unsortedTransactions.Select(p => p.Value.Transaction))) reverifiedItems.Add(item); else // Transaction no longer valid -- it will be removed from unverifiedTxPool. From a0075529412498f790f4b417672856cc8b55ab73 Mon Sep 17 00:00:00 2001 From: jsolman Date: Thu, 17 Jan 2019 11:49:08 -0800 Subject: [PATCH 5/7] Update MemoryPool.cs --- neo/Ledger/MemoryPool.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 9065fee65c..25858b8c21 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -432,8 +432,8 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) List invalidItems = new List(); foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count)) { - // Re-verify up to `count` transactions that can be verified in a block - // since unverifiedSortedTxPool is ordered in an ascending manner, we take the end of it + // Re-verify up to `count` transactions since unverifiedSortedTxPool is ordered + // in an ascending manner, we take the end of it if (item.Transaction.Verify(snapshot, _unsortedTransactions.Select(p => p.Value.Transaction))) reverifiedItems.Add(item); else // Transaction no longer valid -- it will be removed from unverifiedTxPool. From d39c6384446a35bed7144294702e524cb8ff52d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vitor=20Naz=C3=A1rio=20Coelho?= Date: Thu, 17 Jan 2019 17:51:43 -0200 Subject: [PATCH 6/7] Adding dot and passive --- neo/Ledger/MemoryPool.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 25858b8c21..918370b56a 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -433,7 +433,7 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count)) { // Re-verify up to `count` transactions since unverifiedSortedTxPool is ordered - // in an ascending manner, we take the end of it + // in an ascending manner, the end of it is taken. if (item.Transaction.Verify(snapshot, _unsortedTransactions.Select(p => p.Value.Transaction))) reverifiedItems.Add(item); else // Transaction no longer valid -- it will be removed from unverifiedTxPool. From 9d71bd1035ef33de2261acff0443a774adce7120 Mon Sep 17 00:00:00 2001 From: jsolman Date: Thu, 17 Jan 2019 11:54:40 -0800 Subject: [PATCH 7/7] Update MemoryPool.cs --- neo/Ledger/MemoryPool.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/neo/Ledger/MemoryPool.cs b/neo/Ledger/MemoryPool.cs index 918370b56a..521701d0de 100644 --- a/neo/Ledger/MemoryPool.cs +++ b/neo/Ledger/MemoryPool.cs @@ -427,13 +427,12 @@ internal void UpdatePoolForBlockPersisted(Block block, Snapshot snapshot) SortedSet unverifiedSortedTxPool, int count, double secondsTimeout, Snapshot snapshot) { DateTime reverifyCutOffTimeStamp = DateTime.UtcNow.AddSeconds(secondsTimeout); - List reverifiedItems = new List(count); List invalidItems = new List(); + + // Since unverifiedSortedTxPool is ordered in an ascending manner, we take from the end. foreach (PoolItem item in unverifiedSortedTxPool.Reverse().Take(count)) { - // Re-verify up to `count` transactions since unverifiedSortedTxPool is ordered - // in an ascending manner, the end of it is taken. if (item.Transaction.Verify(snapshot, _unsortedTransactions.Select(p => p.Value.Transaction))) reverifiedItems.Add(item); else // Transaction no longer valid -- it will be removed from unverifiedTxPool.