@ApiAudience.Public @ApiStability.Unstable public class SimpleNonceProvider extends java.lang.Object implements NonceProvider
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<AccountAddress,java.lang.Long> |
address2Nonce |
Constructor and Description |
---|
SimpleNonceProvider()
SimpleNonceProvider constructor.
|
SimpleNonceProvider(int capacity)
SimpleNonceProvider constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
bindNonce(AccountAddress accountAddress,
long nonce)
Bind nonce to
accountAddress . |
void |
bindNonce(AccountState accountState)
Bind nonce of
accountState with accountAddress of accountState . |
long |
getLastUsedNonce(AccountAddress accountAddress)
Get last used nonce of
accountAddress . |
long |
incrementAndGetNonce(AccountAddress accountAddress)
Increment nonce of
accountAddress get it. |
protected final java.util.Map<AccountAddress,java.lang.Long> address2Nonce
public SimpleNonceProvider()
public SimpleNonceProvider(int capacity)
capacity
- a number of account to holdpublic void bindNonce(AccountState accountState)
NonceProvider
accountState
with accountAddress of accountState
. The operation
must be thread-safe.bindNonce
in interface NonceProvider
accountState
- an account statepublic void bindNonce(AccountAddress accountAddress, long nonce)
NonceProvider
accountAddress
. Next time nonce is required, it will be provided on base
of passed nonce. The operation must be thread-safe.bindNonce
in interface NonceProvider
accountAddress
- an account addressnonce
- an noncepublic long incrementAndGetNonce(AccountAddress accountAddress)
NonceProvider
accountAddress
get it. If an nonce of accountAddress
is not
binded yet, it will be treated as new account (nonce starts from 0). The operation must be
thread-safe.incrementAndGetNonce
in interface NonceProvider
accountAddress
- an accountAddresspublic long getLastUsedNonce(AccountAddress accountAddress)
NonceProvider
accountAddress
. If an nonce of accountAddress
is not
binded yet, it will be treated as new account (nonce starts from 0). The operation must be
thread-safe.getLastUsedNonce
in interface NonceProvider
accountAddress
- an accountAddress