Skip to content

Commit

Permalink
modify batch cancel size
Browse files Browse the repository at this point in the history
  • Loading branch information
fyannch committed Jul 9, 2024
1 parent b1ee6a4 commit e0e5144
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions contract/Forest/ForestContractConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
23 changes: 17 additions & 6 deletions contract/Forest/ForestContract_Buyers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Offer>();
var remainOfferList = new List<Offer>();
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<string, long>();
Expand Down

0 comments on commit e0e5144

Please sign in to comment.