diff --git a/Libraries/Core/Utils/HashUtil.cs b/Libraries/Core/Utils/HashUtil.cs index 2ecc7e1a..8854067f 100644 --- a/Libraries/Core/Utils/HashUtil.cs +++ b/Libraries/Core/Utils/HashUtil.cs @@ -10,7 +10,7 @@ namespace Core.Utils; public partial class HashUtil(RandomUtil _randomUtil) { /// - /// Create a 24 character MongoId + /// Create a 24 character MongoId /// /// 24 character objectId public string Generate() diff --git a/Libraries/Core/Utils/JsonUtil.cs b/Libraries/Core/Utils/JsonUtil.cs index e1e3a025..ac16c71d 100644 --- a/Libraries/Core/Utils/JsonUtil.cs +++ b/Libraries/Core/Utils/JsonUtil.cs @@ -87,7 +87,7 @@ public class JsonUtil /// Convert JSON into an object from a file /// /// The JSON File to read - /// + /// T public T? DeserializeFromFile(string file) { if (!File.Exists(file)) @@ -106,7 +106,7 @@ public class JsonUtil /// /// The JSON File to read /// The type of the object to deserialize to - /// + /// object public object? DeserializeFromFile(string file, Type type) { if (!File.Exists(file)) diff --git a/Libraries/Core/Utils/RagfairOfferHolder.cs b/Libraries/Core/Utils/RagfairOfferHolder.cs index bb0c210f..6f90c113 100644 --- a/Libraries/Core/Utils/RagfairOfferHolder.cs +++ b/Libraries/Core/Utils/RagfairOfferHolder.cs @@ -29,6 +29,11 @@ public class RagfairOfferHolder( protected HashSet _expiredOfferIds = []; protected object _expiredOfferIdsLock = new(); + /// + /// Get a ragfair offer by its id + /// + /// Ragfair offer id + /// RagfairOffer public RagfairOffer? GetOfferById(string id) { lock (_offersByIdLock) @@ -37,6 +42,11 @@ public class RagfairOfferHolder( } } + /// + /// Get ragfair offers that match the passed in tpl + /// + /// Tpl to get offers for + /// RagfairOffer list public List? GetOffersByTemplate(string templateId) { lock (_offersByTemplateLock) @@ -56,6 +66,11 @@ public class RagfairOfferHolder( } } + /// + /// Get all offers being sold by a trader + /// + /// Id of trader to get offers for + /// RagfairOffer list public List? GetOffersByTrader(string traderId) { lock (_offersByTraderLock) @@ -71,6 +86,10 @@ public class RagfairOfferHolder( } } + /// + /// Get all ragfair offers + /// + /// RagfairOffer list public List GetOffers() { lock (_offersByIdLock) @@ -84,6 +103,10 @@ public class RagfairOfferHolder( return []; } + /// + /// Add a collection of offers to ragfair + /// + /// Offers to add public void AddOffers(List offers) { foreach (var offer in offers) @@ -92,6 +115,10 @@ public class RagfairOfferHolder( } } + /// + /// Add single offer to ragfair + /// + /// Offer to add public void AddOffer(RagfairOffer offer) { lock (_offersByIdLock) @@ -128,10 +155,11 @@ public class RagfairOfferHolder( } } - /** - * Purge offer from offer cache - * @param offer Offer to remove - */ + /// + /// Remove an offer from ragfair by id + /// + /// Offer id to remove + /// OPTIONAL - Should trader offers be checked for offer id public void RemoveOffer(string offerId, bool checkTraderOffers = true) { lock (_offersByIdLock) @@ -174,6 +202,10 @@ public class RagfairOfferHolder( } } + /// + /// Remove all offers a trader has + /// + /// Trader id to remove offers from public void RemoveAllOffersByTrader(string traderId) { lock (_offersByTraderLock) @@ -191,6 +223,11 @@ public class RagfairOfferHolder( } } + /// + /// Add offer to offersByTemplate cache + /// + /// Tpl to store offer against + /// Offer to store against tpl protected void AddOfferByTemplates(string template, RagfairOffer offer) { lock (_offersByTemplateLock) @@ -206,6 +243,11 @@ public class RagfairOfferHolder( } } + /// + /// Cache an offer inside `offersByTrader` by trader id + /// + /// Trader id to store offer against + /// Offer to store against protected void AddOfferByTrader(string trader, RagfairOffer offer) { lock (_offersByTraderLock) @@ -221,6 +263,12 @@ public class RagfairOfferHolder( } } + /// + /// Is the passed in offer stale - end time > passed in time + /// + /// Offer to check + /// Time to check offer against + /// True - offer is stale protected bool IsStale(RagfairOffer? offer, long time) { if (offer is null) @@ -301,7 +349,7 @@ public class RagfairOfferHolder( /// /// Flag offers with an expiry before the passed in timestamp /// - /// + /// Timestamp at point offer is 'expired' public void FlagExpiredOffersAfterDate(long timestamp) { lock (_expiredOfferIdsLock) @@ -322,6 +370,9 @@ public class RagfairOfferHolder( } } + /// + /// Remove all offers flagged as stale/expired + /// public void RemoveExpiredOffers() { lock (_expiredOfferIdsLock)