Search in sources :

Example 1 with ContractDetailsCacheImpl

use of org.ethereum.db.ContractDetailsCacheImpl in project rskj by rsksmart.

the class RepositoryBuilder method build.

public static Repository build(Map<String, AccountTck> accounts) {
    HashMap<RskAddress, AccountState> stateBatch = new HashMap<>();
    HashMap<RskAddress, ContractDetails> detailsBatch = new HashMap<>();
    for (String address : accounts.keySet()) {
        RskAddress addr = new RskAddress(address);
        AccountTck accountTCK = accounts.get(address);
        AccountBuilder.StateWrap stateWrap = AccountBuilder.build(accountTCK);
        AccountState state = stateWrap.getAccountState();
        ContractDetails details = stateWrap.getContractDetails();
        stateBatch.put(addr, state);
        ContractDetailsCacheImpl detailsCache = new ContractDetailsCacheImpl(details);
        detailsCache.setDirty(true);
        detailsBatch.put(addr, detailsCache);
    }
    RepositoryImpl repositoryDummy = new RepositoryImpl(new RskSystemProperties(), new TrieStoreImpl(new HashMapDB()));
    Repository track = repositoryDummy.startTracking();
    track.updateBatch(stateBatch, detailsBatch);
    track.commit();
    return repositoryDummy;
}
Also used : AccountTck(org.ethereum.jsontestsuite.model.AccountTck) TrieStoreImpl(co.rsk.trie.TrieStoreImpl) HashMap(java.util.HashMap) AccountState(org.ethereum.core.AccountState) HashMapDB(org.ethereum.datasource.HashMapDB) ContractDetails(org.ethereum.db.ContractDetails) Repository(org.ethereum.core.Repository) RepositoryImpl(co.rsk.db.RepositoryImpl) RskAddress(co.rsk.core.RskAddress) ContractDetailsCacheImpl(org.ethereum.db.ContractDetailsCacheImpl) RskSystemProperties(co.rsk.config.RskSystemProperties)

Aggregations

RskSystemProperties (co.rsk.config.RskSystemProperties)1 RskAddress (co.rsk.core.RskAddress)1 RepositoryImpl (co.rsk.db.RepositoryImpl)1 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)1 HashMap (java.util.HashMap)1 AccountState (org.ethereum.core.AccountState)1 Repository (org.ethereum.core.Repository)1 HashMapDB (org.ethereum.datasource.HashMapDB)1 ContractDetails (org.ethereum.db.ContractDetails)1 ContractDetailsCacheImpl (org.ethereum.db.ContractDetailsCacheImpl)1 AccountTck (org.ethereum.jsontestsuite.model.AccountTck)1