Skip to content

Commit

Permalink
Merge pull request planetarium#533 from area363/release/70-to-main
Browse files Browse the repository at this point in the history
  • Loading branch information
riemannulus authored Nov 7, 2023
2 parents 7a92c10 + 9eb7065 commit 5ea7591
Show file tree
Hide file tree
Showing 78 changed files with 13,934 additions and 630 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace NineChronicles.DataProvider.Executable.Commands
using Cocona;
using Libplanet;
using Libplanet.Action;
using Libplanet.Action.State;
using Libplanet.Blockchain;
using Libplanet.Blockchain.Policies;
using Libplanet.Crypto;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void Migration(
var blockChainStates = new BlockChainStates(_baseStore, baseStateStore);
var actionEvaluator = new ActionEvaluator(
_ => blockPolicy.BlockAction,
blockChainStates,
baseStateStore,
new NCActionLoader());
_baseChain = new BlockChain(blockPolicy, stagePolicy, _baseStore, baseStateStore, genesis, blockChainStates, actionEvaluator);

Expand Down Expand Up @@ -161,6 +162,8 @@ public void Migration(
var tip = _baseStore.GetBlock((BlockHash)tipHash!);
var blockEvaluation = _baseChain.EvaluateBlock(tip);
var evaluation = blockEvaluation.Last();
var outputState = new Account(_baseChain.GetAccountState(evaluation.OutputState));

var avatarCount = 0;
AvatarState avatarState;
bool checkBattleArenaRankingTable = false;
Expand All @@ -174,17 +177,17 @@ public void Migration(
var avatarAddress = new Address(avatar);
try
{
avatarState = evaluation.OutputState.GetAvatarStateV2(avatarAddress);
avatarState = outputState.GetAvatarStateV2(avatarAddress);
}
catch (Exception)
{
avatarState = evaluation.OutputState.GetAvatarState(avatarAddress);
avatarState = outputState.GetAvatarState(avatarAddress);
}

if (avatarState != null)
{
var avatarLevel = avatarState.level;
var arenaSheet = evaluation.OutputState.GetSheet<ArenaSheet>();
var arenaSheet = outputState.GetSheet<ArenaSheet>();
var arenaData = arenaSheet.GetRoundByBlockIndex(tip.Index);

if (!checkBattleArenaRankingTable)
Expand Down Expand Up @@ -229,8 +232,8 @@ public void Migration(
ArenaScore.DeriveAddress(avatarAddress, arenaData.ChampionshipId, arenaData.Round);
var arenaInformationAdr =
ArenaInformation.DeriveAddress(avatarAddress, arenaData.ChampionshipId, arenaData.Round);
evaluation.OutputState.TryGetArenaInformation(arenaInformationAdr, out var currentArenaInformation);
evaluation.OutputState.TryGetArenaScore(arenaScoreAdr, out var outputArenaScore);
outputState.TryGetArenaInformation(arenaInformationAdr, out var currentArenaInformation);
outputState.TryGetArenaScore(arenaScoreAdr, out var outputArenaScore);
if (currentArenaInformation != null && outputArenaScore != null)
{
_barBulkFile.WriteLine(
Expand Down
996 changes: 545 additions & 451 deletions NineChronicles.DataProvider.Executable/Commands/MySqlMigration.cs

Large diffs are not rendered by default.

Loading

0 comments on commit 5ea7591

Please sign in to comment.