public void IndexChain(ChainBase chain) { if (chain == null) { throw new ArgumentNullException("chain"); } SetThrottling(); using (IndexerTrace.NewCorrelation("Index Main chain").Open()) { Configuration.GetChainTable().CreateIfNotExists(); IndexerTrace.LocalMainChainTip(chain.Tip); var client = Configuration.CreateIndexerClient(); var changes = client.GetChainChangesUntilFork(chain.Tip, true).ToList(); var height = 0; if (changes.Count != 0) { IndexerTrace.StoredMainChainTip(changes[0].BlockId, changes[0].Height); if (changes[0].Height > chain.Tip.Height) { IndexerTrace.LocalMainChainIsLate(); return; } height = changes[changes.Count - 1].Height + 1; if (height > chain.Height) { IndexerTrace.StoredMainChainIsUpToDate(chain.Tip); return; } } else { IndexerTrace.NoForkFoundWithStored(); } IndexerTrace.ImportingChain(chain.GetBlock(height), chain.Tip); Index(chain, height); } }