protected static void Fill(IConfiguration config, IndexerConfiguration indexerConfig) { var account = GetValue(config, "Azure.AccountName", true); var key = GetValue(config, "Azure.Key", true); indexerConfig.StorageCredentials = new StorageCredentials(account, key); indexerConfig.StorageNamespace = GetValue(config, "StorageNamespace", false); var network = GetValue(config, "Bitcoin.Network", false) ?? "Main"; indexerConfig.Network = Network.GetNetwork(network); if (indexerConfig.Network == null) { throw new IndexerConfigurationErrorsException("Invalid value " + network + " in appsettings (expecting Main, Test or Seg)"); } indexerConfig.Node = GetValue(config, "Node", false); indexerConfig.CheckpointSetName = GetValue(config, "CheckpointSetName", false); if (string.IsNullOrWhiteSpace(indexerConfig.CheckpointSetName)) { indexerConfig.CheckpointSetName = "default"; } var emulator = GetValue(config, "AzureStorageEmulatorUsed", false); if (!string.IsNullOrWhiteSpace(emulator)) { indexerConfig.AzureStorageEmulatorUsed = bool.Parse(emulator); } }
/// <summary> /// Initializes the Azure Indexer. /// </summary> public void Initialize() { this.logger.LogTrace("()"); this.IndexerConfig = IndexerConfigFromSettings(this.indexerSettings, this.FullNode.Network, this.loggerFactory); var indexer = this.IndexerConfig.CreateIndexer(); indexer.Configuration.EnsureSetup(); indexer.TaskScheduler = new CustomThreadPoolTaskScheduler(30, 100); indexer.CheckpointInterval = this.indexerSettings.CheckpointInterval; indexer.IgnoreCheckpoints = this.indexerSettings.IgnoreCheckpoints; indexer.FromHeight = this.indexerSettings.From; indexer.ToHeight = this.indexerSettings.To; this.AzureIndexer = indexer; if (this.indexerSettings.IgnoreCheckpoints) { this.SetStoreTip(this.Chain.GetBlock(indexer.FromHeight)); } else { this.UpdateStoreTip(); } this.StartLoop(); this.logger.LogTrace("(-)"); }
public static IndexerConfiguration FromConfiguration(IConfiguration configuration) { IndexerConfiguration indexerConfig = new IndexerConfiguration(); Fill(configuration, indexerConfig); return(indexerConfig); }
public IndexerTransactionRepository(IndexerConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } _Configuration = config; }
public IndexerClient(IndexerConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _Configuration = configuration; BalancePartitionSize = 50; }
public AzureIndexer(IndexerConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } this.TaskScheduler = TaskScheduler.Default; this.CheckpointInterval = TimeSpan.FromMinutes(15.0); this._Configuration = configuration; this.FromHeight = 0; this.ToHeight = int.MaxValue; }
/// <summary> /// Derives an IndexerConfiguration object from the proviced AzureIndexerSettings object and network. /// </summary> /// <param name="indexerSettings">The AzureIndexerSettings object to use.</param> /// <param name="network">The network to use.</param> /// <returns>An IndexerConfiguration object derived from the AzureIndexerSettings object and network.</returns> public static IndexerConfiguration IndexerConfigFromSettings(AzureIndexerSettings indexerSettings, Network network) { IndexerConfiguration indexerConfig = new IndexerConfiguration(); indexerConfig.StorageCredentials = new StorageCredentials( indexerSettings.AzureAccountName, indexerSettings.AzureKey); indexerConfig.StorageNamespace = indexerSettings.StorageNamespace; indexerConfig.Network = network; indexerConfig.CheckpointSetName = indexerSettings.CheckpointsetName; indexerConfig.AzureStorageEmulatorUsed = indexerSettings.AzureEmulatorUsed; return(indexerConfig); }
/// <summary> /// Derives an IndexerConfiguration object from the proviced AzureIndexerSettings object and network. /// </summary> /// <param name="indexerSettings">The AzureIndexerSettings object to use.</param> /// <param name="network">The network to use.</param> /// <returns>An IndexerConfiguration object derived from the AzureIndexerSettings object and network.</returns> public static IndexerConfiguration IndexerConfigFromSettings(AzureIndexerSettings indexerSettings, Network network, ILoggerFactory loggerFactory) { IndexerConfiguration indexerConfig = new IndexerConfiguration(loggerFactory) { StorageNamespace = indexerSettings.StorageNamespace, Network = network, CheckpointSetName = indexerSettings.CheckpointsetName, AzureStorageEmulatorUsed = indexerSettings.AzureEmulatorUsed, StorageCredentials = indexerSettings.AzureEmulatorUsed ? null : new StorageCredentials(indexerSettings.AzureAccountName, indexerSettings.AzureKey) }; return(indexerConfig); }
public AzureIndexer(IndexerConfiguration configuration, ILoggerFactory loggerFactory) { this.loggerFactory = loggerFactory; if (configuration == null) { throw new ArgumentNullException("configuration"); } this.TaskScheduler = TaskScheduler.Default; this.CheckpointInterval = TimeSpan.FromMinutes(15.0); this._Configuration = configuration; this.FromHeight = 0; this.ToHeight = int.MaxValue; this.logger = loggerFactory.CreateLogger(GetType().FullName); }
/// <summary> /// Initializes the Azure Indexer. /// </summary> public void Initialize() { this.logger.LogTrace("()"); this.IndexerConfig = IndexerConfigFromSettings(this.indexerSettings, this.FullNode.Network); var indexer = this.IndexerConfig.CreateIndexer(); indexer.Configuration.EnsureSetup(); indexer.TaskScheduler = new CustomThreadPoolTaskScheduler(30, 100); indexer.CheckpointInterval = this.indexerSettings.CheckpointInterval; indexer.IgnoreCheckpoints = this.indexerSettings.IgnoreCheckpoints; indexer.FromHeight = this.indexerSettings.From; indexer.ToHeight = this.indexerSettings.To; this.AzureIndexer = indexer; ChainedBlock ckpntBlocks = this.GetCheckPointBlock(IndexerCheckpoints.Blocks); ChainedBlock ckpntBalances = this.GetCheckPointBlock(IndexerCheckpoints.Balances); ChainedBlock ckpntTransactions = this.GetCheckPointBlock(IndexerCheckpoints.Transactions); ChainedBlock ckpntWallets = this.GetCheckPointBlock(IndexerCheckpoints.Wallets); if (this.indexerSettings.IgnoreCheckpoints) { this.SetStoreTip(this.Chain.GetBlock(indexer.FromHeight)); } else { int minHeight = ckpntBlocks.Height; minHeight = Math.Min(minHeight, ckpntBalances.Height); minHeight = Math.Min(minHeight, ckpntTransactions.Height); minHeight = Math.Min(minHeight, ckpntWallets.Height); this.SetStoreTip(this.Chain.GetBlock(minHeight)); } this.BlocksFetcher = this.GetBlockFetcher(IndexerCheckpoints.Blocks, this.nodeLifetime.ApplicationStopping, ckpntBlocks); this.BalancesFetcher = this.GetBlockFetcher(IndexerCheckpoints.Balances, this.nodeLifetime.ApplicationStopping, ckpntBalances); this.TransactionsFetcher = this.GetBlockFetcher(IndexerCheckpoints.Transactions, this.nodeLifetime.ApplicationStopping, ckpntTransactions); this.WalletsFetcher = this.GetBlockFetcher(IndexerCheckpoints.Wallets, this.nodeLifetime.ApplicationStopping, ckpntWallets); this.StartLoop(); this.logger.LogTrace("(-)"); }
public static AzureIndexer CreateIndexer(IConfiguration config, ILoggerFactory loggerFactory) { var indexerConfig = new IndexerConfiguration(config, loggerFactory); return(indexerConfig.CreateIndexer()); }
public static AzureIndexer CreateIndexer(IConfiguration config) { var indexerConfig = IndexerConfiguration.FromConfiguration(config); return(indexerConfig.CreateIndexer()); }