Skip to content

Commit

Permalink
Removed preload status tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Sep 5, 2024
1 parent de69cc8 commit 39b331a
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions NineChronicles.Headless/GraphTypes/StandaloneSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
using Libplanet.Types.Blocks;
using Libplanet.Explorer.GraphTypes;
using Libplanet.Headless;
using Libplanet.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
Expand All @@ -19,7 +17,6 @@
using Libplanet.Crypto;
using Libplanet.Types.Assets;
using Nekoyume;
using Nekoyume.Action;
using Nekoyume.Model.State;
using Nekoyume.TableData;
using Libplanet.Blockchain;
Expand Down Expand Up @@ -62,65 +59,6 @@ public TxType()
}
}

class PreloadStateType : ObjectGraphType<BlockSyncState>
{
private sealed class PreloadStateExtra
{
public string Type { get; }
public long CurrentCount { get; }
public long TotalCount { get; }

public PreloadStateExtra(string type, long currentCount, long totalCount)
{
Type = type;
CurrentCount = currentCount;
TotalCount = totalCount;
}
}

private sealed class PreloadStateExtraType : ObjectGraphType<PreloadStateExtra>
{
public PreloadStateExtraType()
{
Field<NonNullGraphType<StringGraphType>>(nameof(PreloadStateExtra.Type));
Field<NonNullGraphType<LongGraphType>>(nameof(PreloadStateExtra.CurrentCount));
Field<NonNullGraphType<LongGraphType>>(nameof(PreloadStateExtra.TotalCount));
}
}

public PreloadStateType()
{
Field<NonNullGraphType<LongGraphType>>(name: "currentPhase", resolve: context => context.Source.CurrentPhase);
Field<NonNullGraphType<LongGraphType>>(name: "totalPhase", resolve: context => BlockSyncState.TotalPhase);
Field<NonNullGraphType<PreloadStateExtraType>>(name: "extra", resolve: context =>
{
var preloadState = context.Source;
return preloadState switch
{
ActionExecutionState actionExecutionState => new PreloadStateExtra(nameof(ActionExecutionState),
actionExecutionState.ExecutedBlockCount,
actionExecutionState.TotalBlockCount),
BlockDownloadState blockDownloadState => new PreloadStateExtra(nameof(BlockDownloadState),
blockDownloadState.ReceivedBlockCount,
blockDownloadState.TotalBlockCount),
BlockHashDownloadState blockHashDownloadState => new PreloadStateExtra(
nameof(BlockHashDownloadState),
blockHashDownloadState.ReceivedBlockHashCount,
blockHashDownloadState.EstimatedTotalBlockHashCount),
BlockVerificationState blockVerificationState => new PreloadStateExtra(
nameof(BlockVerificationState),
blockVerificationState.VerifiedBlockCount,
blockVerificationState.TotalBlockCount),
StateDownloadState stateDownloadState => new PreloadStateExtra(
nameof(StateDownloadState),
stateDownloadState.ReceivedIterationCount,
stateDownloadState.TotalIterationCount),
_ => throw new ExecutionError($"Not supported preload state. {preloadState.GetType()}"),
};
});
}
}

private const int _blockRenderDegreeOfParallelism = 8;

private BlockHeader? _tipHeader;
Expand Down Expand Up @@ -164,13 +102,6 @@ public StandaloneSubscription(StandaloneContext standaloneContext, IConfiguratio
Subscriber = new EventStreamResolver<Tx>(SubscribeTx),
});
AddField(new EventStreamFieldType
{
Name = "preloadProgress",
Type = typeof(PreloadStateType),
Resolver = new FuncFieldResolver<BlockSyncState>(context => (context.Source as BlockSyncState)!),
Subscriber = new EventStreamResolver<BlockSyncState>(context => StandaloneContext.PreloadStateSubject.AsObservable()),
});
AddField(new EventStreamFieldType
{
Name = "nodeStatus",
Type = typeof(NodeStatusType),
Expand Down

0 comments on commit 39b331a

Please sign in to comment.