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;
}
}
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;
}
Aggregations