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

Expose HighPriorityTxType #39

Merged
merged 9 commits into from
Jan 20, 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
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);
}
}