Search in sources :

Example 46 with AccountState

use of org.ethereum.core.AccountState in project rskj by rsksmart.

the class RepositoryImpl method saveCode.

@Override
public synchronized void saveCode(RskAddress addr, byte[] code) {
    AccountState accountState = getAccountState(addr);
    ContractDetails details = getContractDetails(addr);
    if (accountState == null) {
        accountState = createAccount(addr);
        details = getContractDetails(addr);
    }
    details.setCode(code);
    accountState.setCodeHash(Keccak256Helper.keccak256(code));
    updateContractDetails(addr, details);
    updateAccountState(addr, accountState);
}
Also used : AccountState(org.ethereum.core.AccountState)

Aggregations

AccountState (org.ethereum.core.AccountState)46 Test (org.junit.Test)20 RskAddress (co.rsk.core.RskAddress)12 BigInteger (java.math.BigInteger)11 Coin (co.rsk.core.Coin)10 Transaction (org.ethereum.core.Transaction)10 Repository (org.ethereum.core.Repository)7 ContractDetails (org.ethereum.db.ContractDetails)7 Program (org.ethereum.vm.program.Program)5 ProgramInvokeMockImpl (org.ethereum.vm.program.invoke.ProgramInvokeMockImpl)5 Ignore (org.junit.Ignore)5 RskSystemProperties (co.rsk.config.RskSystemProperties)3 TrieImplHashTest (co.rsk.trie.TrieImplHashTest)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ECKey (org.ethereum.crypto.ECKey)3 RepositoryImpl (co.rsk.db.RepositoryImpl)2 TxsPerAccount (co.rsk.net.handler.TxsPerAccount)2 TrieStoreImpl (co.rsk.trie.TrieStoreImpl)2 HashMapDB (org.ethereum.datasource.HashMapDB)2