Search in sources :

Example 11 with KeyValueDataSource

use of org.ethereum.datasource.KeyValueDataSource in project rskj by rsksmart.

the class BlockChainImplTest method createBlockChain.

private static BlockChainImpl createBlockChain(Repository repository, IndexedBlockStore blockStore, BlockValidatorImpl blockValidator) {
    KeyValueDataSource ds = new HashMapDB();
    ds.init();
    ReceiptStore receiptStore = new ReceiptStoreImpl(ds);
    AdminInfo adminInfo = new SimpleAdminInfo();
    EthereumListener listener = new BlockExecutorTest.SimpleEthereumListener();
    BlockChainImpl blockChain = new BlockChainImpl(config, repository, blockStore, receiptStore, null, listener, adminInfo, blockValidator);
    TransactionPoolImpl transactionPool = new TransactionPoolImpl(config, repository, blockStore, receiptStore, null, listener, 10, 100);
    blockChain.setTransactionPool(transactionPool);
    return blockChain;
}
Also used : ReceiptStoreImpl(org.ethereum.db.ReceiptStoreImpl) EthereumListener(org.ethereum.listener.EthereumListener) AdminInfo(org.ethereum.manager.AdminInfo) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) HashMapDB(org.ethereum.datasource.HashMapDB) ReceiptStore(org.ethereum.db.ReceiptStore)

Example 12 with KeyValueDataSource

use of org.ethereum.datasource.KeyValueDataSource in project rskj by rsksmart.

the class ContractDetailsImpl method checkDataSourceIsOpened.

private void checkDataSourceIsOpened() {
    if (!this.closed) {
        return;
    }
    if (!this.externalStorage) {
        return;
    }
    logger.trace("reopening contract details data source");
    KeyValueDataSource ds = levelDbByName(config, this.getDataSourceName());
    TrieStoreImpl newStore = new TrieStoreImpl(ds);
    Trie newTrie = newStore.retrieve(this.trie.getHash().getBytes());
    this.trie = newTrie;
    this.closed = false;
}
Also used : KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource)

Example 13 with KeyValueDataSource

use of org.ethereum.datasource.KeyValueDataSource in project rskj by rsksmart.

the class CommonConfig method makeDataSource.

private KeyValueDataSource makeDataSource(RskSystemProperties config, String name) {
    KeyValueDataSource ds = new LevelDbDataSource(config, name);
    ds.init();
    return ds;
}
Also used : KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) LevelDbDataSource(org.ethereum.datasource.LevelDbDataSource)

Example 14 with KeyValueDataSource

use of org.ethereum.datasource.KeyValueDataSource in project rskj by rsksmart.

the class CommonConfig method repository.

@Bean
public Repository repository(RskSystemProperties config) {
    String databaseDir = config.databaseDir();
    if (config.databaseReset()) {
        FileUtil.recursiveDelete(databaseDir);
        logger.info("Database reset done");
    }
    KeyValueDataSource ds = makeDataSource(config, "state");
    KeyValueDataSource detailsDS = makeDataSource(config, "details");
    return new RepositoryImpl(config, new TrieStoreImpl(ds), detailsDS);
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) RepositoryImpl(co.rsk.db.RepositoryImpl) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) Bean(org.springframework.context.annotation.Bean)

Example 15 with KeyValueDataSource

use of org.ethereum.datasource.KeyValueDataSource in project rskj by rsksmart.

the class DefaultConfig method receiptStore.

@Bean
public ReceiptStore receiptStore(RskSystemProperties config) {
    KeyValueDataSource ds = new LevelDbDataSource(config, "receipts");
    ds.init();
    return new ReceiptStoreImpl(ds);
}
Also used : KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) LevelDbDataSource(org.ethereum.datasource.LevelDbDataSource) Bean(org.springframework.context.annotation.Bean)

Aggregations

KeyValueDataSource (org.ethereum.datasource.KeyValueDataSource)26 HashMapDB (org.ethereum.datasource.HashMapDB)13 Test (org.junit.Test)13 LevelDbDataSource (org.ethereum.datasource.LevelDbDataSource)10 BlockDifficulty (co.rsk.core.BlockDifficulty)6 Block (org.ethereum.core.Block)6 DB (org.mapdb.DB)6 BigInteger (java.math.BigInteger)5 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)4 Bean (org.springframework.context.annotation.Bean)4 RskAddress (co.rsk.core.RskAddress)3 RepositoryImpl (co.rsk.db.RepositoryImpl)3 DummyBlockValidator (co.rsk.validators.DummyBlockValidator)3 EthereumListener (org.ethereum.listener.EthereumListener)3 AdminInfo (org.ethereum.manager.AdminInfo)3 RskSystemProperties (co.rsk.config.RskSystemProperties)2 BlockChainImpl (co.rsk.core.bc.BlockChainImpl)2 TransactionPoolImpl (co.rsk.core.bc.TransactionPoolImpl)2 ReceiptStore (org.ethereum.db.ReceiptStore)2 ReceiptStoreImpl (org.ethereum.db.ReceiptStoreImpl)2