Skip to content

Commit

Permalink
Merge pull request #515 from greymistcube/bump/9c-headless
Browse files Browse the repository at this point in the history
⬆️ Bump 9c-headless
  • Loading branch information
riemannulus authored Oct 17, 2023
2 parents f3f7e52 + 4e01f3b commit 32206cf
Show file tree
Hide file tree
Showing 7 changed files with 597 additions and 508 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
774 changes: 397 additions & 377 deletions NineChronicles.DataProvider.Executable/Commands/MySqlMigration.cs

Large diffs are not rendered by default.

Loading

0 comments on commit 32206cf

Please sign in to comment.