Search in sources :

Example 6 with Database

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

the class WeakSubjectivityCommand method displayWeakSubjectivityState.

@CommandLine.Command(name = "display-state", description = "Display the stored weak subjectivity configuration", mixinStandardHelpOptions = true, showDefaultValues = true, abbreviateSynopsis = true, versionProvider = PicoCliVersionProvider.class, synopsisHeading = "%n", descriptionHeading = "%nDescription:%n%n", optionListHeading = "%nOptions:%n", footerHeading = "%n", footer = "Teku is licensed under the Apache License 2.0")
public int displayWeakSubjectivityState(@CommandLine.Mixin final BeaconNodeDataOptions dataOptions, @CommandLine.Mixin final DataStorageOptions dataStorageOptions, @CommandLine.Mixin final Eth2NetworkOptions eth2NetworkOptions) throws Exception {
    try (final Database db = createDatabase(dataOptions, dataStorageOptions, eth2NetworkOptions)) {
        final WeakSubjectivityState wsState = db.getWeakSubjectivityState();
        SUB_COMMAND_LOG.display("Stored weak subjectivity state: " + stateToString(wsState));
        return 0;
    }
}
Also used : Database(tech.pegasys.teku.storage.server.Database) WeakSubjectivityState(tech.pegasys.teku.storage.events.WeakSubjectivityState)

Example 7 with Database

use of tech.pegasys.teku.storage.server.Database 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

Database (tech.pegasys.teku.storage.server.Database)7 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)2 Command (picocli.CommandLine.Command)2 WeakSubjectivityState (tech.pegasys.teku.storage.events.WeakSubjectivityState)2 DepositStorage (tech.pegasys.teku.storage.server.DepositStorage)2 VersionedDatabaseFactory (tech.pegasys.teku.storage.server.VersionedDatabaseFactory)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Optional (java.util.Optional)1 CommandLine (picocli.CommandLine)1 Mixin (picocli.CommandLine.Mixin)1 Option (picocli.CommandLine.Option)1 BLSKeyPair (tech.pegasys.teku.bls.BLSKeyPair)1 PicoCliVersionProvider (tech.pegasys.teku.cli.converter.PicoCliVersionProvider)1 BeaconNodeDataOptions (tech.pegasys.teku.cli.options.BeaconNodeDataOptions)1 DataStorageOptions (tech.pegasys.teku.cli.options.DataStorageOptions)1 Eth2NetworkOptions (tech.pegasys.teku.cli.options.Eth2NetworkOptions)1 BlockProvider (tech.pegasys.teku.dataproviders.lookup.BlockProvider)1