Created
January 31, 2017 19:28
-
-
Save conor10/397f79440e808e3cf54132c9276937fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.web3j.tx; | |
| import java.math.BigInteger; | |
| import java.util.concurrent.ExecutionException; | |
| import org.web3j.crypto.Credentials; | |
| import org.web3j.protocol.Web3j; | |
| public class FastRawTransactionManager extends RawTransactionManager { | |
| private BigInteger nonce = BigInteger.valueOf(-1); | |
| public FastRawTransactionManager(Web3j web3j, Credentials credentials, byte chainId) { | |
| super(web3j, credentials, chainId); | |
| } | |
| public FastRawTransactionManager(Web3j web3j, Credentials credentials) { | |
| super(web3j, credentials); | |
| } | |
| @Override | |
| synchronized BigInteger getNonce(String address) throws InterruptedException, ExecutionException { | |
| if (nonce.signum() == -1) { | |
| nonce = super.getNonce(address); | |
| } else { | |
| nonce = nonce.add(BigInteger.ONE); | |
| } | |
| return nonce; | |
| } | |
| public BigInteger getCurrentNonce() { | |
| return nonce; | |
| } | |
| public synchronized void resetNonce(String address) throws InterruptedException, ExecutionException { | |
| nonce = super.getNonce(address); | |
| } | |
| public synchronized void setNonce(BigInteger value) { | |
| nonce = value; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment