Search in sources :

Example 1 with DataSourceWithCache

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

the class RskContext method buildTrieStore.

protected synchronized TrieStore buildTrieStore(Path trieStorePath) {
    checkIfNotClosed();
    int statesCacheSize = getRskSystemProperties().getStatesCacheSize();
    KeyValueDataSource ds = LevelDbDataSource.makeDataSource(trieStorePath);
    if (statesCacheSize != 0) {
        CacheSnapshotHandler cacheSnapshotHandler = getRskSystemProperties().shouldPersistStatesCacheSnapshot() ? new CacheSnapshotHandler(resolveCacheSnapshotPath(trieStorePath)) : null;
        ds = new DataSourceWithCache(ds, statesCacheSize, cacheSnapshotHandler);
    }
    return new TrieStoreImpl(ds);
}
Also used : TrieStoreImpl(co.rsk.trie.TrieStoreImpl) DataSourceWithCache(org.ethereum.datasource.DataSourceWithCache) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) CacheSnapshotHandler(org.ethereum.datasource.CacheSnapshotHandler)

Example 2 with DataSourceWithCache

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

the class RskContext method buildReceiptStore.

protected synchronized ReceiptStore buildReceiptStore() {
    checkIfNotClosed();
    int receiptsCacheSize = getRskSystemProperties().getReceiptsCacheSize();
    KeyValueDataSource ds = LevelDbDataSource.makeDataSource(Paths.get(getRskSystemProperties().databaseDir(), "receipts"));
    if (receiptsCacheSize != 0) {
        ds = new DataSourceWithCache(ds, receiptsCacheSize);
    }
    return new ReceiptStoreImplV2(ds);
}
Also used : DataSourceWithCache(org.ethereum.datasource.DataSourceWithCache) ReceiptStoreImplV2(org.ethereum.db.ReceiptStoreImplV2) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource)

Example 3 with DataSourceWithCache

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

the class RskContext method buildBlocksBloomDataSource.

protected synchronized KeyValueDataSource buildBlocksBloomDataSource() {
    checkIfNotClosed();
    int bloomsCacheSize = getRskSystemProperties().getBloomsCacheSize();
    Path bloomsStorePath = Paths.get(getRskSystemProperties().databaseDir(), "blooms");
    KeyValueDataSource ds = LevelDbDataSource.makeDataSource(bloomsStorePath);
    if (bloomsCacheSize != 0) {
        CacheSnapshotHandler cacheSnapshotHandler = getRskSystemProperties().shouldPersistBloomsCacheSnapshot() ? new CacheSnapshotHandler(resolveCacheSnapshotPath(bloomsStorePath)) : null;
        ds = new DataSourceWithCache(ds, bloomsCacheSize, cacheSnapshotHandler);
    }
    return ds;
}
Also used : Path(java.nio.file.Path) DataSourceWithCache(org.ethereum.datasource.DataSourceWithCache) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource) CacheSnapshotHandler(org.ethereum.datasource.CacheSnapshotHandler)

Example 4 with DataSourceWithCache

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

the class RskContext method buildStateRootsStore.

protected StateRootsStore buildStateRootsStore() {
    checkIfNotClosed();
    int stateRootsCacheSize = getRskSystemProperties().getStateRootsCacheSize();
    KeyValueDataSource stateRootsDB = LevelDbDataSource.makeDataSource(Paths.get(getRskSystemProperties().databaseDir(), "stateRoots"));
    if (stateRootsCacheSize > 0) {
        stateRootsDB = new DataSourceWithCache(stateRootsDB, stateRootsCacheSize);
    }
    return new StateRootsStoreImpl(stateRootsDB);
}
Also used : DataSourceWithCache(org.ethereum.datasource.DataSourceWithCache) KeyValueDataSource(org.ethereum.datasource.KeyValueDataSource)

Aggregations

DataSourceWithCache (org.ethereum.datasource.DataSourceWithCache)4 KeyValueDataSource (org.ethereum.datasource.KeyValueDataSource)4 CacheSnapshotHandler (org.ethereum.datasource.CacheSnapshotHandler)2 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)1 Path (java.nio.file.Path)1 ReceiptStoreImplV2 (org.ethereum.db.ReceiptStoreImplV2)1