예제 #1
0
        public async Task Init(string basePath, IDbConfig dbConfig, bool useReceiptsDb)
        {
            _dbConfig = dbConfig;
            _basePath = basePath;

            HashSet <Task> allInitializers = new HashSet <Task>();

            allInitializers.Add(Task.Run(() => BlocksDb     = new BlocksRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => HeadersDb    = new HeadersRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => BlockInfosDb = new BlockInfosRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => StateDb      = new StateDb(new StateRocksDb(basePath, dbConfig, _logManager))));
            allInitializers.Add(Task.Run(() => CodeDb       = new StateDb(new CodeRocksDb(basePath, dbConfig, _logManager))));
            allInitializers.Add(Task.Run(() => PendingTxsDb = new PendingTxsRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => BloomDb      = new BloomRocksDb(basePath, dbConfig, _logManager)));

            allInitializers.Add(Task.Run(() =>
            {
                if (useReceiptsDb)
                {
                    ReceiptsDb = new ReceiptsRocksDb(basePath, dbConfig, _logManager);
                }
                else
                {
                    ReceiptsDb = new ReadOnlyDb(new MemDb(), false);
                }
            }));

            await Task.WhenAll(allInitializers);
        }
예제 #2
0
        public async Task Init(string basePath, IDbConfig dbConfig, bool useReceiptsDb)
        {
            HashSet <Task> allInitializers = new HashSet <Task>();

            allInitializers.Add(Task.Run(() => BlocksDb      = new BlocksRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => HeadersDb     = new HeadersRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => BlockInfosDb  = new BlockInfosRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => StateDb       = new StateDb(new StateRocksDb(basePath, dbConfig, _logManager))));
            allInitializers.Add(Task.Run(() => CodeDb        = new StateDb(new CodeRocksDb(basePath, dbConfig, _logManager))));
            allInitializers.Add(Task.Run(() => PendingTxsDb  = new PendingTxsRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => BloomDb       = new BloomRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => ChtDb         = new CanonicalHashRocksDb(basePath, dbConfig, _logManager)));
            allInitializers.Add(Task.Run(() => ConfigsDb     = _addNdmDbs ? new ConfigsRocksDb(basePath, dbConfig, _logManager) : (IDb) new MemDb()));
            allInitializers.Add(Task.Run(() => EthRequestsDb = _addNdmDbs ? new EthRequestsRocksDb(basePath, dbConfig, _logManager) : (IDb) new MemDb()));

            allInitializers.Add(Task.Run(() =>
            {
                if (useReceiptsDb)
                {
                    ReceiptsDb = new ReceiptsRocksDb(basePath, dbConfig, _logManager);
                }
                else
                {
                    ReceiptsDb = new ReadOnlyColumnsDb <ReceiptsColumns>(new MemColumnsDb <ReceiptsColumns>(), false);
                }
            }));

            await Task.WhenAll(allInitializers);
        }