/// <summary> /// Initializes a new instance of the <see cref="MongoBuilder"/> class. /// </summary> public MongoBuilder(ILogger <MongoBuilder> logger, IStorage data, IOptions <IndexerConfiguration> nakoConfiguration) : base(logger) { log = logger; mongoData = (MongoData)data; configuration = nakoConfiguration.Value; }
public static IndexerConfiguration CreateConfiguration() { var confBuilder = new ConfigurationBuilder(); var config = IndexerConfiguration.FromConfiguration(confBuilder.Build()); return(config); }
public static IndexerConfiguration CreateConfiguration(ILoggerFactory loggerFactory) { var confBuilder = new ConfigurationBuilder(); var config = new IndexerConfiguration(confBuilder.Build(), loggerFactory); return(config); }
public static QBitNinjaConfiguration FromConfiguration(IConfiguration configuration) { // Make sure the networks are registered NBitcoin.Altcoins.AltNetworkSets.GetAll().Select(c => c.Regtest).ToList(); var conf = new QBitNinjaConfiguration { Indexer = IndexerConfiguration.FromConfiguration(configuration), LocalChain = configuration["LocalChain"], ServiceBus = configuration["ServiceBus"], RPCConnectionString = configuration["RPCConnectionString"], }; var nocache = configuration["NoLocalChain"] == "true"; var qbitDirectory = QBitNinja.DefaultDataDirectory.GetDirectory("qbitninja", conf.Indexer.Network.ToString()); if (string.IsNullOrEmpty(conf.LocalChain)) { conf.LocalChain = Path.Combine(qbitDirectory, "LocalChain.dat"); } if (nocache) { conf.LocalChain = null; } conf.CoinbaseMaturity = conf.Indexer.Network.Consensus.CoinbaseMaturity; return(conf); }
public static IndexerConfiguration CreateConfiguration() { var confBuilder = new ConfigurationBuilder(); confBuilder.AddUserSecrets(typeof(IndexerTester).Assembly); var config = IndexerConfiguration.FromConfiguration(confBuilder.Build()); return config; }
/// <summary> /// Initializes a new instance of the <see cref="StatsHandler"/> class. /// </summary> public StatsHandler(SyncConnection connection, IStorage storage, IOptions <IndexerConfiguration> configuration, IOptions <ChainConfiguration> chainConfiguration) { this.storage = storage; syncConnection = connection; this.configuration = configuration.Value; this.chainConfiguration = chainConfiguration.Value; }
public Indexer(IndexerConfiguration configuration) { if (configuration.Dictionary == null) { throw new InvalidDataException("Error creating Indexer. Dictionary cannot be null"); } if (configuration.TextExtractors == null) { throw new InvalidDataException("Error creating Indexer. Text Extractor cannot be null"); } _configuration = configuration; // wrap the notification handler with our default handler just in case user does not want any notification _configuration.NotificationHandler = new NotificationHandler(_configuration.NotificationHandler, _configuration.Stemmer != null); // set required stuff for splitter _tokenDictionary = new TokenDictionary(_configuration.Dictionary); if (_configuration.TextCorrector != null) { _configuration.TextCorrector.SetTokenDictionary(_tokenDictionary); _configuration.TextCorrector.UseDictionary(false); _configuration.TextCorrector.UseTokenDictionary(true); } _configuration.Splitter.SetTextCorrector(_configuration.TextCorrector); _configuration.Splitter.SetStemmer(_configuration.Stemmer); _configuration.Splitter.SetDictionary(_configuration.Dictionary); _configuration.Splitter.SetTokenDictionary(_tokenDictionary); }
/// <summary> /// Initializes a new instance of the <see cref="SyncServer"/> class. /// </summary> public SyncServer(ILogger <SyncServer> logger, IOptions <IndexerConfiguration> configuration, IOptions <ChainConfiguration> chainConfiguration, IServiceScopeFactory scopeFactory) { log = logger; this.configuration = configuration.Value; this.chainConfiguration = chainConfiguration.Value; this.scopeFactory = scopeFactory; }
/// <summary> /// Initializes a new instance of the <see cref="MongoStorageOperations"/> class. /// </summary> public MongoStorageOperations(IStorage storage, ILogger <MongoStorageOperations> logger, IOptions <IndexerConfiguration> configuration, SyncConnection syncConnection) { data = (MongoData)storage; this.configuration = configuration.Value; log = logger; this.syncConnection = syncConnection; this.storage = storage; }
/// <summary> /// Initializes a new instance of the <see cref="BlockFinder"/> class. /// </summary> public BlockFinder(IOptions <IndexerConfiguration> configuration, ISyncOperations syncOperations, SyncConnection syncConnection, ILogger <BlockFinder> logger) : base(configuration, logger) { log = logger; this.syncConnection = syncConnection; this.syncOperations = syncOperations; config = configuration.Value; watch = Stopwatch.Start(); }
public IndexTask(IndexerConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } this.Configuration = configuration; SaveProgression = true; MaxQueued = 100; }
public IndexTask(IndexerConfiguration configuration, ILoggerFactory loggerFactory) { if (configuration == null) { throw new ArgumentNullException("configuration"); } this.Configuration = configuration; SaveProgression = true; MaxQueued = 100; this.logger = loggerFactory.CreateLogger(GetType().FullName); }
public static RapidBaseConfiguration FromConfiguration() { var conf = new RapidBaseConfiguration { Indexer = IndexerConfiguration.FromConfiguration(), LocalChain = ConfigurationManager.AppSettings["LocalChain"], ServiceBus = ConfigurationManager.AppSettings["ServiceBus"] }; return(conf); }
static string GetFilePath(IndexerConfiguration conf, string name) { var mainDirectory = ConfigurationManager.AppSettings["MainDirectory"]; var fileName = conf.StorageNamespace + "-" + name; if (!String.IsNullOrEmpty(mainDirectory)) { return(Path.Combine(mainDirectory, fileName)); } return(fileName); }
/// <summary> /// Initializes a new instance of the <see cref="Notifier"/> class. /// </summary> public Notifier(IOptions <IndexerConfiguration> configuration, IOptions <ChainConfiguration> chainConfiguration, ILogger <Notifier> logger, IStorage storage) : base(configuration, logger) { this.configuration = configuration.Value; this.chainConfiguration = chainConfiguration.Value; log = logger; this.storage = storage; watch = Stopwatch.Start(); client = new Lazy <HttpClient>(() => new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = (sender, certificate, chain, errors) => errors == SslPolicyErrors.None || errors == SslPolicyErrors.RemoteCertificateNameMismatch })); }
public static QBitNinjaConfiguration FromConfiguration() { var conf = new QBitNinjaConfiguration { Indexer = IndexerConfiguration.FromConfiguration(new ConfigurationManagerConfiguration()), LocalChain = ConfigurationManager.AppSettings["LocalChain"], ServiceBus = ConfigurationManager.AppSettings["ServiceBus"] }; conf.CoinbaseMaturity = conf.Indexer.Network.Consensus.CoinbaseMaturity; return(conf); }
/// <summary> /// Initializes a new instance of the <see cref="SyncOperations"/> class. /// </summary> public SyncOperations(IStorage storage, ILogger <SyncOperations> logger, IOptions <IndexerConfiguration> configuration, IMemoryCache cache) { this.configuration = configuration.Value; log = logger; this.storage = storage; this.cache = cache; // Register the cold staking template. StandardScripts.RegisterStandardScriptTemplate(ColdStakingScriptTemplate.Instance); watch = Stopwatch.Start(); cacheOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(CacheKeys.BlockCountTime); }
/// <summary> /// Runs indexer /// </summary> private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { IsIndexingInProgress = true; UpdateCanStartIndexing(); IndexerConfiguration.SplitterSetting splitterSetting = new IndexerConfiguration.SplitterSetting() { UseDefaultSplitterOfType = ApplyBestSuffixSplit ? SplitterType.Advance : (ApplyCamelCaseSplit ? SplitterType.CamelCase : SplitterType.None), }; IndexerConfiguration.DictionarySetting dictionarySetting = new IndexerConfiguration.DictionarySetting() { DefaultDictionaryRemoveEnglishStopWord = RemoveEnglishStopWords, DefaultDictionaryRemoveProgrammingStopWord = RemoveProgrammingStopWords }; IndexerConfiguration.TextCorrectorSetting textCorrectorSetting = new IndexerConfiguration. TextCorrectorSetting() { UseDefaultSpellChecker = ApplySpellCheck }; ExtractType extractType = 0; SplitTypes.Where(x => x.IsSelected).ToList().ForEach(x => extractType |= x.Value); IndexerConfiguration.TextExtractorSetting textExtractorSetting = new IndexerConfiguration. TextExtractorSetting() { ExtractType = extractType }; IStemmer stemmer = ApplyLemmatizer ? _stanfordLemmatizer : null; IndexerConfiguration.StemmerSetting stemmerSetting = new IndexerConfiguration.StemmerSetting() { CustomStemmer = stemmer, UseDefaultPorterStemmer = ApplyStemmer }; List <IndexerFile> selectedFiles = SelectedFiles.ToList(); IndexerConfiguration indexerConfiguration = IndexerConfiguration.GetIndexerConfiguration(splitterSetting, dictionarySetting, textExtractorSetting, textCorrectorSetting, stemmerSetting, selectedFiles, this); Indexer indexer = new Indexer(indexerConfiguration); e.Result = indexer.Execute(); }
public MongoData(ILogger <MongoStorageOperations> logger, SyncConnection connection, IOptions <IndexerConfiguration> nakoConfiguration, IOptions <ChainConfiguration> chainConfiguration) { configuration = nakoConfiguration.Value; this.chainConfiguration = chainConfiguration.Value; syncConnection = connection; log = logger; mongoClient = new MongoClient(configuration.ConnectionString.Replace("{Symbol}", this.chainConfiguration.Symbol.ToLower())); string dbName = configuration.DatabaseNameSubfix ? "Blockchain" + this.chainConfiguration.Symbol : "Blockchain"; mongoDatabase = mongoClient.GetDatabase(dbName); MemoryTransactions = new ConcurrentDictionary <string, NBitcoin.Transaction>(); // Make sure we only create a single instance of the watcher. watch = Stopwatch.Start(); }
public IndexerTester(string folder) { TestUtils.EnsureNew(folder); var config = IndexerConfiguration.FromConfiguration(); config.StorageNamespace = folder; config.MainDirectory = folder; _Importer = config.CreateIndexer(); foreach (var table in config.EnumerateTables()) { table.CreateIfNotExists(); } config.GetBlocksContainer().CreateIfNotExists(); config.EnsureSetup(); _Folder = folder; }
public NetworkConfig(IndexerConfiguration config, ChainConfiguration chainConfig, NetworkConfiguration networkConfig) { CoinTicker = chainConfig.Symbol; var consensusFactory = (ConsensusFactory)Activator.CreateInstance(Type.GetType(networkConfig.NetworkConsensusFactoryType)); Consensus = new ConsensusConfig(config, consensusFactory); Base58Prefixes = new byte[12][]; Base58Prefixes[(int)Base58Type.PUBKEY_ADDRESS] = new byte[] { (networkConfig.NetworkPubkeyAddressPrefix) }; Base58Prefixes[(int)Base58Type.SCRIPT_ADDRESS] = new byte[] { (networkConfig.NetworkScriptAddressPrefix) }; Bech32Encoders = new Bech32Encoder[2]; var encoder = new Bech32Encoder(networkConfig.NetworkWitnessPrefix); Bech32Encoders[(int)Bech32Type.WITNESS_PUBKEY_ADDRESS] = encoder; Bech32Encoders[(int)Bech32Type.WITNESS_SCRIPT_ADDRESS] = encoder; // TODO //StandardScripts.RegisterStandardScriptTemplate(ColdStakingScriptTemplate); }
private static void Azure() { SetThrottling(); var client = IndexerConfiguration.FromConfiguration().CreateBlobClient(); var container = client.GetContainerReference("throughput2"); container.CreateIfNotExists(); int count = 0; var threads = Enumerable.Range(0, 30).Select(_ => new Thread(__ => { while (true) { var testStream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6 }); // Create a random blob name. string blobName = string.Format("test-{0}.txt", Guid.NewGuid()); // Get a reference to the blob storage system. var blobReference = container.GetBlockBlobReference(blobName); // Upload the word "hello" from a Memory Stream. blobReference.UploadFromStream(testStream); // Increment my stat-counter. Interlocked.Increment(ref count); } })).ToArray(); foreach (var test in threads) { test.Start(); } while (true) { Thread.Sleep(2000); Console.WriteLine(count + " / s"); Interlocked.Exchange(ref count, 0); } }
public static QBitNinjaConfiguration FromConfiguration() { var conf = new QBitNinjaConfiguration { Indexer = IndexerConfiguration.FromConfiguration(new ConfigurationManagerConfiguration()), LocalChain = ConfigurationManager.AppSettings["LocalChain"], ServiceBus = ConfigurationManager.AppSettings["ServiceBus"] }; var nocache = ConfigurationManager.AppSettings["NoLocalChain"] == "true"; var qbitDirectory = QBitNinja.DefaultDataDirectory.GetDirectory("qbitninja", conf.Indexer.Network.ToString()); if (string.IsNullOrEmpty(conf.LocalChain)) { conf.LocalChain = Path.Combine(qbitDirectory, "LocalChain.dat"); } if (nocache) { conf.LocalChain = null; } conf.CoinbaseMaturity = conf.Indexer.Network.Consensus.CoinbaseMaturity; return(conf); }
/// <summary> /// Initializes a new instance of the <see cref="SyncConnection"/> class. /// </summary> public SyncConnection(IOptions <IndexerConfiguration> config, IOptions <ChainConfiguration> chainConfig, IOptions <NetworkConfiguration> networkConfig) { IndexerConfiguration configuration = config.Value; ChainConfiguration chainConfiguration = chainConfig.Value; NetworkConfiguration networkConfiguration = networkConfig.Value; Symbol = chainConfiguration.Symbol; Password = configuration.RpcPassword; // Take the RPC Port from the Indexer configuration, if it is specified. Otherwise we'll use the default for this chain. RpcAccessPort = configuration.RpcAccessPort != 0 ? configuration.RpcAccessPort : networkConfiguration.RPCPort; ServerDomain = configuration.RpcDomain.Replace("{Symbol}", chainConfiguration.Symbol.ToLower()); User = configuration.RpcUser; Secure = configuration.RpcSecure; StartBlockIndex = configuration.StartBlockIndex; // This can be replaced with a specific the network class of a specific coin // Or use the config values to simulate the network class. Network = new NetworkConfig(configuration, chainConfiguration, networkConfiguration); RecentItems = new Buffer <(DateTime Inserted, TimeSpan Duration, long Size)>(5000); }
public ConsensusConfig(IndexerConfiguration config, ConsensusFactory consensusFactory) : base( consensusFactory: consensusFactory, consensusOptions: null, coinType: 0, hashGenesisBlock: uint256.Zero, subsidyHalvingInterval: 0, majorityEnforceBlockUpgrade: 0, majorityRejectBlockOutdated: 0, majorityWindow: 0, buriedDeployments: null, bip9Deployments: null, bip34Hash: uint256.Zero, ruleChangeActivationThreshold: 0, minerConfirmationWindow: 0, maxReorgLength: 0, defaultAssumeValid: uint256.Zero, maxMoney: 0, coinbaseMaturity: 0, premineHeight: 0, premineReward: 0, proofOfWorkReward: 0, powTargetTimespan: TimeSpan.Zero, powTargetSpacing: TimeSpan.Zero, powAllowMinDifficultyBlocks: false, posNoRetargeting: false, powNoRetargeting: false, powLimit: new Target(uint256.Zero), minimumChainWork: null, isProofOfStake: consensusFactory is PosConsensusFactory, lastPowBlock: 0, proofOfStakeLimit: null, proofOfStakeLimitV2: null, proofOfStakeReward: 0 ) { }
static string GetFilePath(IndexerConfiguration conf, string name) { var mainDirectory = ConfigurationManager.AppSettings["MainDirectory"]; var fileName = conf.StorageNamespace + "-" + name; if (!String.IsNullOrEmpty(mainDirectory)) return Path.Combine(mainDirectory, fileName); return fileName; }
public IndexBalanceTask(IndexerConfiguration conf, WalletRuleEntryCollection walletRules, ILoggerFactory loggerFactory) : base(conf, loggerFactory) { _WalletRules = walletRules; this.logger = loggerFactory.CreateLogger(GetType().FullName); }
public IndexTableEntitiesTaskBase(IndexerConfiguration configuration) : base(configuration) { }
public IndexTableEntitiesTask(IndexerConfiguration conf, CloudTable table) : base(conf) { _Table = table; }
public IndexBlocksTask(IndexerConfiguration configuration) : base(configuration) { }
public IndexBalanceTask(IndexerConfiguration conf, WalletRuleEntryCollection walletRules) : base(conf) { _WalletRules = walletRules; }