Search in sources :

Example 1 with VersionedDatabaseFactory

use of tech.pegasys.teku.storage.server.VersionedDatabaseFactory in project teku by ConsenSys.

the class StorageService method doStart.

@Override
protected SafeFuture<?> doStart() {
    return SafeFuture.fromRunnable(() -> {
        final VersionedDatabaseFactory dbFactory = new VersionedDatabaseFactory(serviceConfig.getMetricsSystem(), serviceConfig.getDataDirLayout().getBeaconDataDirectory(), config.getDataStorageMode(), config.getDataStorageCreateDbVersion(), config.getDataStorageFrequency(), config.getEth1DepositContract(), config.isStoreNonCanonicalBlocksEnabled(), config.getMaxKnownNodeCacheSize(), config.getSpec());
        database = dbFactory.createDatabase();
        chainStorage = ChainStorage.create(database, config.getSpec());
        final DepositStorage depositStorage = DepositStorage.create(serviceConfig.getEventChannels().getPublisher(Eth1EventsChannel.class), database);
        serviceConfig.getEventChannels().subscribe(Eth1DepositStorageChannel.class, depositStorage).subscribe(Eth1EventsChannel.class, depositStorage).subscribe(StorageUpdateChannel.class, chainStorage).subscribe(VoteUpdateChannel.class, chainStorage).subscribeMultithreaded(StorageQueryChannel.class, chainStorage, STORAGE_QUERY_CHANNEL_PARALLELISM);
    });
}
Also used : DepositStorage(tech.pegasys.teku.storage.server.DepositStorage) Eth1EventsChannel(tech.pegasys.teku.pow.api.Eth1EventsChannel) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) VoteUpdateChannel(tech.pegasys.teku.storage.api.VoteUpdateChannel)

Example 2 with VersionedDatabaseFactory

use of tech.pegasys.teku.storage.server.VersionedDatabaseFactory in project teku by ConsenSys.

the class WeakSubjectivityCommand method createDatabase.

private Database createDatabase(final BeaconNodeDataOptions dataOptions, final DataStorageOptions dataStorageOptions, final Eth2NetworkOptions eth2NetworkOptions) {
    final Spec spec = eth2NetworkOptions.getNetworkConfiguration().getSpec();
    final VersionedDatabaseFactory databaseFactory = new VersionedDatabaseFactory(new NoOpMetricsSystem(), DataDirLayout.createFrom(dataOptions.getDataConfig()).getBeaconDataDirectory(), dataStorageOptions.getDataStorageMode(), eth2NetworkOptions.getNetworkConfiguration().getEth1DepositContractAddress(), dataStorageOptions.isStoreNonCanonicalBlocks(), spec);
    return databaseFactory.createDatabase();
}
Also used : NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) Spec(tech.pegasys.teku.spec.Spec)

Example 3 with VersionedDatabaseFactory

use of tech.pegasys.teku.storage.server.VersionedDatabaseFactory in project teku by ConsenSys.

the class DebugDbCommand method createDatabase.

private Database createDatabase(final BeaconNodeDataOptions dataOptions, final DataStorageOptions dataStorageOptions, final Eth2NetworkOptions eth2NetworkOptions) {
    final Spec spec = eth2NetworkOptions.getNetworkConfiguration().getSpec();
    final VersionedDatabaseFactory databaseFactory = new VersionedDatabaseFactory(new NoOpMetricsSystem(), DataDirLayout.createFrom(dataOptions.getDataConfig()).getBeaconDataDirectory(), dataStorageOptions.getDataStorageMode(), eth2NetworkOptions.getNetworkConfiguration().getEth1DepositContractAddress(), dataStorageOptions.isStoreNonCanonicalBlocks(), spec);
    return databaseFactory.createDatabase();
}
Also used : NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) Spec(tech.pegasys.teku.spec.Spec)

Example 4 with VersionedDatabaseFactory

use of tech.pegasys.teku.storage.server.VersionedDatabaseFactory in project teku by ConsenSys.

the class DatabaseMigrater method createDatabase.

@VisibleForTesting
KvStoreDatabase createDatabase(final Path databasePath, DatabaseVersion databaseVersion) throws DatabaseMigraterError {
    final Eth2NetworkConfiguration config = Eth2NetworkConfiguration.builder(network).build();
    final VersionedDatabaseFactory databaseFactory = new VersionedDatabaseFactory(new NoOpMetricsSystem(), databasePath, storageMode, databaseVersion, DEFAULT_STORAGE_FREQUENCY, config.getEth1DepositContractAddress(), true, 0, spec);
    final Database database = databaseFactory.createDatabase();
    if (!(database instanceof KvStoreDatabase)) {
        throw new DatabaseMigraterError("Expected the database at " + databasePath.toFile() + " to be a KV store, but it was not, not able to migrate data.");
    }
    return (KvStoreDatabase) database;
}
Also used : NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) KvStoreDatabase(tech.pegasys.teku.storage.server.kvstore.KvStoreDatabase) Database(tech.pegasys.teku.storage.server.Database) Eth2NetworkConfiguration(tech.pegasys.teku.networks.Eth2NetworkConfiguration) VersionedDatabaseFactory(tech.pegasys.teku.storage.server.VersionedDatabaseFactory) KvStoreDatabase(tech.pegasys.teku.storage.server.kvstore.KvStoreDatabase) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VersionedDatabaseFactory (tech.pegasys.teku.storage.server.VersionedDatabaseFactory)4 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)3 Spec (tech.pegasys.teku.spec.Spec)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Eth2NetworkConfiguration (tech.pegasys.teku.networks.Eth2NetworkConfiguration)1 Eth1EventsChannel (tech.pegasys.teku.pow.api.Eth1EventsChannel)1 VoteUpdateChannel (tech.pegasys.teku.storage.api.VoteUpdateChannel)1 Database (tech.pegasys.teku.storage.server.Database)1 DepositStorage (tech.pegasys.teku.storage.server.DepositStorage)1 KvStoreDatabase (tech.pegasys.teku.storage.server.kvstore.KvStoreDatabase)1