diff --git a/nekoyume/Assets/_Scripts/Blockchain/ActionHandler.cs b/nekoyume/Assets/_Scripts/Blockchain/ActionHandler.cs index 38c4be439d..ef4b41f402 100644 --- a/nekoyume/Assets/_Scripts/Blockchain/ActionHandler.cs +++ b/nekoyume/Assets/_Scripts/Blockchain/ActionHandler.cs @@ -116,7 +116,7 @@ protected GoldBalanceState GetGoldBalanceState(ActionEvaluation evaluation } var sheetStates = await agent.GetStateBulkAsync( - ReservedAddresses.LegacyAccount, sheetAddrArr); + agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, sheetAddrArr); var stakeRegularFixedRewardSheet = new StakeRegularFixedRewardSheet(); stakeRegularFixedRewardSheet.Set( sheetStates[sheetAddrArr[0]].ToDotnetString()); diff --git a/nekoyume/Assets/_Scripts/Blockchain/Agent.cs b/nekoyume/Assets/_Scripts/Blockchain/Agent.cs index 7bf44f3e9d..32787cb031 100644 --- a/nekoyume/Assets/_Scripts/Blockchain/Agent.cs +++ b/nekoyume/Assets/_Scripts/Blockchain/Agent.cs @@ -355,18 +355,6 @@ public async Task> GetAvatarStatesAsync( return dict; } - public async Task> GetStateBulkAsync(Address accountAddress, IEnumerable
addressList) - { - var dict = new Dictionary(); - foreach (var address in addressList) - { - var result = await await Task.FromResult(GetStateAsync(accountAddress, address)); - dict[address] = result; - } - - return dict; - } - public async Task> GetStateBulkAsync( HashDigest stateRootHash, Address accountAddress, diff --git a/nekoyume/Assets/_Scripts/Blockchain/IAgent.cs b/nekoyume/Assets/_Scripts/Blockchain/IAgent.cs index c862c816f0..e5a560f6a7 100644 --- a/nekoyume/Assets/_Scripts/Blockchain/IAgent.cs +++ b/nekoyume/Assets/_Scripts/Blockchain/IAgent.cs @@ -108,10 +108,6 @@ Task> GetAvatarStatesAsync( HashDigest stateRootHash, IEnumerable
addressList); - Task> GetStateBulkAsync( - Address accountAddress, - IEnumerable
addressList); - Task> GetStateBulkAsync( HashDigest stateRootHash, Address accountAddress, diff --git a/nekoyume/Assets/_Scripts/Blockchain/RPCAgent.cs b/nekoyume/Assets/_Scripts/Blockchain/RPCAgent.cs index 513dcae8a7..8cdd8549c3 100644 --- a/nekoyume/Assets/_Scripts/Blockchain/RPCAgent.cs +++ b/nekoyume/Assets/_Scripts/Blockchain/RPCAgent.cs @@ -607,22 +607,6 @@ private AvatarState ResolveAvatarState(byte[] raw) return avatarState; } - public async Task> GetStateBulkAsync(Address accountAddress, IEnumerable
addressList) - { - var raw = - await _service.GetBulkStateByBlockHash( - BlockTipHash.ToByteArray(), - accountAddress.ToByteArray(), - addressList.Select(a => a.ToByteArray())); - var result = new Dictionary(); - foreach (var kv in raw) - { - result[new Address(kv.Key)] = _codec.Decode(kv.Value); - } - - return result; - } - public async Task> GetStateBulkAsync( HashDigest stateRootHash, Address accountAddress, diff --git a/nekoyume/Assets/_Scripts/Extensions/GetStateExtensions.cs b/nekoyume/Assets/_Scripts/Extensions/GetStateExtensions.cs index e50e81e954..223f199d86 100644 --- a/nekoyume/Assets/_Scripts/Extensions/GetStateExtensions.cs +++ b/nekoyume/Assets/_Scripts/Extensions/GetStateExtensions.cs @@ -29,6 +29,7 @@ public static class GetStateExtensions ItemSlotState.DeriveAddress(avatarAddress, BattleType.Raid) }; var itemBulk = await agent.GetStateBulkAsync( + agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, itemAddresses); var itemSlotStates = new List(); @@ -47,6 +48,7 @@ public static class GetStateExtensions RuneSlotState.DeriveAddress(avatarAddress, BattleType.Raid) }; var runeBulk = await Game.Game.instance.Agent.GetStateBulkAsync( + Game.Game.instance.Agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, runeAddresses); var runeSlotStates = new List(); @@ -78,7 +80,7 @@ public static async Task GetAllCombinationSlotStateAsyn { combinationSlotAddresses.Add(CombinationSlotState.DeriveAddress(avatarAddress, i)); } - var bulkStates = await agent.GetStateBulkAsync(ReservedAddresses.LegacyAccount, combinationSlotAddresses); + var bulkStates = await agent.GetStateBulkAsync(agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, combinationSlotAddresses); allCombinationSlotState = new AllCombinationSlotState(); for (var i = 0; i < AvatarState.DefaultCombinationSlotCount; i++) @@ -142,7 +144,7 @@ public static async Task GetAllRuneStateAsync( var runeAddresses = runeListSheet.Values.Select(row => RuneState.DeriveAddress(avatarAddress, row.Id)); var stateBulk = await Game.Game.instance.Agent.GetStateBulkAsync( - ReservedAddresses.LegacyAccount, runeAddresses); + Game.Game.instance.Agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, runeAddresses); foreach (var runeSerialized in stateBulk.Values.OfType()) { allRuneState.AddRuneState(new RuneState(runeSerialized)); diff --git a/nekoyume/Assets/_Scripts/State/States.cs b/nekoyume/Assets/_Scripts/State/States.cs index 94326c247e..975d4132e2 100644 --- a/nekoyume/Assets/_Scripts/State/States.cs +++ b/nekoyume/Assets/_Scripts/State/States.cs @@ -71,7 +71,7 @@ public class States public FungibleAssetValue CrystalBalance { get; private set; } public AllRuneState AllRuneState { get; private set; } - + public AllCombinationSlotState AllCombinationSlotState { get; private set; } public readonly ConcurrentDictionary> @@ -86,12 +86,12 @@ public readonly ConcurrentDictionary> private class Workshop { private readonly ConcurrentDictionary _states = new(); - + public void UpdateCombinationSlotState(int index, CombinationSlotState state) { _states[index] = state; } - + /// /// If you want to update the state, use . /// @@ -216,7 +216,7 @@ public void SetAllRuneState(AllRuneState allRuneState) { AllRuneState = allRuneState; } - + private void SetAllCombinationSlotState(Address avatarAddress, AllCombinationSlotState allCombinationSlotState) { LocalLayer.Instance.InitializeCombinationSlots(allCombinationSlotState); @@ -251,7 +251,7 @@ public async UniTask InitRuneSlotStates() RuneSlotState.DeriveAddress(avatarState.address, BattleType.Arena), RuneSlotState.DeriveAddress(avatarState.address, BattleType.Raid) }; - var stateBulk = await Game.Game.instance.Agent.GetStateBulkAsync(ReservedAddresses.LegacyAccount, addresses); + var stateBulk = await Game.Game.instance.Agent.GetStateBulkAsync(Game.Game.instance.Agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, addresses); foreach (var value in stateBulk.Values) { if (value is List list) @@ -321,7 +321,7 @@ public async UniTask InitItemSlotStates() ItemSlotState.DeriveAddress(avatarState.address, BattleType.Arena), ItemSlotState.DeriveAddress(avatarState.address, BattleType.Raid) }; - var stateBulk = await agent.GetStateBulkAsync(ReservedAddresses.LegacyAccount, addresses); + var stateBulk = await agent.GetStateBulkAsync(agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, addresses); foreach (var value in stateBulk.Values) { if (value is List list) @@ -359,7 +359,7 @@ private async UniTask InitItemSlotState(int slotIndex, AvatarState avatarState) ItemSlotState.DeriveAddress(avatarState.address, BattleType.Raid) }; - var stateBulk = await Game.Game.instance.Agent.GetStateBulkAsync(ReservedAddresses.LegacyAccount, addresses); + var stateBulk = await Game.Game.instance.Agent.GetStateBulkAsync(Game.Game.instance.Agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, addresses); foreach (var value in stateBulk.Values) { if (value is List list) @@ -726,7 +726,7 @@ public IDictionary GetCombinationSlotState(AvatarStat { return !_slotStates.ContainsKey(avatarState.address) ? null : _slotStates[avatarState.address].States; } - + public void SetGameConfigState(GameConfigState state) { GameConfigState = state; @@ -782,6 +782,7 @@ public void UpdateHammerPointStates(IEnumerable recipeIds) .ToList(); var states = await Game.Game.instance.Agent.GetStateBulkAsync( + Game.Game.instance.Agent.BlockTipStateRootHash, ReservedAddresses.LegacyAccount, hammerPointStateAddresses.Select(tuple => tuple.Item1)); var joinedStates = states.Join(