Skip to content

Commit

Permalink
If worsevalue removed but not found, reinsert new worst item (#7097)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored May 29, 2024
1 parent 5804a01 commit f97cd93
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit f97cd93

Please sign in to comment.