private void RegisterAll(bool useReceiptsDb) { RegisterDb(BuildRocksDbSettings(DbNames.Blocks, () => Metrics.BlocksDbReads++, () => Metrics.BlocksDbWrites++)); RegisterDb(BuildRocksDbSettings(DbNames.Headers, () => Metrics.HeaderDbReads++, () => Metrics.HeaderDbWrites++)); RegisterDb(BuildRocksDbSettings(DbNames.BlockInfos, () => Metrics.BlockInfosDbReads++, () => Metrics.BlockInfosDbWrites++)); RocksDbSettings stateDbSettings = BuildRocksDbSettings(DbNames.State, () => Metrics.StateDbReads++, () => Metrics.StateDbWrites++); RegisterCustomDb(DbNames.State, () => new FullPruningDb( stateDbSettings, PersistedDb ? new FullPruningInnerDbFactory(RocksDbFactory, _fileSystem, stateDbSettings.DbPath) : new MemDbFactoryToRocksDbAdapter(MemDbFactory), () => Interlocked.Increment(ref Metrics.StateDbInPruningWrites))); RegisterDb(BuildRocksDbSettings(DbNames.Code, () => Metrics.CodeDbReads++, () => Metrics.CodeDbWrites++)); RegisterDb(BuildRocksDbSettings(DbNames.Bloom, () => Metrics.BloomDbReads++, () => Metrics.BloomDbWrites++)); RegisterDb(BuildRocksDbSettings(DbNames.CHT, () => Metrics.CHTDbReads++, () => Metrics.CHTDbWrites++)); RegisterDb(BuildRocksDbSettings(DbNames.Witness, () => Metrics.WitnessDbReads++, () => Metrics.WitnessDbWrites++)); if (useReceiptsDb) { RegisterColumnsDb <ReceiptsColumns>(BuildRocksDbSettings(DbNames.Receipts, () => Metrics.ReceiptsDbReads++, () => Metrics.ReceiptsDbWrites++)); } else { RegisterCustomDb(DbNames.Receipts, () => new ReadOnlyColumnsDb <ReceiptsColumns>(new MemColumnsDb <ReceiptsColumns>(), false)); } RegisterDb(BuildRocksDbSettings(DbNames.Metadata, () => Metrics.MetadataDbReads++, () => Metrics.MetadataDbWrites++)); }
private void AddRegisterAction(RocksDbSettings settings, Func <IDb> rocksDbCreation, Func <IDb> memDbCreation) { var action = new Action(() => { IDb db; if (_dbProvider.DbMode == DbModeHint.Persisted) { db = rocksDbCreation(); } else { db = memDbCreation(); } _dbProvider.RegisterDb(settings.DbName, db); }); _registrations.Add(action); }
protected void RegisterColumnsDb <T>(RocksDbSettings settings) { AddRegisterAction(settings, () => _rocksDbFactory.CreateColumnsDb <T>(settings), () => _memDbFactory.CreateColumnsDb <T>(settings.DbName)); }
protected void RegisterSnapshotableDb(RocksDbSettings settings) { AddRegisterAction(settings, () => _rocksDbFactory.CreateSnapshotableDb(settings), () => _memDbFactory.CreateSnapshotableDb(settings.DbName)); }