Search in sources :

Example 1 with ZmqPublishProvider

use of com.iota.iri.storage.ZmqPublishProvider in project iri by iotaledger.

the class Iota method initializeTangle.

private void initializeTangle() {
    String dbPath = configuration.string(Configuration.DefaultConfSettings.DB_PATH);
    if (testnet) {
        if (dbPath.isEmpty() || dbPath.equals("mainnetdb")) {
            // testnetusers must not use mainnetdb, overwrite it unless an explicit name is set.
            configuration.put(Configuration.DefaultConfSettings.DB_PATH.name(), "testnetdb");
            configuration.put(Configuration.DefaultConfSettings.DB_LOG_PATH.name(), "testnetdb.log");
        }
    } else {
        if (dbPath.isEmpty() || dbPath.equals("testnetdb")) {
            // mainnetusers must not use testnetdb, overwrite it unless an explicit name is set.
            configuration.put(Configuration.DefaultConfSettings.DB_PATH.name(), "mainnetdb");
            configuration.put(Configuration.DefaultConfSettings.DB_LOG_PATH.name(), "mainnetdb.log");
        }
    }
    switch(configuration.string(Configuration.DefaultConfSettings.MAIN_DB)) {
        case "rocksdb":
            {
                tangle.addPersistenceProvider(new RocksDBPersistenceProvider(configuration.string(Configuration.DefaultConfSettings.DB_PATH), configuration.string(Configuration.DefaultConfSettings.DB_LOG_PATH), configuration.integer(Configuration.DefaultConfSettings.DB_CACHE_SIZE)));
                break;
            }
        default:
            {
                throw new NotImplementedException("No such database type.");
            }
    }
    if (configuration.booling(Configuration.DefaultConfSettings.EXPORT)) {
        tangle.addPersistenceProvider(new FileExportProvider());
    }
    if (configuration.booling(Configuration.DefaultConfSettings.ZMQ_ENABLED)) {
        tangle.addPersistenceProvider(new ZmqPublishProvider(messageQ));
    }
}
Also used : FileExportProvider(com.iota.iri.storage.FileExportProvider) NotImplementedException(org.apache.commons.lang3.NotImplementedException) RocksDBPersistenceProvider(com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider) ZmqPublishProvider(com.iota.iri.storage.ZmqPublishProvider)

Aggregations

FileExportProvider (com.iota.iri.storage.FileExportProvider)1 ZmqPublishProvider (com.iota.iri.storage.ZmqPublishProvider)1 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1