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

If worsevalue removed but not found, reinsert new worst item #7097

Merged
merged 1 commit into from
May 29, 2024
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
10 changes: 9 additions & 1 deletion src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,22 @@ private void UpdateSortedValues(EnhancedSortedSet<TValue> bucket, TValue? previo
protected virtual bool Remove(TKey key, TValue value)
{
// Always remove from worst values; as may have been where it came from and dangling item
_worstSortedValues.Remove(value);
bool removed = _worstSortedValues.Remove(value);
// Now remove from cache
if (_cacheMap.Remove(key))
{
UpdateIsFull();
_snapshot = null;
return true;
}
else if (removed)
{
TGroupKey groupMapping = MapToGroup(value);
if (_buckets.TryGetValue(groupMapping, out EnhancedSortedSet<TValue>? bucket))
{
UpdateSortedValues(bucket, previousLast: default);
}
}

return false;
}
Expand Down