Skip to content

Commit 1eed1ff

Browse files
authored
Merge pull request #55 from iExecBlockchainComputing/bugfix/remove-dead-code
Remove dead code in `IexecHubAbstractService` and `Web3jbstractService`
2 parents 069e352 + cc7733d commit 1eed1ff

File tree

3 files changed

+1
-52
lines changed

3 files changed

+1
-52
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file.
1111
- Do not run tests in `itest` task to avoid executing them twice. (#47)
1212
- Upgrade to Gradle 8.2.1 with up-to-date plugins. (#49)
1313
- Fetch contribution deadline ratio during `@PostConstruct` execution in `IexecHubAbstractService`. (#51)
14-
- Remove dead code in `IexecHubAbstractService`. (#54)
14+
- Remove dead code in `IexecHubAbstractService` and `Web3jAbstractService`. (#54 #55)
1515
### Dependency Upgrades
1616
- Upgrade to Spring Boot 2.7.14. (#48)
1717
- Upgrade to `testcontainers` 1.19.0. (#50)

src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,35 +1035,6 @@ public boolean hasEnoughGas(String address) {
10351035
return web3jAbstractService.hasEnoughGas(address);
10361036
}
10371037

1038-
1039-
protected boolean isStatusValidOnChainAfterPendingReceipt(String chainTaskId,
1040-
ChainStatus onchainStatus,
1041-
BiFunction<String, ChainStatus, Boolean> isStatusValidOnChainFunction) {
1042-
long maxWaitingTime = web3jAbstractService.getMaxWaitingTimeWhenPendingReceipt();
1043-
log.info("Waiting for on-chain status after pending receipt " +
1044-
"[chainTaskId:{}, status:{}, maxWaitingTime:{}]",
1045-
chainTaskId, onchainStatus, maxWaitingTime);
1046-
1047-
final long startTime = System.currentTimeMillis();
1048-
long duration = 0;
1049-
while (duration < maxWaitingTime) {
1050-
try {
1051-
if (isStatusValidOnChainFunction.apply(chainTaskId, onchainStatus)) {
1052-
return true;
1053-
}
1054-
Thread.sleep(500);
1055-
} catch (InterruptedException e) {
1056-
log.error("Error in checking the latest block number", e);
1057-
}
1058-
duration = System.currentTimeMillis() - startTime;
1059-
}
1060-
1061-
log.error("Timeout reached after waiting for on-chain status " +
1062-
"[chainTaskId:{}, maxWaitingTime:{}]",
1063-
chainTaskId, maxWaitingTime);
1064-
return false;
1065-
}
1066-
10671038
/*
10681039
* Behaves as a cache to avoid always calling blockchain to retrieve task description
10691040
*

src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,28 +181,6 @@ public boolean isBlockAvailable(long blockNumber) {
181181
return false;
182182
}
183183

184-
public long getMaxWaitingTimeWhenPendingReceipt() {
185-
long maxWaitingTime = 2 * 60 * 1000L; // 2min
186-
187-
// max waiting Time should be roughly the time of 10 blocks
188-
try {
189-
EthBlock.Block latestBlock = getLatestBlock();
190-
191-
long latestBlockNumber = latestBlock.getNumber().longValue();
192-
193-
BigInteger latestBlockTimestamp = latestBlock.getTimestamp();
194-
BigInteger tenBlocksAgoTimestamp = getBlock(latestBlockNumber - 10).getTimestamp();
195-
196-
maxWaitingTime = (latestBlockTimestamp.longValue() - tenBlocksAgoTimestamp.longValue()) * 1000;
197-
198-
log.info("[latestBlockTimestamp:{}, tenBlocksAgoTimestamp:{}, maxWaitingTime:{}]",
199-
latestBlockTimestamp, tenBlocksAgoTimestamp, maxWaitingTime);
200-
} catch (IOException e) {
201-
log.error("Error when computing max waiting time", e);
202-
}
203-
return maxWaitingTime;
204-
}
205-
206184
public long getAverageTimePerBlock() {//in ms
207185
long defaultTime = TransactionManager.DEFAULT_POLLING_FREQUENCY; // 15sec
208186
int NB_OF_BLOCKS = 10;

0 commit comments

Comments
 (0)