Commit Graph

123 Commits

Author SHA1 Message Date
JustArchi
774b63ca83 Misc 2017-06-19 08:23:01 +02:00
JustArchi
7bd2ce650c Misc code review 2017-04-27 01:57:04 +02:00
JustArchi
87ea402de6 Improve OnNewGameAdded() event
This event should work similar to Trading.OnNewTrade() event - we can call it many times, especially once per each game being added, and if we're adding many games through a bundle or app_license_request, we might quickly run into having 30+ badge parsing tasks queued, which doesn't make much sense considering that just 2 are sufficient for an update.
Correct it in a way that makes both me and Steam servers happy.
2017-04-16 18:15:09 +02:00
JustArchi
c990c57036 Misc 2017-04-08 20:34:17 +02:00
JustArchi
8c0a100ae8 Enhance InventoryLimiterDelay
Gifts/Login limiter is actually working decent, because response is nearly instant and fast enough to not worry about it in long-run.
With inventory things are entirely different, as inventory fetching might take even a very long time, and while fetching one inventory, we might already run out of our delay and start fetching another one.
This is not a big functionality-wise, as it's nothing new for ASF to parse multiple inventories concurrently, but Steam Community actually counts number of requests, and our inventory function might ask for multiple pages during execution, which could quickly lead to a situation of 10+ ongoing inventory requests being sent concurrently for too many accounts at once, as we can't predict not only how long the request will be handled, but also how many sub-requests we will do across one.
This means that for optimal performance in terms of rate-limiting, we must limit ASF to one inventory request at a time, with mandatory InventoryLimiterDelay before asking for another one.
This can degrade performance of previously fast !loot requests on multiple accounts at once (especially with bigger inventories), but it will also decrease significantly a chance of getting rate-limited and requests failing.
2017-04-08 04:47:38 +02:00
JustArchi
4e1a03222b Fix potential STM logic exploit
Previously we calculated amounts (and therefore, differences) based on cards only, which means that user could earn some extra 'points' in our calculation for giving us many trash cards that we miss, and in exchange for that swap cards from some other game that would normally results in non-neutral difference on that game basis, but neutral+ in overall basis (that we operated on).
This would not cause any serious problem, because ASF ensures that trade is fair before calculating actual neutrality, but it could result in accepting a trade that is neutral+ only at first sight, and non-neutral+ when we take a closer look what we're actually swapping.
The logic was enhanced to handle differences on per-game basis now, and taking minimum in account, so all swaps on per-game basis have to be neutral+ now
2017-04-08 04:33:01 +02:00
JustArchi
fcf9686a79 Revert "Resharper cleanup"
This reverts commit 7c8d7b5ada.

Bad cleanup.
2017-04-05 17:01:18 +02:00
JustArchi
7c8d7b5ada Resharper cleanup 2017-04-05 16:59:48 +02:00
JustArchi
c7515f9024 Post-merge Resharper fixes #501 2017-04-05 16:17:34 +02:00
Logerfo
e4da0c05d5 Merge branch 'master' into master 2017-04-05 10:33:13 -03:00
JustArchi
8a54f1b355 Revert "EXPERIMENTAL: Packages update [1/2] #514"
This reverts commit 588af12d0b.

