use of co.rsk.trie.MultiTrieStore in project rskj by rsksmart.
the class RskContext method buildAbstractTrieStore.
private TrieStore buildAbstractTrieStore(Path databasePath) {
TrieStore newTrieStore;
GarbageCollectorConfig gcConfig = getRskSystemProperties().garbageCollectorConfig();
final String multiTrieStoreNamePrefix = "unitrie_";
if (gcConfig.enabled()) {
try {
newTrieStore = buildMultiTrieStore(databasePath, multiTrieStoreNamePrefix, gcConfig.numberOfEpochs());
} catch (IOException e) {
throw new IllegalStateException("Unable to build multi trie store", e);
}
} else {
Path trieStorePath = databasePath.resolve("unitrie");
try (Stream<Path> databasePathFilesStream = Files.list(databasePath)) {
List<Path> multiTrieStorePaths = databasePathFilesStream.filter(p -> p.getFileName().toString().startsWith(multiTrieStoreNamePrefix)).collect(Collectors.toList());
boolean gcWasEnabled = !multiTrieStorePaths.isEmpty();
if (gcWasEnabled) {
LevelDbDataSource.mergeDataSources(trieStorePath, multiTrieStorePaths);
// cleanup MultiTrieStore data sources
multiTrieStorePaths.stream().map(Path::toString).forEach(FileUtil::recursiveDelete);
}
} catch (IOException e) {
logger.error("Unable to check if GC was ever enabled", e);
}
newTrieStore = buildTrieStore(trieStorePath);
}
return newTrieStore;
}
use of co.rsk.trie.MultiTrieStore in project rskj by rsksmart.
the class RskContext method buildInternalServices.
public synchronized List<InternalService> buildInternalServices() {
checkIfNotClosed();
List<InternalService> internalServices = new ArrayList<>();
internalServices.add(getTransactionPool());
internalServices.add(getChannelManager());
internalServices.add(getNodeMessageHandler());
internalServices.add(getPeerServer());
boolean rpcHttpEnabled = getRskSystemProperties().isRpcHttpEnabled();
boolean rpcWebSocketEnabled = getRskSystemProperties().isRpcWebSocketEnabled();
boolean bloomServiceEnabled = getRskSystemProperties().bloomServiceEnabled();
if (bloomServiceEnabled) {
internalServices.add(new BlocksBloomService(getCompositeEthereumListener(), getBlocksBloomStore(), getBlockStore()));
}
if (rpcHttpEnabled || rpcWebSocketEnabled) {
internalServices.add(getWeb3());
}
if (rpcHttpEnabled) {
internalServices.add(getWeb3HttpServer());
}
if (rpcWebSocketEnabled) {
internalServices.add(getWeb3WebSocketServer());
}
if (getRskSystemProperties().isPeerDiscoveryEnabled()) {
internalServices.add(new UDPServer(getRskSystemProperties().getBindAddress().getHostAddress(), getRskSystemProperties().getPeerPort(), getPeerExplorer()));
}
if (getRskSystemProperties().isSyncEnabled()) {
internalServices.add(getSyncPool());
}
if (getRskSystemProperties().isMinerServerEnabled()) {
internalServices.add(getMinerServer());
if (getRskSystemProperties().isMinerClientEnabled()) {
internalServices.add(getMinerClient());
}
}
NodeBlockProcessor nodeBlockProcessor = getNodeBlockProcessor();
if (nodeBlockProcessor instanceof InternalService) {
internalServices.add((InternalService) nodeBlockProcessor);
}
GarbageCollectorConfig gcConfig = getRskSystemProperties().garbageCollectorConfig();
if (gcConfig.enabled()) {
internalServices.add(new GarbageCollector(getCompositeEthereumListener(), gcConfig.blocksPerEpoch(), gcConfig.numberOfEpochs(), (MultiTrieStore) getTrieStore(), getBlockStore(), getRepositoryLocator()));
}
if (getRskSystemProperties().isPeerScoringStatsReportEnabled()) {
internalServices.add(getPeerScoringReporterService());
}
internalServices.add(new BlockChainFlusher(getRskSystemProperties().flushNumberOfBlocks(), getCompositeEthereumListener(), getTrieStore(), getBlockStore(), getReceiptStore(), getBlocksBloomStore(), getStateRootsStore()));
return Collections.unmodifiableList(internalServices);
}
Aggregations