diff --git a/pom.xml b/pom.xml
index 6d414e2..95ee334 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
burstcoin-faucet
burstcoin
burstcoin-faucet
- 0.2.0-SNAPSHOT
+ 0.2.0-RELEASE
1.8
diff --git a/src/main/java/burstcoin/faucet/controller/FaucetController.java b/src/main/java/burstcoin/faucet/controller/FaucetController.java
index bebac0f..6d62233 100644
--- a/src/main/java/burstcoin/faucet/controller/FaucetController.java
+++ b/src/main/java/burstcoin/faucet/controller/FaucetController.java
@@ -101,7 +101,7 @@ public String index(Model model)
model.addAttribute("faucetBalance", (Long.valueOf(balance.getUnconfirmedBalanceNQT()) / 100000000) + " BURST");
model.addAttribute("reCaptchaPublicKey", BurstcoinFaucetProperties.getPublicKey());
- if(lastStatsUpdate == null || lastStatsUpdate.getTime() < new Date().getTime() - (1000 * 60 /* 30 sec. */))
+ if(lastStatsUpdate == null || lastStatsUpdate.getTime() < new Date().getTime() - (1000 * 60 * 5 /* 5 minutes */))
{
stats = getStats(numericFaucetAccountId);
lastStatsUpdate = new Date();
@@ -146,53 +146,62 @@ public String claim(@RequestParam("accountId") String accountId, HttpServletRequ
}
}
- // get client ip
- String ip = request.getHeader("X-FORWARDED-FOR");
- if(ip == null)
- {
- ip = request.getRemoteAddr();
- }
-
- IPAddress ipAddress = null;
- if(ip != null)
+ // check account
+ Account account = getAccount(accountId);
+ if(account.getLastClaim() == null || new Date().getTime() > (account.getLastClaim().getTime() + claimInterval))
{
- ipAddress = getIPAddress(ip);
- }
- boolean ipCanClaim = ipAddress == null || ipAddress.getLastClaim() == null || new Date().getTime() > (ipAddress.getLastClaim().getTime() + claimInterval);
+ // check ip
+ String ip = request.getHeader("X-FORWARDED-FOR");
+ if(ip == null)
+ {
+ ip = request.getRemoteAddr();
+ }
- Account account = getAccount(accountId);
- boolean addressCanClaim = account.getLastClaim() == null || new Date().getTime() > (account.getLastClaim().getTime() + claimInterval);
+ IPAddress ipAddress = null;
+ if(ip != null)
+ {
+ ipAddress = getIPAddress(ip);
+ }
- if(ipCanClaim && addressCanClaim)
- {
- if(recaptchaValidator.validate(request).isSuccess())
+ if(ipAddress == null || ipAddress.getLastClaim() == null || new Date().getTime() > (ipAddress.getLastClaim().getTime() + claimInterval))
{
- SendMoneyResponse sendMoneyResponse = networkComponent
- .sendMoney(BurstcoinFaucetProperties.getClaimAmount(), accountId, BurstcoinFaucetProperties.getPassPhrase());
- if(sendMoneyResponse != null)
+ // check recaptcha
+ if(recaptchaValidator.validate(request).isSuccess())
{
- if(ipAddress != null)
+ SendMoneyResponse sendMoneyResponse = networkComponent.sendMoney(BurstcoinFaucetProperties.getClaimAmount(), accountId,
+ BurstcoinFaucetProperties.getPassPhrase());
+ if(sendMoneyResponse != null)
{
- ipAddress.setLastClaim(new Date());
- ipAddressRepository.save(ipAddress);
- }
+ // update ip
+ if(ipAddress != null)
+ {
+ ipAddress.setLastClaim(new Date());
+ ipAddressRepository.save(ipAddress);
+ }
- account.setLastClaim(new Date());
- accountRepository.save(account);
+ // update account
+ account.setLastClaim(new Date());
+ accountRepository.save(account);
- return "redirect:/?success=" + BurstcoinFaucetProperties.getClaimAmount() + " BURST send to " + account.getAccountId();
- }
- else
- {
- return "redirect:/?error=Sry, faucet could not access Wallet, to send your BURST.";
+ return "redirect:/?success=" + BurstcoinFaucetProperties.getClaimAmount() + " BURST send to " + account.getAccountId();
+ }
+ else
+ {
+ return "redirect:/?error=Sry, faucet could not access Wallet, to send your BURST.";
+ }
}
}
+ else
+ {
+ long ipTime = (ipAddress.getLastClaim().getTime() + claimInterval) - new Date().getTime();
+ return "redirect:/?error=No BURST send. Please wait at least " + ((ipTime) / (60 * 1000))
+ + " minutes, before claim again with your accounts.";
+ }
}
else
{
long accountTime = (account.getLastClaim().getTime() + claimInterval) - new Date().getTime();
- long ipTime = (ipAddress.getLastClaim().getTime() + claimInterval) - new Date().getTime();
- return "redirect:/?error=No BURST send. Please wait at least " + ((ipTime > accountTime ? ipTime : accountTime) / (60 * 1000))
+ return "redirect:/?error=No BURST send. Please wait at least " + ((accountTime) / (60 * 1000))
+ " minutes, before claim again.";
}
return "redirect:/?error=Unexpected problem ... could not send BURST.";
diff --git a/src/main/java/burstcoin/faucet/network/NetworkComponent.java b/src/main/java/burstcoin/faucet/network/NetworkComponent.java
index ceefe04..fd8d0c8 100644
--- a/src/main/java/burstcoin/faucet/network/NetworkComponent.java
+++ b/src/main/java/burstcoin/faucet/network/NetworkComponent.java
@@ -152,8 +152,7 @@ public Balance getBalance(String accountId)
}
catch(Exception e)
{
- LOG.warn("Error: Failed to 'getBalance' for accountId '" + accountId + "' : " + e.getMessage());
-
+ LOG.warn("Error: Failed to 'getBalance' for accountId '" + accountId + "' : " + e.getMessage(), e);
}
return balance;
}