From af4a605a8cefb85daa0353a1a879d9f90c2008d8 Mon Sep 17 00:00:00 2001 From: Archi Date: Fri, 23 Dec 2022 15:08:36 +0100 Subject: [PATCH] Optimize inventories request --- .../RemoteCommunication.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index 06bf8cf9e..79ed90cb9 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -461,6 +461,17 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { return; } + // Remove from our inventory items that can't be possibly matched due to no dupes to offer available + Dictionary<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity), List> inventorySets = Trading.GetInventorySets(ourInventory); + + ourInventory.RemoveWhere(item => !inventorySets.TryGetValue((item.RealAppID, item.Type, item.Rarity), out List? amounts) || (amounts.Count == 0) || amounts.All(static amount => amount < 2)); + + if (ourInventory.Count == 0) { + Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(ourInventory))); + + return; + } + // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework (HttpStatusCode StatusCode, ImmutableHashSet Users)? response = await Backend.GetListedUsersForMatching(ASF.GlobalConfig.LicenseID.Value, Bot, ourInventory, acceptedMatchableTypes, tradeToken!).ConfigureAwait(false);