public void Setup() { _configProvider = Substitute.For <IConfigProvider>(); _configManager = Substitute.For <IConfigManager>(); _ndmConfig = new NdmConfig(); _baseDbPath = "db"; _rocksProvider = Substitute.For <IDbProvider>(); _mongoProvider = Substitute.For <IMongoProvider>(); _logManager = Substitute.For <ILogManager>(); _blockTree = Substitute.For <IBlockTree>(); _specProvider = Substitute.For <ISpecProvider>(); _transactionPool = Substitute.For <ITxPool>(); _receiptStorage = Substitute.For <IReceiptStorage>(); _filterStore = Substitute.For <IFilterStore>(); _filterManager = Substitute.For <IFilterManager>(); _wallet = Substitute.For <IWallet>(); _timestamper = Substitute.For <ITimestamper>(); _ecdsa = Substitute.For <IEthereumEcdsa>(); _keyStore = Substitute.For <IKeyStore>(); _rpcModuleProvider = Substitute.For <IRpcModuleProvider>(); _jsonSerializer = Substitute.For <IJsonSerializer>(); _cryptoRandom = Substitute.For <ICryptoRandom>(); _enode = Substitute.For <IEnode>(); _ndmConsumerChannelManager = Substitute.For <INdmConsumerChannelManager>(); _ndmDataPublisher = Substitute.For <INdmDataPublisher>(); _grpcServer = Substitute.For <IGrpcServer>(); _ethRequestService = Substitute.For <IEthRequestService>(); _notifier = Substitute.For <INdmNotifier>(); _enableUnsecuredDevWallet = false; _blockProcessor = Substitute.For <IBlockProcessor>(); _ndmModule = new NdmModule(); }
public NdmRequiredServices(IConfigProvider configProvider, IConfigManager configManager, INdmConfig ndmConfig, string baseDbPath, IDbProvider rocksProvider, IMongoProvider mongoProvider, ILogManager logManager, IBlockTree blockTree, ITxPool transactionPool, ISpecProvider specProvider, IReceiptStorage receiptStorage, IFilterStore filterStore, IFilterManager filterManager, IWallet wallet, ITimestamper timestamper, IEthereumEcdsa ecdsa, IKeyStore keyStore, IRpcModuleProvider rpcModuleProvider, IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode, INdmConsumerChannelManager ndmConsumerChannelManager, INdmDataPublisher ndmDataPublisher, IGrpcServer grpcServer, IEthRequestService ethRequestService, INdmNotifier notifier, bool enableUnsecuredDevWallet, IBlockProcessor blockProcessor, IJsonRpcClientProxy jsonRpcClientProxy, IEthJsonRpcClientProxy ethJsonRpcClientProxy, IHttpClient httpClient, IMonitoringService monitoringService) { ConfigProvider = configProvider; ConfigManager = configManager; NdmConfig = ndmConfig; BaseDbPath = baseDbPath; RocksProvider = rocksProvider; MongoProvider = mongoProvider; LogManager = logManager; BlockTree = blockTree; TransactionPool = transactionPool; SpecProvider = specProvider; ReceiptStorage = receiptStorage; FilterStore = filterStore; FilterManager = filterManager; Wallet = wallet; Timestamper = timestamper; Ecdsa = ecdsa; KeyStore = keyStore; RpcModuleProvider = rpcModuleProvider; JsonSerializer = jsonSerializer; CryptoRandom = cryptoRandom; Enode = enode; NdmConsumerChannelManager = ndmConsumerChannelManager; NdmDataPublisher = ndmDataPublisher; GrpcServer = grpcServer; EthRequestService = ethRequestService; Notifier = notifier; EnableUnsecuredDevWallet = enableUnsecuredDevWallet; BlockProcessor = blockProcessor; JsonRpcClientProxy = jsonRpcClientProxy; EthJsonRpcClientProxy = ethJsonRpcClientProxy; HttpClient = httpClient; MonitoringService = monitoringService; }
public RequiredServices(IConfigProvider configProvider, IConfigManager configManager, INdmConfig ndmConfig, string baseDbPath, IDbProvider rocksProvider, IMongoProvider mongoProvider, ILogManager logManager, IBlockProcessor blockProcessor, IBlockTree blockTree, ITxPool transactionPool, ITxPoolInfoProvider transactionPoolInfoProvider, ISpecProvider specProvider, IReceiptStorage receiptStorage, IWallet wallet, ITimestamp timestamp, IEthereumEcdsa ecdsa, IKeyStore keyStore, IRpcModuleProvider rpcModuleProvider, IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode, INdmConsumerChannelManager ndmConsumerChannelManager, INdmDataPublisher ndmDataPublisher, IGrpcService grpcService, EthRequestService ethRequestService, bool enableUnsecuredDevWallet) { ConfigProvider = configProvider; ConfigManager = configManager; NdmConfig = ndmConfig; BaseDbPath = baseDbPath; RocksProvider = rocksProvider; MongoProvider = mongoProvider; LogManager = logManager; BlockProcessor = blockProcessor; BlockTree = blockTree; TransactionPool = transactionPool; TransactionPoolInfoProvider = transactionPoolInfoProvider; SpecProvider = specProvider; ReceiptStorage = receiptStorage; Wallet = wallet; Timestamp = timestamp; Ecdsa = ecdsa; KeyStore = keyStore; RpcModuleProvider = rpcModuleProvider; JsonSerializer = jsonSerializer; CryptoRandom = cryptoRandom; Enode = enode; NdmConsumerChannelManager = ndmConsumerChannelManager; NdmDataPublisher = ndmDataPublisher; GrpcService = grpcService; EthRequestService = ethRequestService; EnableUnsecuredDevWallet = enableUnsecuredDevWallet; }
public TeacherRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection <Teacher>("teacher"); }
public void Setup() { _mockMongoProvider = MockRepository.GenerateMock<IMongoProvider>(); _mockMongoProvider.Stub(p => p.ForCollection(Arg<string>.Is.Anything)).Return(_mockMongoProvider); _repo = new UserRepository(_mockMongoProvider); }
public TopicRepository(IMongoProvider provider) { Database = provider.database; collection = Database.GetCollection<Topic>("topic"); }
public ProjectRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection<Project>("projects"); }
public SubjectRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection <Subject>("subjects"); }
public MongoRepository(IMongoProvider unitOfWork) : base(unitOfWork) { _databaseProvider = unitOfWork; }
public GroupRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection<Group>("groups"); }
public MongoPricingService(IMongoProvider provider) { _pricing = provider.GetCollection <PricingInformation>("Pricing"); }
public MongoOutputProvider(IMongoProvider provider) { _provider = provider; }
public TitleService(IMongoProvider mongo, string collection) : base(mongo, collection) { }
PreInitAsync(IConfigProvider configProvider, IDbProvider dbProvider, string baseDbPath, IBlockTree blockTree, ITxPool txPool, ISpecProvider specProvider, IReceiptStorage receiptStorage, IWallet wallet, IFilterStore filterStore, IFilterManager filterManager, ITimestamper timestamper, IEthereumEcdsa ecdsa, IRpcModuleProvider rpcModuleProvider, IKeyStore keyStore, IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode, INdmConsumerChannelManager consumerChannelManager, INdmDataPublisher dataPublisher, IGrpcServer grpcServer, bool enableUnsecuredDevWallet, IWebSocketsManager webSocketsManager, ILogManager logManager, IBlockProcessor blockProcessor) { if (!(configProvider.GetConfig<INdmConfig>() is NdmConfig defaultConfig)) { return default; } if (!defaultConfig.Enabled) { return default; } if (defaultConfig.StoreConfigInDatabase && string.IsNullOrWhiteSpace(defaultConfig.Id)) { throw new ArgumentException("NDM config stored in database requires an id.", nameof(defaultConfig.Id)); } IMongoProvider mongoProvider = null; IConfigRepository configRepository = null; IEthRequestRepository ethRequestRepository = null; switch (defaultConfig.Persistence?.ToLowerInvariant()) { case "mongo": mongoProvider = new MongoProvider(configProvider.GetConfig<INdmMongoConfig>(), logManager); var database = mongoProvider.GetDatabase(); configRepository = new ConfigMongoRepository(database); ethRequestRepository = new EthRequestMongoRepository(database); break; default: configRepository = new ConfigRocksRepository(dbProvider.ConfigsDb, new NdmConfigDecoder()); ethRequestRepository = new EthRequestRocksRepository(dbProvider.EthRequestsDb, new EthRequestDecoder()); break; } var configManager = new ConfigManager(defaultConfig, configRepository); var ndmConfig = await configManager.GetAsync(defaultConfig.Id); if (ndmConfig is null) { ndmConfig = defaultConfig; if (defaultConfig.StoreConfigInDatabase) { await configManager.UpdateAsync(ndmConfig); } } var webSocketsModule = webSocketsManager.GetModule("ndm"); var notifier = new NdmNotifier(webSocketsModule); var ethRequestService = new EthRequestService(ndmConfig.FaucetHost, logManager); var services = _ndmModule.Init(new NdmRequiredServices(configProvider, configManager, ndmConfig, baseDbPath, dbProvider, mongoProvider, logManager, blockTree, txPool, specProvider, receiptStorage, filterStore, filterManager, wallet, timestamper, ecdsa, keyStore, rpcModuleProvider, jsonSerializer, cryptoRandom, enode, consumerChannelManager, dataPublisher, grpcServer, ethRequestService, notifier, enableUnsecuredDevWallet, blockProcessor)); var faucetAddress = string.IsNullOrWhiteSpace(ndmConfig.FaucetAddress) ? null : new Address(ndmConfig.FaucetAddress); var faucet = new NdmFaucet(services.CreatedServices.BlockchainBridge, ethRequestRepository, faucetAddress, ndmConfig.FaucetWeiRequestMaxValue, ndmConfig.FaucetEthDailyRequestsTotalValue, ndmConfig.FaucetEnabled, timestamper, wallet, logManager); var consumerAddress = string.IsNullOrWhiteSpace(ndmConfig.ConsumerAddress) ? Address.Zero : new Address(ndmConfig.ConsumerAddress); var providerAddress = string.IsNullOrWhiteSpace(ndmConfig.ProviderAddress) ? Address.Zero : new Address(ndmConfig.ProviderAddress); var consumers = _ndmConsumersModule.Init(services); return (ndmConfig, services, faucet, consumers.AccountService, consumers.ConsumerService, consumerAddress, providerAddress); }
protected MongoSeederBase(string key, IMongoProvider provider) { _key = key; _provider = provider; }
public MongoOutputProvider(IMongoProvider provider) { _provider = provider; }
async Task <IPersist> IPeristProvider.CreatePersistAsync(IConfigure Configure, CancellationToken token) { string collectionBase = string.Empty; MongoPersist toReturn = null; string collectionName = string.Empty; bool CreateDatabase = this.dbName.DB == MongoDataBaseName.CREATE; //if database provided, our collection names must be unique, so we factor in applicationname if (!CreateDatabase) { collectionName = string.Format("{0}_{1}", Configure.ApplicationName, "messages"); } else //if we are creating database, our collectionname can be generic { this.dbName = Configure.ApplicationName; collectionName = "messages"; } // TODO: test if database exists and that it is not configured for another collection this.mongoProvider = new MongoProvider(server); ////if not createdatabase, then the one passed in must exist //if (!CreateDatabase) { // if (!this.DBExists()) { // throw new Exception(string.Format("{0} does not exists", this.dbName.DB)); // } //} bool exists = await this.CollectionExistsAsync(collectionName, token); if (exists) { toReturn = new MongoPersist(new MongoSettings() { ServerName = this.server, DataBaseName = this.dbName.DB, CollectionName = collectionName }); EndpointConfigPersist <EndPointConfigBase> configReader = new EndpointConfigPersist <EndPointConfigBase>(toReturn); //get config and ensure its the same EndPointConfigBase config = await configReader.GetConfigAsync(token); if (config.ApplicationGUID != Configure.ApplicationGUID) { throw new Exception("Collection exists but has already been configured for another process"); } } else //if not, we must create //create collection { IMongoDatabase db = this.mongoProvider.GetClient().GetDatabase(dbName.DB); await db.CreateCollectionAsync(collectionName, null, token); IMongoCollection <PersistedMessage> collection = db.GetCollection <PersistedMessage>(collectionName); collection = await this.CreateIndexesAsync(collection, token); toReturn = new MongoPersist(new MongoSettings() { ServerName = this.server, DataBaseName = this.dbName.DB, CollectionName = collectionName }); EndpointConfigPersist <EndPointConfigBase> configReader = new EndpointConfigPersist <EndPointConfigBase>(toReturn); EndPointConfigBase config = new EndPointConfigBase() { ApplicationGUID = Configure.ApplicationGUID, ApplicationName = Configure.ApplicationName, Version = "1.0" }; await configReader.UpdateConfigAsync(config, token); } return(toReturn); }
public MongoService(IMongoProvider mongo, string collection) { _collection = mongo.GetCollection <T>(collection); }
public NdmRequiredServices( IConfigProvider configProvider, IConfigManager configManager, INdmConfig ndmConfig, string baseDbPath, IDbProvider rocksProvider, IMongoProvider mongoProvider, ILogManager logManager, IBlockTree blockTree, ITxPool transactionPool, ISpecProvider specProvider, IReceiptStorage receiptStorage, IFilterStore filterStore, IFilterManager filterManager, IWallet wallet, ITimestamper timestamper, IEthereumEcdsa ecdsa, IKeyStore keyStore, IRpcModuleProvider rpcModuleProvider, IJsonSerializer jsonSerializer, ICryptoRandom cryptoRandom, IEnode enode, INdmConsumerChannelManager ndmConsumerChannelManager, INdmDataPublisher ndmDataPublisher, IGrpcServer grpcServer, IEthRequestService ethRequestService, INdmNotifier notifier, bool enableUnsecuredDevWallet, IBlockProcessor blockProcessor, IJsonRpcClientProxy?jsonRpcClientProxy, IEthJsonRpcClientProxy?ethJsonRpcClientProxy, IHttpClient httpClient, IMonitoringService monitoringService, IBloomStorage bloomStorage) { ConfigProvider = configProvider ?? throw new ArgumentNullException(nameof(configProvider)); ConfigManager = configManager ?? throw new ArgumentNullException(nameof(configManager)); NdmConfig = ndmConfig ?? throw new ArgumentNullException(nameof(ndmConfig)); BaseDbPath = baseDbPath ?? throw new ArgumentNullException(nameof(baseDbPath)); RocksProvider = rocksProvider ?? throw new ArgumentNullException(nameof(rocksProvider)); MongoProvider = mongoProvider ?? throw new ArgumentNullException(nameof(mongoProvider)); LogManager = logManager ?? throw new ArgumentNullException(nameof(logManager)); BlockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree)); TransactionPool = transactionPool ?? throw new ArgumentNullException(nameof(transactionPool)); SpecProvider = specProvider ?? throw new ArgumentNullException(nameof(specProvider)); ReceiptStorage = receiptStorage ?? throw new ArgumentNullException(nameof(receiptStorage)); FilterStore = filterStore ?? throw new ArgumentNullException(nameof(filterStore)); FilterManager = filterManager ?? throw new ArgumentNullException(nameof(filterManager)); Wallet = wallet ?? throw new ArgumentNullException(nameof(wallet)); Timestamper = timestamper ?? throw new ArgumentNullException(nameof(timestamper)); Ecdsa = ecdsa ?? throw new ArgumentNullException(nameof(ecdsa)); KeyStore = keyStore ?? throw new ArgumentNullException(nameof(keyStore)); RpcModuleProvider = rpcModuleProvider ?? throw new ArgumentNullException(nameof(rpcModuleProvider)); JsonSerializer = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer)); CryptoRandom = cryptoRandom ?? throw new ArgumentNullException(nameof(cryptoRandom)); Enode = enode ?? throw new ArgumentNullException(nameof(enode)); NdmConsumerChannelManager = ndmConsumerChannelManager ?? throw new ArgumentNullException(nameof(ndmConsumerChannelManager)); NdmDataPublisher = ndmDataPublisher ?? throw new ArgumentNullException(nameof(ndmDataPublisher)); GrpcServer = grpcServer ?? throw new ArgumentNullException(nameof(grpcServer)); EthRequestService = ethRequestService ?? throw new ArgumentNullException(nameof(ethRequestService)); Notifier = notifier ?? throw new ArgumentNullException(nameof(notifier)); EnableUnsecuredDevWallet = enableUnsecuredDevWallet; BlockProcessor = blockProcessor ?? throw new ArgumentNullException(nameof(blockProcessor)); HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); MonitoringService = monitoringService ?? throw new ArgumentNullException(nameof(monitoringService)); JsonRpcClientProxy = jsonRpcClientProxy; EthJsonRpcClientProxy = ethJsonRpcClientProxy; BloomStorage = bloomStorage; }
public StudentRepository(IMongoProvider provider) { Database = provider.database; collection = Database.GetCollection <Student>("student"); }
public PricingSeeder(IMongoProvider provider) : base("Pricing", provider) { }
public TeacherRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection<Teacher>("teacher"); }
public StageRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection <Stage>("stages"); }
public TopicRepository(IMongoProvider provider) { Database = provider.database; collection = Database.GetCollection <Topic>("topic"); }
public UserRepository(IMongoProvider repository) { _repository = repository.ForCollection("User"); }
public GroupRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection <Group>("groups"); }
public StudentRepository(IMongoProvider provider) { Database = provider.database; collection = Database.GetCollection<Student>("student"); }
public StageRepository(IMongoProvider provider) { Database = provider.database; _collection = Database.GetCollection<Stage>("stages"); }