Skip to content

Commit c195d2c

Browse files
committed
added new env with challengeExpire long value
1 parent 4ecc1f8 commit c195d2c

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/main/java/runHyperties/StartJavaHyperties.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ public void start() throws Exception {
117117
e.printStackTrace();
118118
}
119119
System.out.println("SIOT_POC:" + pointOfContact);
120+
121+
String challengeExpireStr = "1577750400000"; //31-12-2019
122+
long challengeExpire = Long.valueOf(challengeExpireStr);
123+
try {
124+
String envChallengeExpire = System.getenv("CHALLENGE_EXPIRE");
125+
if (envChallengeExpire != null) {
126+
challengeExpire = Long.valueOf(envChallengeExpire);
127+
}
128+
} catch (Exception e) {
129+
e.printStackTrace();
130+
}
131+
132+
120133

121134
String checkINHypertyURL = "hyperty://sharing-cities-dsm/checkin-rating";
122135
String userActivityHypertyURL = "hyperty://sharing-cities-dsm/user-activity";
@@ -380,6 +393,7 @@ public void start() throws Exception {
380393
configWalletManager.put("rankingTimer", 30000);
381394
configWalletManager.put("onReadMaxTransactions", 100);
382395
configWalletManager.put("engageRating", 50);
396+
configWalletManager.put("challengeExpire", challengeExpire);
383397

384398

385399
// public wallets

src/main/java/walletManager/WalletManagerHyperty.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public class WalletManagerHyperty extends AbstractHyperty {
6262
private static final int initialBalance = 50;
6363

6464
private static int engageRating;
65+
private static long challengeExpire;
6566

6667
@Override
6768
public void start() {
@@ -75,6 +76,8 @@ public void start() {
7576
int rankingTimer = config().getInteger("rankingTimer");
7677
onReadMaxTransactions = config().getInteger("onReadMaxTransactions");
7778
engageRating = config().getInteger("engageRating");
79+
challengeExpire = config().getLong("challengeExpire");
80+
7881

7982
if (publicWallets != null) {
8083
createPublicWallets(publicWallets);
@@ -1305,12 +1308,20 @@ private void validateTransaction(JsonObject transaction, String walletAddress) {
13051308
Future<Void> updatedTransaction = transferToPrivateWallet(walletAddress, transaction);
13061309

13071310
updatedTransaction.setHandler(asyncResult -> {
1308-
String publicWalletAddress = wallet.getString(causeWalletAddress);
1309-
if (publicWalletAddress != null) {
1310-
// update wallet2bGranted balance
1311-
transferToPublicWallet(publicWalletAddress, transaction);
1311+
1312+
1313+
Long currentTime = new Date().getTime();
1314+
logger.debug(" current:" + currentTime +"\n challengeExpire:"+challengeExpire);
1315+
if(currentTime < challengeExpire) {
1316+
String publicWalletAddress = wallet.getString(causeWalletAddress);
1317+
if (publicWalletAddress != null) {
1318+
// update wallet2bGranted balance
1319+
transferToPublicWallet(publicWalletAddress, transaction);
1320+
}
1321+
} else {
1322+
logger.debug("challengeExpire");
13121323
}
1313-
1324+
13141325
});
13151326

13161327
// check if nonce is repeated

0 commit comments

Comments
 (0)