@@ -1276,27 +1276,16 @@ private async Task<bool> MatchActively(ImmutableHashSet<ListedUser> listedUsers,
12761276
12771277 Bot . ArchiLogger . LogGenericTrace ( $ "{ listedUser . SteamID } ...") ;
12781278
1279- byte ? tradeHoldDuration = await Bot . ArchiWebHandler . GetCombinedTradeHoldDurationAgainstUser ( listedUser . SteamID , listedUser . TradeToken ) . ConfigureAwait ( false ) ;
1280-
1281- switch ( tradeHoldDuration ) {
1282- case null :
1283- Bot . ArchiLogger . LogGenericTrace ( Strings . FormatErrorIsEmpty ( nameof ( tradeHoldDuration ) ) ) ;
1284-
1285- continue ;
1286- case > 0 when ( tradeHoldDuration . Value > maxTradeHoldDuration ) || ( tradeHoldDuration . Value > listedUser . MaxTradeHoldDuration ) :
1287- Bot . ArchiLogger . LogGenericTrace ( $ "{ tradeHoldDuration . Value } > { maxTradeHoldDuration } || { listedUser . MaxTradeHoldDuration } ") ;
1288-
1289- continue ;
1290- }
1291-
1292- HashSet < Asset > theirInventory = listedUser . Assets . Where ( item => ( ! listedUser . MatchEverything || item . Tradable ) && wantedSets . Contains ( ( item . RealAppID , item . Type , item . Rarity ) ) && ( ( tradeHoldDuration . Value == 0 ) || ! ( item . Type is EAssetType . FoilTradingCard or EAssetType . TradingCard && CardsFarmer . SalesBlacklist . Contains ( item . RealAppID ) ) ) ) . Select ( static asset => asset . ToAsset ( ) ) . ToHashSet ( ) ;
1279+ HashSet < Asset > theirInventory = listedUser . Assets . Where ( item => ( ! listedUser . MatchEverything || item . Tradable ) && wantedSets . Contains ( ( item . RealAppID , item . Type , item . Rarity ) ) ) . Select ( static asset => asset . ToAsset ( ) ) . ToHashSet ( ) ;
12931280
12941281 if ( theirInventory . Count == 0 ) {
12951282 continue ;
12961283 }
12971284
12981285 skippedSetsThisUser . Clear ( ) ;
12991286
1287+ byte ? tradeHoldDuration = null ;
1288+
13001289 Dictionary < ( uint RealAppID , EAssetType Type , EAssetRarity Rarity ) , Dictionary < ulong , uint > > theirTradableState = MatchingUtilities . GetTradableInventoryState ( theirInventory ) ;
13011290
13021291 for ( byte i = 0 ; i < Trading . MaxTradesPerAccount ; i ++ ) {
@@ -1335,6 +1324,10 @@ private async Task<bool> MatchActively(ImmutableHashSet<ListedUser> listedUsers,
13351324 match = false ;
13361325
13371326 foreach ( ( ulong ourItem , uint ourFullAmount ) in ourFullSet . Where ( static item => item . Value > 1 ) . OrderByDescending ( static item => item . Value ) ) {
1327+ if ( ( tradeHoldDuration > maxTradeHoldDuration ) || ( tradeHoldDuration > listedUser . MaxTradeHoldDuration ) ) {
1328+ break ;
1329+ }
1330+
13381331 if ( ! ourTradableSet . TryGetValue ( ourItem , out uint ourTradableAmount ) || ( ourTradableAmount == 0 ) ) {
13391332 continue ;
13401333 }
@@ -1378,6 +1371,29 @@ private async Task<bool> MatchActively(ImmutableHashSet<ListedUser> listedUsers,
13781371 }
13791372 }
13801373
1374+ // Now that we have a match, check trade hold to ensure user is valid to match against
1375+ // Since it involves remote call, we didn't do it previously, to skip checking against users with no matches for us
1376+ if ( tradeHoldDuration == null ) {
1377+ tradeHoldDuration = await Bot . ArchiWebHandler . GetCombinedTradeHoldDurationAgainstUser ( listedUser . SteamID , listedUser . TradeToken ) . ConfigureAwait ( false ) ;
1378+
1379+ if ( tradeHoldDuration == null ) {
1380+ Bot . ArchiLogger . LogGenericTrace ( Strings . FormatErrorIsEmpty ( nameof ( tradeHoldDuration ) ) ) ;
1381+
1382+ break ;
1383+ }
1384+
1385+ if ( ( tradeHoldDuration . Value > maxTradeHoldDuration ) || ( tradeHoldDuration . Value > listedUser . MaxTradeHoldDuration ) ) {
1386+ Bot . ArchiLogger . LogGenericTrace ( $ "{ tradeHoldDuration . Value } > { maxTradeHoldDuration } || { listedUser . MaxTradeHoldDuration } ") ;
1387+
1388+ break ;
1389+ }
1390+ }
1391+
1392+ if ( ( tradeHoldDuration . Value > 0 ) && set . Type is EAssetType . FoilTradingCard or EAssetType . TradingCard && CardsFarmer . SalesBlacklist . Contains ( set . RealAppID ) ) {
1393+ // We're not considering this set for matching due to trade hold
1394+ continue ;
1395+ }
1396+
13811397 // Skip this set from the remaining of this round
13821398 skippedSetsThisTrade . Add ( set ) ;
13831399
0 commit comments