|
30 | 30 | import org.web3j.tuples.generated.Tuple3; |
31 | 31 | import org.web3j.tx.RawTransactionManager; |
32 | 32 | import org.web3j.tx.gas.ContractGasProvider; |
| 33 | +import org.web3j.tx.response.PollingTransactionReceiptProcessor; |
33 | 34 | import org.web3j.utils.Numeric; |
34 | 35 |
|
35 | 36 | import java.io.IOException; |
|
41 | 42 | import static com.iexec.commons.poco.encoding.AccessorsEncoder.*; |
42 | 43 | import static com.iexec.commons.poco.tee.TeeEnclaveConfiguration.buildEnclaveConfigurationFromJsonString; |
43 | 44 | import static com.iexec.commons.poco.utils.BytesUtils.isNonZeroedBytes32; |
44 | | -import static org.web3j.tx.TransactionManager.DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH; |
45 | | - |
46 | 45 |
|
47 | 46 | /* |
48 | 47 | * Contracts (located at *.contract.generated) which are used in this service are generated from: |
|
52 | 51 | @Slf4j |
53 | 52 | public abstract class IexecHubAbstractService { |
54 | 53 |
|
| 54 | + public static final int POLLING_ATTEMPTS_PER_TX_HASH = 12; |
55 | 55 | public static final int NB_BLOCKS_TO_WAIT_PER_RETRY = 6; |
56 | 56 | public static final int MAX_RETRIES = 3; |
57 | 57 |
|
58 | 58 | protected final Credentials credentials; |
59 | 59 | private final String iexecHubAddress; |
60 | | - private final RawTransactionManager txManager; |
61 | | - protected IexecHubContract iexecHubContract; |
| 60 | + protected final RawTransactionManager txManager; |
| 61 | + protected final PollingTransactionReceiptProcessor txReceiptProcessor; |
| 62 | + protected final IexecHubContract iexecHubContract; |
62 | 63 | private final Web3jAbstractService web3jAbstractService; |
63 | 64 | private long maxNbOfPeriodsForConsensus = -1; |
64 | 65 | private final long retryDelay;// ms |
@@ -94,12 +95,17 @@ protected IexecHubAbstractService( |
94 | 95 | this.retryDelay = nbBlocksToWaitPerRetry * this.web3jAbstractService.getBlockTime().toMillis(); |
95 | 96 | this.maxRetries = maxRetries; |
96 | 97 |
|
| 98 | + txReceiptProcessor = new PollingTransactionReceiptProcessor( |
| 99 | + web3jAbstractService.getWeb3j(), |
| 100 | + web3jAbstractService.getBlockTime().toMillis(), |
| 101 | + POLLING_ATTEMPTS_PER_TX_HASH |
| 102 | + ); |
| 103 | + |
97 | 104 | txManager = new RawTransactionManager( |
98 | 105 | web3jAbstractService.getWeb3j(), |
99 | 106 | credentials, |
100 | 107 | web3jAbstractService.getChainId(), |
101 | | - DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH, |
102 | | - web3jAbstractService.getBlockTime().toMillis() |
| 108 | + txReceiptProcessor |
103 | 109 | ); |
104 | 110 |
|
105 | 111 | iexecHubContract = getHubContract(web3jAbstractService.getContractGasProvider()); |
|
0 commit comments