private Checkpoint GetCheckpointInternal(IndexerCheckpoints checkpoint) { var chk = GetCheckpoint(checkpoint); if(IgnoreCheckpoints) chk = new Checkpoint(chk.CheckpointName, Configuration.Network, null, null); return chk; }
/// <summary> /// Perform indexing for a given checkpoint type. /// </summary> /// <param name="type">The checkpoint type to index.</param> /// <param name="fromHeight">The height to index from.</param> /// <param name="toHeight">The height to index to.</param> private void PerformIndexing(IndexerCheckpoints type, int fromHeight, int toHeight) { if (!this.nodeLifetime.ApplicationStopping.IsCancellationRequested) { // Index a batch of blocks/transactions/balances/wallets var fetcher = this.GetBlockFetcher(type); if (toHeight > fetcher._LastProcessed.Height) { fetcher.FromHeight = Math.Max(fetcher._LastProcessed.Height + 1, fromHeight); fetcher.ToHeight = toHeight; IIndexTask task = null; switch (type) { case IndexerCheckpoints.Blocks: task = new IndexBlocksTask(this.IndexerConfig, this.loggerFactory); break; case IndexerCheckpoints.Transactions: task = new IndexTransactionsTask(this.IndexerConfig, this.loggerFactory); break; case IndexerCheckpoints.Balances: task = new IndexBalanceTask(this.IndexerConfig, null, this.loggerFactory); break; case IndexerCheckpoints.Wallets: task = new IndexBalanceTask(this.IndexerConfig, this.IndexerConfig.CreateIndexerClient().GetAllWalletRules(), this.loggerFactory); break; } task.SaveProgression = !this.indexerSettings.IgnoreCheckpoints; task.Index(fetcher, this.AzureIndexer.TaskScheduler, this.FullNode.Network); } } }
internal Checkpoint GetCheckpointInternal(IndexerCheckpoints checkpoint) { var chk = this.GetCheckpoint(checkpoint); if (this.IgnoreCheckpoints) { chk = new Checkpoint(chk.CheckpointName, this.Configuration.Network, null, null); } return(chk); }
private Checkpoint GetCheckpointInternal(IndexerCheckpoints checkpoint) { var chk = GetCheckpoint(checkpoint); if (IgnoreCheckpoints) { chk = new Checkpoint(chk.CheckpointName, Configuration.Network, null, null); } return(chk); }
/// <summary> /// Determines the block that a checkpoint is at. /// </summary> /// <param name="indexerCheckpoints">The type of checkpoint (wallets, blocks, transactions or balances).</param> /// <returns>The block that a checkpoint is at.</returns> private ChainedHeader GetCheckPointBlock(IndexerCheckpoints indexerCheckpoints) { this.logger.LogTrace("()"); Checkpoint checkpoint = this.AzureIndexer.GetCheckpointInternal(indexerCheckpoints); ChainedHeader fork = this.Chain.FindFork(checkpoint.BlockLocator); this.logger.LogTrace("(-):{0}", fork?.ToString()); return(fork); }
/// <summary> /// Gets a block fetcher that respects the given type of checkpoint. /// The block fetcher will return "IndexBatchSize" blocks starting at this.StoreTip + 1. /// If "this.AzureIndexer.IgnoreCheckpoints" is set then the checkpoints /// will be ignored by "GetCheckpointInternal". /// </summary> /// <param name="indexerCheckpoints">The type of checkpoint (wallets, blocks, transactions or balances).</param> /// <param name="cancellationToken">The token used for cancellation.</param> /// <returns>A block fetcher that respects the given type of checkpoint.</returns> private BlockFetcher GetBlockFetcher(IndexerCheckpoints indexerCheckpoints, CancellationToken cancellationToken) { Checkpoint checkpoint = this.AzureIndexer.GetCheckpointInternal(indexerCheckpoints); FullNodeBlocksRepository repo = new FullNodeBlocksRepository(this.FullNode); return(new BlockFetcher(checkpoint, repo, this.Chain) { NeedSaveInterval = this.indexerSettings.CheckpointInterval, FromHeight = this.StoreTip.Height + 1, ToHeight = Math.Min(this.StoreTip.Height + IndexBatchSize, this.indexerSettings.To), CancellationToken = cancellationToken }); }
internal Checkpoint GetCheckpointInternal(IndexerCheckpoints checkpoint) { this.logger.LogTrace("({0}:{1})", nameof(checkpoint), checkpoint); Checkpoint chk = this.GetCheckpoint(checkpoint); if (this.IgnoreCheckpoints) { this.logger.LogTrace("Checkpoints ignored"); chk = new Checkpoint(chk.CheckpointName, this.Configuration.Network, null, null, this.loggerFactory); } this.logger.LogTrace("(-)"); return(chk); }
/// <summary> /// Gets a block fetcher that respects the given type of checkpoint. /// The block fetcher will return "IndexBatchSize" blocks starting at this.StoreTip + 1. /// If "this.AzureIndexer.IgnoreCheckpoints" is set then the checkpoints /// will be ignored by "GetCheckpointInternal". /// </summary> /// <param name="indexerCheckpoints">The type of checkpoint (wallets, blocks, transactions or balances).</param> /// <returns>A block fetcher that respects the given type of checkpoint.</returns> private BlockFetcher GetBlockFetcher(IndexerCheckpoints indexerCheckpoints) { this.logger.LogTrace("()"); Checkpoint checkpoint = this.AzureIndexer.GetCheckpointInternal(indexerCheckpoints); FullNodeBlocksRepository repo = new FullNodeBlocksRepository(this.FullNode); var fetcher = new BlockFetcher(checkpoint, repo, this.Chain, this.Chain.FindFork(checkpoint.BlockLocator), this.loggerFactory) { NeedSaveInterval = this.indexerSettings.CheckpointInterval, FromHeight = this.StoreTip.Height + 1, ToHeight = Math.Min(this.StoreTip.Height + IndexBatchSize, this.indexerSettings.To), CancellationToken = this.nodeLifetime.ApplicationStopping }; this.logger.LogTrace("(-)"); return(fetcher); }
public Task <Checkpoint> GetCheckpointAsync(IndexerCheckpoints checkpoint) { return(this.GetCheckpointRepository().GetCheckpointAsync(checkpoint.ToString().ToLowerInvariant())); }
public Checkpoint GetCheckpoint(IndexerCheckpoints checkpoint) { return(this.GetCheckpointRepository().GetCheckpoint(checkpoint.ToString().ToLowerInvariant())); }
/// <summary> /// Determines the block that a checkpoint is at. /// </summary> /// <param name="indexerCheckpoints">The type of checkpoint (wallets, blocks, transactions or balances).</param> /// <returns>The block that a checkpoint is at.</returns> private ChainedBlock GetCheckPointBlock(IndexerCheckpoints indexerCheckpoints) { Checkpoint checkpoint = this.AzureIndexer.GetCheckpointInternal(indexerCheckpoints); return(this.Chain.FindFork(checkpoint.BlockLocator)); }
/// <summary> /// Get the last processed block for a checkpoint type. /// </summary> /// <param name="type">The type of checkpoint.</param> /// <returns>The last processed block.</returns> private ChainedHeader LastProcessed(IndexerCheckpoints type) { return(this.Chain.FindFork(this.AzureIndexer.GetCheckpointInternal(type).BlockLocator)); }
public Task<Checkpoint> GetCheckpointAsync(IndexerCheckpoints checkpoint) { return GetCheckpointRepository().GetCheckpointAsync(checkpoint.ToString().ToLowerInvariant()); }
public Checkpoint GetCheckpoint(IndexerCheckpoints checkpoint) { return GetCheckpointRepository().GetCheckpoint(checkpoint.ToString().ToLowerInvariant()); }