public Task Execute(CancellationToken cancellationToken) { ILogger logger = _api.LogManager.GetClassLogger(); IInitConfig initConfig = _api.Config <IInitConfig>(); switch (initConfig.DiagnosticMode) { case DiagnosticMode.VerifySupply: { logger.Info("Genesis supply:"); SupplyVerifier supplyVerifier = new SupplyVerifier(logger); StateDb stateDb = new StateDb(_api.DbProvider !.StateDb.Innermost); StateDb codeDb = new StateDb(_api.DbProvider.StateDb.Innermost); StateReader stateReader = new StateReader(stateDb, codeDb, _api.LogManager); stateReader.RunTreeVisitor(supplyVerifier, _api.BlockTree !.Genesis.StateRoot); Block head = _api.BlockTree !.Head; logger.Info($"Head ({head.Number}) block supply:"); supplyVerifier = new SupplyVerifier(logger); stateReader.RunTreeVisitor(supplyVerifier, head.StateRoot); break; } case DiagnosticMode.VerifyRewards: _api.BlockTree !.Accept(new RewardsVerifier(_api.LogManager), cancellationToken); break; } return(Task.CompletedTask); }
private static IPruningContext CopyDb(IPruningContext pruningContext, MemDb trieDb, MemDb clonedDb) { LimboLogs logManager = LimboLogs.Instance; PatriciaTree trie = Build.A.Trie(trieDb).WithAccountsByIndex(0, 100).TestObject; IStateReader stateReader = new StateReader(new TrieStore(trieDb, logManager), new MemDb(), logManager); using CopyTreeVisitor copyTreeVisitor = new(pruningContext, logManager); stateReader.RunTreeVisitor(copyTreeVisitor, trie.RootHash); return(pruningContext); }