use of org.ethereum.core.AccountState in project rskj by rsksmart.
the class RepositoryImpl method loadAccount.
@Override
public synchronized void loadAccount(RskAddress addr, Map<RskAddress, AccountState> cacheAccounts, Map<RskAddress, ContractDetails> cacheDetails) {
AccountState account = getAccountState(addr);
ContractDetails details = getContractDetails(addr);
account = (account == null) ? new AccountState() : account.clone();
details = new ContractDetailsCacheImpl(details);
cacheAccounts.put(addr, account);
cacheDetails.put(addr, details);
}
use of org.ethereum.core.AccountState in project rskj by rsksmart.
the class RepositoryImpl method hibernate.
@Override
public synchronized void hibernate(RskAddress addr) {
AccountState account = getAccountStateOrCreateNew(addr);
account.hibernate();
updateAccountState(addr, account);
}
use of org.ethereum.core.AccountState in project rskj by rsksmart.
the class RepositoryImpl method createAccount.
@Override
public synchronized AccountState createAccount(RskAddress addr) {
AccountState accountState = new AccountState();
updateAccountState(addr, accountState);
updateContractDetails(addr, new ContractDetailsImpl(config));
return accountState;
}
use of org.ethereum.core.AccountState in project rskj by rsksmart.
the class RepositoryImpl method increaseNonce.
@Override
public synchronized BigInteger increaseNonce(RskAddress addr) {
AccountState account = getAccountStateOrCreateNew(addr);
account.incrementNonce();
updateAccountState(addr, account);
return account.getNonce();
}
use of org.ethereum.core.AccountState in project rskj by rsksmart.
the class TxBuilder method simulateTxs.
public void simulateTxs() {
key = ECKey.fromPrivate(privateKeyBytes);
new Thread() {
@Override
public void run() {
try {
Thread.sleep(60000);
while (blockProcessor.hasBetterBlockToSync()) {
Thread.sleep(60000);
}
SecureRandom random = new SecureRandom();
RskAddress addr = new RskAddress(key.getAddress());
AccountState accountState = repository.getAccountState(addr);
BigInteger nonce = accountState.getNonce();
while (!stop) {
if ((random.nextInt() % 10) == 0) {
nonce = repository.getAccountState(addr).getNonce();
}
TxBuilder.this.createNewTx(nonce);
Thread.sleep(random.nextInt(51000));
nonce = nonce.add(BigInteger.ONE);
}
} catch (InterruptedException e) {
logger.error("TxBuild Thread was interrupted", e);
Thread.currentThread().interrupt();
return;
}
}
}.start();
}
Aggregations