public void IndexChain(ChainBase chain, CancellationToken cancellationToken = default(CancellationToken)) { this.logger.LogTrace("()"); if (chain == null) { throw new ArgumentNullException("chain"); } this.SetThrottling(); using (IndexerTrace.NewCorrelation("Index main chain to azure started")) { this.Configuration.GetChainTable().CreateIfNotExistsAsync().GetAwaiter().GetResult(); IndexerTrace.InputChainTip(chain.Tip); var client = this.Configuration.CreateIndexerClient(); var changes = client.GetChainChangesUntilFork(chain.Tip, true, cancellationToken).ToList(); var height = 0; if (changes.Count != 0) { this.logger.LogTrace("Changes count: {0}", changes.Count); IndexerTrace.IndexedChainTip(changes[0].BlockId, changes[0].Height); if (changes[0].Height > chain.Tip.Height) { IndexerTrace.InputChainIsLate(); this.logger.LogTrace("(-):LATE"); return; } height = changes[changes.Count - 1].Height + 1; if (height > chain.Height) { IndexerTrace.IndexedChainIsUpToDate(chain.Tip); this.logger.LogTrace("(-):UP_TO_DATE"); return; } } else { this.logger.LogTrace("No work found"); IndexerTrace.NoForkFoundWithStored(); } IndexerTrace.IndexingChain(chain.GetBlock(height), chain.Tip); this.Index(chain, height, cancellationToken); } this.logger.LogTrace("(-)"); }
public int IndexWalletBalances(ChainBase chain) { using (IndexerTrace.NewCorrelation("Import wallet balances to azure started")) { using (var node = this.Configuration.ConnectToNode(false)) { node.VersionHandshake(); var task = new IndexBalanceTask(this.Configuration, this.Configuration.CreateIndexerClient().GetAllWalletRules()); task.SaveProgression = !this.IgnoreCheckpoints; task.Index(this.GetBlockFetcher(this.GetCheckpointInternal(IndexerCheckpoints.Wallets), node, chain), this.TaskScheduler); return(task.IndexedEntities); } } }
public long IndexBlocks(ChainBase chain = null) { using (IndexerTrace.NewCorrelation("Import blocks to azure started")) { using (var node = this.Configuration.ConnectToNode(false)) { node.VersionHandshake(); var task = new IndexBlocksTask(this.Configuration); task.SaveProgression = !this.IgnoreCheckpoints; task.Index(this.GetBlockFetcher(this.GetCheckpointInternal(IndexerCheckpoints.Blocks), node, chain), this.TaskScheduler); return(task.IndexedBlocks); } } }