Search in sources :

Example 6 with RocksDBPersistenceProvider

use of com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider 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)

Example 7 with RocksDBPersistenceProvider

use of com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider in project iri by iotaledger.

the class TipsManagerTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    tangle = new Tangle();
    dbFolder.create();
    logFolder.create();
    tangle.addPersistenceProvider(new RocksDBPersistenceProvider(dbFolder.getRoot().getAbsolutePath(), logFolder.getRoot().getAbsolutePath(), 1000));
    tangle.init();
    TipsViewModel tipsViewModel = new TipsViewModel();
    MessageQ messageQ = new MessageQ(0, null, 1, false);
    TransactionRequester transactionRequester = new TransactionRequester(tangle, messageQ);
    TransactionValidator transactionValidator = new TransactionValidator(tangle, tipsViewModel, transactionRequester, messageQ);
    Milestone milestone = new Milestone(tangle, Hash.NULL_HASH, Snapshot.initialSnapshot.clone(), transactionValidator, true, messageQ);
    LedgerValidator ledgerValidator = new LedgerValidator(tangle, milestone, transactionRequester, messageQ);
    tipsManager = new TipsManager(tangle, ledgerValidator, transactionValidator, tipsViewModel, milestone, 15, messageQ);
}
Also used : TransactionRequester(com.iota.iri.network.TransactionRequester) MessageQ(com.iota.iri.zmq.MessageQ) Milestone(com.iota.iri.Milestone) TransactionValidator(com.iota.iri.TransactionValidator) TipsViewModel(com.iota.iri.controllers.TipsViewModel) RocksDBPersistenceProvider(com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider) Tangle(com.iota.iri.storage.Tangle) LedgerValidator(com.iota.iri.LedgerValidator) BeforeClass(org.junit.BeforeClass)

Example 8 with RocksDBPersistenceProvider

use of com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider in project iri by iotaledger.

the class MilestoneViewModelTest method setUpTest.

@Before
public void setUpTest() throws Exception {
    dbFolder.create();
    logFolder.create();
    RocksDBPersistenceProvider rocksDBPersistenceProvider;
    rocksDBPersistenceProvider = new RocksDBPersistenceProvider(dbFolder.getRoot().getAbsolutePath(), logFolder.getRoot().getAbsolutePath(), 1000);
    tangle.addPersistenceProvider(rocksDBPersistenceProvider);
    tangle.init();
}
Also used : RocksDBPersistenceProvider(com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)

Aggregations

RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)8 BeforeClass (org.junit.BeforeClass)3 TipsViewModel (com.iota.iri.controllers.TipsViewModel)2 TransactionRequester (com.iota.iri.network.TransactionRequester)2 Tangle (com.iota.iri.storage.Tangle)2 MessageQ (com.iota.iri.zmq.MessageQ)2 Before (org.junit.Before)2 TemporaryFolder (org.junit.rules.TemporaryFolder)2 LedgerValidator (com.iota.iri.LedgerValidator)1 Milestone (com.iota.iri.Milestone)1 TransactionValidator (com.iota.iri.TransactionValidator)1 FileExportProvider (com.iota.iri.storage.FileExportProvider)1 ZmqPublishProvider (com.iota.iri.storage.ZmqPublishProvider)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1