Java Code Examples for org.ethereum.core.AccountState#getNonce()

The following examples show how to use org.ethereum.core.AccountState#getNonce() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryImpl.java    From ethereumj with MIT License 5 votes vote down vote up
public BigInteger increaseNonce(byte[] addr) {
    AccountState state = getAccountState(addr);
    if (state == null) return BigInteger.ZERO;
    state.incrementNonce();

    if (logger.isDebugEnabled())
        logger.debug("Increment nonce:\n account:\t [{}]\n new nonce:\t [{}]",
                Hex.toHexString(addr), state.getNonce().longValue());

    accountStateDB.update(addr, state.getEncoded());
    return state.getNonce();
}
 
Example 2
Source File: RepositoryImpl.java    From nuls-v2 with MIT License 4 votes vote down vote up
@Override
public synchronized BigInteger increaseNonce(byte[] addr) {
    AccountState accountState = getOrCreateAccountState(addr);
    accountStateCache.put(addr, accountState.withIncrementedNonce());
    return accountState.getNonce();
}
 
Example 3
Source File: RepositoryImpl.java    From nuls-v2 with MIT License 4 votes vote down vote up
@Override
public synchronized BigInteger setNonce(byte[] addr, BigInteger nonce) {
    AccountState accountState = getOrCreateAccountState(addr);
    accountStateCache.put(addr, accountState.withNonce(nonce));
    return accountState.getNonce();
}
 
Example 4
Source File: RepositoryImpl.java    From nuls-v2 with MIT License 4 votes vote down vote up
@Override
public synchronized BigInteger getNonce(byte[] addr) {
    AccountState accountState = getAccountState(addr);
    return accountState == null ? config.getBlockchainConfig().getCommonConstants().getInitialNonce() :
            accountState.getNonce();
}
 
Example 5
Source File: RepositoryImpl.java    From nuls with MIT License 4 votes vote down vote up
@Override
public synchronized BigInteger increaseNonce(byte[] addr) {
    AccountState accountState = getOrCreateAccountState(addr);
    accountStateCache.put(addr, accountState.withIncrementedNonce());
    return accountState.getNonce();
}
 
Example 6
Source File: RepositoryImpl.java    From nuls with MIT License 4 votes vote down vote up
@Override
public synchronized BigInteger setNonce(byte[] addr, BigInteger nonce) {
    AccountState accountState = getOrCreateAccountState(addr);
    accountStateCache.put(addr, accountState.withNonce(nonce));
    return accountState.getNonce();
}
 
Example 7
Source File: RepositoryImpl.java    From nuls with MIT License 4 votes vote down vote up
@Override
public synchronized BigInteger getNonce(byte[] addr) {
    AccountState accountState = getAccountState(addr);
    return accountState == null ? config.getBlockchainConfig().getCommonConstants().getInitialNonce() :
            accountState.getNonce();
}
 
Example 8
Source File: RepositoryImpl.java    From ethereumj with MIT License 4 votes vote down vote up
public BigInteger getNonce(byte[] addr) {
    AccountState state = getAccountState(addr);
    if (state == null) return BigInteger.ZERO;
    return state.getNonce();
}