Skip to content

Commit

Permalink
- auto build distribution zip
Browse files Browse the repository at this point in the history
- loading stats data in smaller parts (to prevent timeout)
  • Loading branch information
de-luxe committed Sep 11, 2016
1 parent 76b4015 commit 5d2aa58
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 8 deletions.
54 changes: 49 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>

<name>burstcoin-faucet</name>
<groupId>burstcoin</groupId>
<artifactId>burstcoin-faucet</artifactId>
<version>0.3.3-RELEASE</version>
<version>0.3.4-RELEASE</version>

<properties>
<java.version>1.8</java.version>
<main.basedir>${basedir}/../..</main.basedir>
<bcprov-jdk15on.version>1.51</bcprov-jdk15on.version>
<bcprov-jdk15on.version>1.55</bcprov-jdk15on.version>
<recaptcha-spring-boot-starter.version>1.3.5</recaptcha-spring-boot-starter.version>
</properties>

Expand Down Expand Up @@ -92,10 +92,54 @@

<build>
<plugins>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-clear</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- clear dist dir -->
<delete dir="${project.basedir}/dist"/>
<mkdir dir="${project.basedir}/dist"/>
<mkdir dir="${project.basedir}/dist/tmp"/>
</target>
</configuration>
</execution>
<execution>
<id>ant-zip</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy file="${project.basedir}/target/${project.build.finalName}.jar" tofile="${project.basedir}/dist/tmp/${project.build.finalName}.jar"/>
<copy file="${project.basedir}/faucet.default.properties" tofile="${project.basedir}/dist/tmp/faucet.properties"/>
<copy file="${project.basedir}/LICENSE.md" tofile="${project.basedir}/dist/tmp/LICENSE.txt"/>
<copy file="${project.basedir}/README.md" tofile="${project.basedir}/dist/tmp/README.txt"/>
<copy file="${project.basedir}/run.bat" tofile="${project.basedir}/dist/tmp/run.sh"/>
<copy file="${project.basedir}/run.bat" tofile="${project.basedir}/dist/tmp/run.bat"/>
<!-- create zip file -->
<zip destfile="${project.basedir}/dist/${project.build.finalName}.zip" basedir="${project.basedir}/dist/tmp"/>
</target>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
1 change: 1 addition & 0 deletions run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar burstcoin-faucet-0.3.4-RELEASE.jar
25 changes: 23 additions & 2 deletions src/main/java/burstcoin/faucet/controller/FaucetController.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -391,8 +392,29 @@ private IPAddress getIPAddress(String ip)

private StatsData getStatsData(String accountId)
{
Map<String, Transaction> transactions = networkComponent.getTransactions(accountId);
Map<String, Transaction> transactions = new HashMap<>();
boolean hasMoreTransactions = true;
int offset = 0;
int transactionsPerRequest = 1999;
while(hasMoreTransactions)
{
Map<String, Transaction> temp = networkComponent.getTransactions(accountId, offset, transactionsPerRequest);
if(temp != null && !temp.isEmpty())
{
hasMoreTransactions = temp.size() >= transactionsPerRequest;
transactions.putAll(temp);
offset += transactionsPerRequest;
}
else
{
LOG.warn("Failed to get Transactions ...");
}
}
return generateStatsData(accountId, transactions);
}

private StatsData generateStatsData(String accountId, Map<String, Transaction> transactions)
{
StatsData data = new StatsData();

for(Transaction transaction : transactions.values())
Expand Down Expand Up @@ -449,7 +471,6 @@ private StatsData getStatsData(String accountId)
{
data.getDonateLookup().remove(other);
}

return data;
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/burstcoin/faucet/network/NetworkComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public SendMoneyResponse sendMoney(int amount, String recipientId, String secret
return sendMoneyResponse;
}

public Map<String, Transaction> getTransactions(String accountId)
public Map<String, Transaction> getTransactions(String accountId, int offset, int transactionsPerRequest)
{
Map<String, Transaction> transactionLookup = null;
try
Expand All @@ -99,6 +99,8 @@ public Map<String, Transaction> getTransactions(String accountId)

Request request = httpClient.POST(BURST_API_URL)
.param("requestType", "getAccountTransactions")
.param("firstIndex", String.valueOf(offset))
.param("lastIndex", String.valueOf(offset + transactionsPerRequest))
.param("account", accountId);
request.send(listener);

Expand Down

0 comments on commit 5d2aa58

Please sign in to comment.