Not ready yet.
2017-03-29 13:01:36 +02:00
JustArchi
588af12d0b EXPERIMENTAL: Packages update [1/2] #514 2017-03-29 12:57:19 +02:00
JustArchi
4f5d46b422 Closes #515 2017-03-28 21:27:01 +02:00
JustArchi
5e5e4d11f8 Misc log fix 2017-03-21 15:57:34 +01:00
JustArchi
39a8d9c8a2 SteamUserPermissions revolution
This is needed for defining multiple operators and/or masters, as well as eventual further enhancements
2017-03-15 11:56:20 +01:00
Bruno Logerfo
f8b2fcda7a C# 7.0 syntax sugars 2017-03-14 08:20:29 -03:00
JustArchi
11e429a73f Don't accept STM trades when we can't check our inventory
It's nice to note that MatchEverything doesn't even bother with loading the inventory at all.
2017-02-23 17:07:51 +01:00
JustArchi
c557e9153f Misc 2017-02-16 15:44:20 +01:00
JustArchi
178eac5db7 Make it possible to use AcceptDonations together with DontAcceptBotTrades 2017-02-16 15:39:43 +01:00
JustArchi
a8045ac50b Fix async/await with ConcurrentHashSet
Now this is a nice bug that was found accidentally by ArchiBoT...
ReaderWriterLockSlim() is very decent solution, but it's thread-based, and we're using our ConcurrentHashSet in mixed async/sync context. This means that if we use something like:
foreach (var item in concHashSet) {
    await AnythingAsync().ConfigureAwait(false);
}
It's totally possible that we'll request read lock as thread 1, and release the read lock as thread 2, which will lead to RWLock exception => System.Threading.SynchronizationLockException: The read lock is being released without being held.
Fortunately it looks like we didn't have any scenario like this in ASF, as this was possible only when we async/await while enumerating over ConcurrentHashSet, so that specific bug didn't affect ASF codebase (yet). Still, I must fix this as current implementation is not thread-safe, so our HashSet is in fact not concurrent in the first place.
I analyzed possible solutions and there are basically 3: either using ConcurrentDictionary and wrapping around it, replacing lock with SemaphoreSlim, or using third-party AsyncReaderWriterLock from StephenCleary. SemaphoreSlim entirely kills the concept of multiple readers one writer, and could affect performance negatively, moreover - it doesn't support upgreadable lock scenario we have with ReplaceIfNeededWith(). Concurrent dictionary would be nice if I didn't have that awful memory hit from storing mandatory pointless value, plus I don't really like concept of wrapping around conc dictionary if I can simply use it right away and drop my conc hashset entirely. AsyncReaderWriterLock seem to be really well written, and works on Mono + should be compatible with .NET core in the future, so we should go for it as it's the best bet both performance-wise and memory-wise.
This brings another package dependency and changes a bit backend of ConcurrentHashSet
2017-02-07 20:14:51 +01:00
JustArchi
dba6fdfeeb TradingPreferences.DontAcceptBotTrades 2017-02-05 07:51:04 +01:00
JustArchi
e4f4859eb4 Closes #445
ASF doesn't really make use of Balanced profile (as opposed to ArchiBoT), remove it leaving only MaxPerformance/MinMemoryUsage
2017-01-30 22:42:05 +01:00
JustArchi
de897aaa92 Rewrite #414 in a way that makes me happy 2017-01-11 15:22:00 +01:00
JustArchi
28e2cfbc7c Localizing... 2017-01-06 15:32:12 +01:00
JustArchi
ba8d70aebb Copyright update 2017-01-02 20:05:21 +01:00
JustArchi
d36eaebbfe Closes #383 2016-12-25 05:52:17 +01:00
JustArchi
1a917a668c Misc 2016-12-04 20:41:01 +01:00
JustArchi
2165818e25 First set of fixes 2016-12-04 05:50:11 +01:00
JustArchi
19f66cdada Accept trades also from SteamOwnerID 2016-12-01 14:45:31 +01:00
JustArchi
b7f15daa91 Misc 2016-11-24 07:49:44 +01:00
JustArchi
df218074ad Gigantic code cleanup
Time to enforce some common file layout, as general mess started to annoying me. Sorry in advance for people using custom forks and having merge conflicts, this will help everybody in long-run
2016-11-24 07:32:16 +01:00
JustArchi
1a49c80bc4 Misc 2016-11-20 00:03:27 +01:00
JustArchi
8b3b822938 Rewrite entire ASF logging, as preparation for #354 2016-11-06 12:06:02 +01:00
JustArchi
b2e3d435dd Misc trading logic enhancements, #351 2016-10-27 22:01:38 +02:00
JustArchi
cb0b8ecb34 Misc 2016-10-27 02:19:10 +02:00
JustArchi
1fe628bd5d Code review 2016-10-21 21:39:58 +02:00
JustArchi
4ed1ceeff4 Add MatchEveryting trading preference 2016-10-21 21:33:55 +02:00
JustArchi
53b07fb1bb Optimize ParseActiveTrades()
Never bother with checking trades if user didn't enable any trading preferences
2016-10-21 21:03:01 +02:00
JustArchi
af45ac1e2d Implement TradingPreferences, closes #351
It also kills deprecated now SteamTradeMatcher bool property
2016-10-21 20:32:22 +02:00
JustArchi
0acef23ffd Don't do extra work when user is not using ASF 2FA 2016-09-27 13:20:22 +02:00
JustArchi
0cea70ef6a Rename card checks methods to match ArchiBoT 2016-09-12 03:49:17 +02:00
JustArchi
edb047980e Extend logic for trades 2016-08-15 21:47:31 +02:00
JustArchi
95637ea3a7 Improve trading failure handling
It seems that even if Steam responds with e.g. internal server error (500), the trade gets accepted 20-30 seconds later, which doesn't make ANY sense, but does anything in Steam do?
Let's improve the logic a bit by returning result even if we in fact failed in Accept/Decline function, this will allow us to deal with confirmations even if failed trade in fact succeeded.
2016-08-14 00:19:01 +02:00
JustArchi
413d44b42b Those should be errors 2016-07-27 04:53:23 +02:00
JustArchi
c52934ed9a Bring in small ArchiBoT trading enhancements
This mostly fixed forwarded tradeIDs to contain only trades that we indeed accepted and need to confirm, instead of all trades we're dealing with
2016-07-27 04:48:28 +02:00
JustArchi
afbfb62bed Always expect english responses, closes #301
Also some misc fixes while I'm at it
2016-07-19 20:14:21 +02:00
JustArchi
561fb66e7a Correct harmless VS code analysis warnings 2016-07-08 07:41:36 +02:00
JustArchi
09b2b29ff4 Avoid excessive TrimExcess()
It's really good for keeping memory low, but due to limited lifespan of those objects and the fact that we should focus on performance and not memory, it's better to avoid extra overhead and let GC do it's job, by dropping references to those objects ASAP

TrimExcess() is still being used for global objects, as those have longer (possibly infinite) lifespan and can benefit from that.
2016-07-08 06:45:17 +02:00
JustArchi
cbf212aff5 Don't launch all parallel tasks immediately
It seems that the runtime is actually smarter than I thought, and can optimize tasks creation for maximum performance better than we'd do
2016-07-02 22:05:29 +02:00
JustArchi
4380679df6 JSON code review 2016-06-29 20:18:47 +02:00