use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class RepositoryImplTest method syncToRootAfterCreatingAnAccount.
@Test
public void syncToRootAfterCreatingAnAccount() {
TrieStore store = new TrieStoreImpl(new HashMapDB());
RepositoryImpl repository = new RepositoryImpl(config, store);
repository.flush();
RskAddress accAddress = randomAccountAddress();
byte[] initialRoot = repository.getRoot();
repository.createAccount(accAddress);
repository.flush();
byte[] newRoot = repository.getRoot();
Assert.assertTrue(repository.isExist(accAddress));
repository.syncToRoot(initialRoot);
Assert.assertFalse(repository.isExist(accAddress));
repository.syncToRoot(newRoot);
Assert.assertTrue(repository.isExist(accAddress));
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class RepositoryImplTest method getAccountsKeysOnSnapshot.
@Test
public void getAccountsKeysOnSnapshot() {
RskAddress accAddress1 = randomAccountAddress();
RskAddress accAddress2 = randomAccountAddress();
TrieStore store = new TrieStoreImpl(new HashMapDB());
RepositoryImpl repository = new RepositoryImpl(config, store);
repository.createAccount(accAddress1);
repository.flush();
byte[] root = repository.getRoot();
repository.createAccount(accAddress2);
repository.syncToRoot(root);
Set<RskAddress> keys = repository.getAccountsKeys();
Assert.assertNotNull(keys);
Assert.assertFalse(keys.isEmpty());
Assert.assertEquals(1, keys.size());
}
use of co.rsk.trie.TrieStore in project rskj by rsksmart.
the class DoPrune method doPrune.
public void doPrune(String[] args) throws Exception {
logger.info("Pruning Database");
int blocksToProcess = DEFAULT_BLOCKS_TO_PROCESS;
RskAddress contractAddress = DEFAULT_CONTRACT_ADDRESS;
CLIInterface.call(rskSystemProperties, args);
logger.info("Running {}, core version: {}-{}", rskSystemProperties.genesisInfo(), rskSystemProperties.projectVersion(), rskSystemProperties.projectVersionModifier());
BuildInfo.printInfo();
long height = this.blockchain.getBestBlock().getNumber();
String dataSourceName = getDataSourceName(contractAddress);
logger.info("Datasource Name {}", dataSourceName);
logger.info("Blockchain height {}", height);
TrieImpl source = new TrieImpl(new TrieStoreImpl(levelDbByName(this.rskSystemProperties, dataSourceName)), true);
KeyValueDataSource targetDataSource = levelDbByName(this.rskSystemProperties, dataSourceName + "B");
TrieStore targetStore = new TrieStoreImpl(targetDataSource);
this.processBlocks(height - blocksToProcess, source, contractAddress, targetStore);
targetDataSource.close();
}
Aggregations