Search in sources :

Example 6 with InternalVmType

use of org.aion.base.InternalVmType in project aion by aionnetwork.

the class ExternalStateForAvm method getVmType.

private InternalVmType getVmType(AionAddress destination) {
    // will load contract into memory otherwise leading to consensus issues
    RepositoryCache track = repositoryCache.startTracking();
    AccountState accountState = track.getAccountState(destination);
    InternalVmType vm;
    if (accountState == null) {
        // the address doesn't exist yet, so it can be used by either vm
        vm = InternalVmType.EITHER;
    } else {
        vm = repositoryCache.getVMUsed(destination, accountState.getCodeHash());
        // UNKNOWN is returned when there was no contract information stored
        if (vm == InternalVmType.UNKNOWN) {
            // use the in-memory value
            vm = track.getVmType(destination);
        }
    }
    return vm;
}
Also used : InternalVmType(org.aion.base.InternalVmType) RepositoryCache(org.aion.base.db.RepositoryCache) AccountState(org.aion.base.AccountState)

Aggregations

InternalVmType (org.aion.base.InternalVmType)6 AccountState (org.aion.base.AccountState)5 RepositoryCache (org.aion.base.db.RepositoryCache)4 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AionAddress (org.aion.types.AionAddress)1 ByteArrayWrapper (org.aion.util.types.ByteArrayWrapper)1 Pair (org.apache.commons.lang3.tuple.Pair)1