Skip to content

Commit

Permalink
Expose HighPriorityTxType (neo-project#39)
Browse files Browse the repository at this point in the history
* Expose HighPriorityTxType

* HigherLowPriorityTxTypes

* InHigherLowPriorityList

* Modify missing InHigherLowPriorityList

* Missing InHigherLowPriorityList

* Use InHigherLowPriorityList and change to public

* Clean

* Clean II
  • Loading branch information
vncoelho authored and 陈志同 committed Oct 13, 2020
1 parent 731bb64 commit 196fb92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SimplePolicy/SimplePolicyPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IEnumerable<Transaction> FilterForBlock(IEnumerable<Transaction> transact
private static IEnumerable<Transaction> FilterForBlock_Policy1(IEnumerable<Transaction> transactions)
{
int count = 0, count_free = 0;
foreach (Transaction tx in transactions.OrderByDescending(p => p.NetworkFee / p.Size).ThenByDescending(p => p.NetworkFee).ThenByDescending(p => InHighPriorityList(p)))
foreach (Transaction tx in transactions.OrderByDescending(p => p.NetworkFee / p.Size).ThenByDescending(p => p.NetworkFee).ThenByDescending(p => InHigherLowPriorityList(p)))
{
if (count++ >= Settings.Default.MaxTransactionsPerBlock - 1) break;
if (!tx.IsLowPriority || count_free++ < Settings.Default.MaxFreeTransactionsPerBlock)
Expand All @@ -66,7 +66,7 @@ private static IEnumerable<Transaction> FilterForBlock_Policy2(IEnumerable<Trans
Transaction[] free = tx_list.Where(p => p.IsLowPriority)
.OrderByDescending(p => p.NetworkFee / p.Size)
.ThenByDescending(p => p.NetworkFee)
.ThenByDescending(p => InHighPriorityList(p))
.ThenByDescending(p => InHigherLowPriorityList(p))
.ThenByAscending(p => p.Transaction.Hash)
.Take(Settings.Default.MaxFreeTransactionsPerBlock)
.ToArray();
Expand Down Expand Up @@ -98,7 +98,7 @@ void ILogPlugin.Log(string source, LogLevel level, string message)

private bool VerifySizeLimits(Transaction tx)
{
if (InHighPriorityList(tx)) return true;
if (InHigherLowPriorityList(tx)) return true;

// Not Allow free TX bigger than MaxFreeTransactionSize
if (tx.IsLowPriority && tx.Size > Settings.Default.MaxFreeTransactionSize) return false;
Expand All @@ -114,6 +114,6 @@ private bool VerifySizeLimits(Transaction tx)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool InHighPriorityList(Transaction tx) => Settings.Default.HighPriorityTxType.Contains(tx.Type);
public static bool InHigherLowPriorityList(Transaction tx) => Settings.Default.HighPriorityTxType.Contains(tx.Type);
}
}

0 comments on commit 196fb92

Please sign in to comment.