From e0e5144ed4429aa2bebc96082255e5fb19c75bc4 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 9 Jul 2024 19:34:00 +0800 Subject: [PATCH] modify batch cancel size --- contract/Forest/ForestContractConstants.cs | 4 ++-- contract/Forest/ForestContract_Buyers.cs | 23 ++++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/contract/Forest/ForestContractConstants.cs b/contract/Forest/ForestContractConstants.cs index 0656dd2..561026f 100644 --- a/contract/Forest/ForestContractConstants.cs +++ b/contract/Forest/ForestContractConstants.cs @@ -22,7 +22,7 @@ public partial class ForestContract public const string DefaultAIImageSize1024 = "1024x1024"; public const string DefaultAIImageSize512 = "512x512"; public const string DefaultAIImageSize256 = "256x256"; - public const int DefaultMaxBatchCancelOfferCount= 30; - public const int DefaultMaxBatchCancelListCount= 30; + public const int DefaultMaxBatchCancelOfferCount= 20; + public const int DefaultMaxBatchCancelListCount= 20; } \ No newline at end of file diff --git a/contract/Forest/ForestContract_Buyers.cs b/contract/Forest/ForestContract_Buyers.cs index 1083a51..dd167c3 100644 --- a/contract/Forest/ForestContract_Buyers.cs +++ b/contract/Forest/ForestContract_Buyers.cs @@ -554,15 +554,26 @@ private Empty CancelOfferList(CancelOfferListByExpireTimeInput input) Assert(offerList?.Value?.Count > 0, "Offer not exists"); - var cancelOfferList = offerList?.Value.Where(existOffer => input.CancelOfferList.Any(cannelOffer => - AreOffersEqual(existOffer, cannelOffer) - )).ToList(); + var cancelOfferList = new List(); + var remainOfferList = new List(); + foreach (var existOffer in offerList?.Value) + { + foreach (var cannelOffer in input.CancelOfferList) + { + if (AreOffersEqual(existOffer, cannelOffer)) + { + cancelOfferList.Add(existOffer); + } + if (!AreOffersEqual(existOffer, cannelOffer)) + { + remainOfferList.Add(existOffer); + } + } + } Assert(cancelOfferList?.Count > 0, "Cannel Offer not exists"); var newOfferList = new OfferList(); - var remainOfferList = offerList?.Value.Where(existOffer => !input.CancelOfferList.Any(cannelOffer => - AreOffersEqual(existOffer, cannelOffer) - )).ToList(); + newOfferList.Value.Add(remainOfferList); var cancelOfferMap = new Dictionary();