From b0604e93e26e39dd649d15e790aad7418df99546 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Thu, 9 Nov 2023 18:11:07 +0900 Subject: [PATCH] Use raw marketState for action execution time --- Lib9c/Action/CancelProductRegistration.cs | 8 ++++---- Lib9c/Action/CancelProductRegistration0.cs | 8 ++++---- Lib9c/Action/ReRegisterProduct.cs | 8 ++++---- Lib9c/Action/ReRegisterProduct0.cs | 8 ++++---- Lib9c/Action/RegisterProduct.cs | 8 ++++---- Lib9c/Action/RegisterProduct0.cs | 8 ++++---- Lib9c/Action/RegisterProduct2.cs | 8 ++++---- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lib9c/Action/CancelProductRegistration.cs b/Lib9c/Action/CancelProductRegistration.cs index 5ccd1c61e4..f16ce8d2bd 100644 --- a/Lib9c/Action/CancelProductRegistration.cs +++ b/Lib9c/Action/CancelProductRegistration.cs @@ -71,11 +71,11 @@ public override IAccount Execute(IActionContext context) { // cancel order before product registered case. var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); + ? rawMarketList + : List.Empty; productsState = new ProductsState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); foreach (var productInfo in ProductInfos) diff --git a/Lib9c/Action/CancelProductRegistration0.cs b/Lib9c/Action/CancelProductRegistration0.cs index 65601d2b39..62dc761cbb 100644 --- a/Lib9c/Action/CancelProductRegistration0.cs +++ b/Lib9c/Action/CancelProductRegistration0.cs @@ -79,11 +79,11 @@ public override IAccount Execute(IActionContext context) { // cancel order before product registered case. var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); + ? rawMarketList + : List.Empty; productsState = new ProductsState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress); foreach (var productInfo in ProductInfos) diff --git a/Lib9c/Action/ReRegisterProduct.cs b/Lib9c/Action/ReRegisterProduct.cs index 43fc158124..83413d4d99 100644 --- a/Lib9c/Action/ReRegisterProduct.cs +++ b/Lib9c/Action/ReRegisterProduct.cs @@ -73,11 +73,11 @@ public override IAccount Execute(IActionContext context) else { var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); + ? rawMarketList + : List.Empty; productsState = new ProductsState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } var random = context.GetRandom(); diff --git a/Lib9c/Action/ReRegisterProduct0.cs b/Lib9c/Action/ReRegisterProduct0.cs index 60aa45e6f5..310a0f43c7 100644 --- a/Lib9c/Action/ReRegisterProduct0.cs +++ b/Lib9c/Action/ReRegisterProduct0.cs @@ -73,11 +73,11 @@ public override IAccount Execute(IActionContext context) else { var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); + ? rawMarketList + : List.Empty; productsState = new ProductsState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } var random = context.GetRandom(); diff --git a/Lib9c/Action/RegisterProduct.cs b/Lib9c/Action/RegisterProduct.cs index c93b5abcc5..6dd795c756 100644 --- a/Lib9c/Action/RegisterProduct.cs +++ b/Lib9c/Action/RegisterProduct.cs @@ -84,10 +84,10 @@ public override IAccount Execute(IActionContext context) { productsState = new ProductsState(); var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + ? rawMarketList + : List.Empty; + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } sw.Stop(); Log.Debug("{Source} {Process} from #{BlockIndex}: {Elapsed}", diff --git a/Lib9c/Action/RegisterProduct0.cs b/Lib9c/Action/RegisterProduct0.cs index b3ffeeab31..5734a367db 100644 --- a/Lib9c/Action/RegisterProduct0.cs +++ b/Lib9c/Action/RegisterProduct0.cs @@ -80,10 +80,10 @@ public override IAccount Execute(IActionContext context) { productsState = new ProductsState(); var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + ? rawMarketList + : List.Empty; + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } var random = context.GetRandom(); diff --git a/Lib9c/Action/RegisterProduct2.cs b/Lib9c/Action/RegisterProduct2.cs index ebe4cc3d19..4e54a44bc2 100644 --- a/Lib9c/Action/RegisterProduct2.cs +++ b/Lib9c/Action/RegisterProduct2.cs @@ -81,10 +81,10 @@ public override IAccount Execute(IActionContext context) { productsState = new ProductsState(); var marketState = states.TryGetState(Addresses.Market, out List rawMarketList) - ? new MarketState(rawMarketList) - : new MarketState(); - marketState.AvatarAddresses.Add(AvatarAddress); - states = states.SetState(Addresses.Market, marketState.Serialize()); + ? rawMarketList + : List.Empty; + marketState = marketState.Add(AvatarAddress.Serialize()); + states = states.SetState(Addresses.Market, marketState); } foreach (var info in RegisterInfos.OrderBy(r => r.Type).ThenBy(r => r.Price)) {