Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
Merge branch 'dev' into dev-hotfix-randomTip
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-e committed Jun 27, 2017
2 parents a8aac96 + a1db258 commit bb72c64
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ script: mvn package -P build-extras
deploy:
- provider: releases
api_key:
secure: l80FJQ+9Kk+ZYZxXcfagFGgnrp8BlnSZNCDv9KqbWYWQ4YL83qULlD1xgewUcEZhxbddR4nIo/gB1HxrdUxyjzHQKd1ysQ54BH9ZM51MqAtmzslz1gg6WNIDElugsY484W/ynAOQ286tq/5Y4bsAtmHaNzRLlf0sUfW1evXVBNFTz+0eLinqd/r0cC6bEFVk0TWXtk2+EcfTsowkyA36QNZhA+l0ti7GpJj5ubG4cd7hO7ktY4yQ130zJ4zrvv9aL6OwpFULGPDSV/wWujxcZm8GlLrJc2kWAHPLfQESt1Vr9ze2P/8n2FPyh9G67KemS8ubdp5XQPTZKALv4a7Zw8QBhJoahFptkqofgxQkDreCWlgwQyJvmfIJ7pFYXzGsdKUsd4aop6EhT44e2vJuYQBI+EUmx9HiW5+tQPsRkwWqyPyfchHu7KCpqGnImkDTjIHHJinB9dyEdQUbkGVVDWv3n8jNXas5IijS6YvMH5PVt6bWwcbAmijrY+a6E7kf/siJHNNyK/uBTL6FZIkkL2jcH6USgrt2KI/xIoBng1c1w000ctGQcXVGUjeURqQeHclLLpst2Td0uR6SgAGLEOxjeQ9ghzQWC/4x9BPW7xf7SkxhESWB2MMTvxma8xaV7hmNSsUK7tHyMLZPGdhDnPuUx2E6eNG4IZzUvcmHI4U=
#secure: l80FJQ+9Kk+ZYZxXcfagFGgnrp8BlnSZNCDv9KqbWYWQ4YL83qULlD1xgewUcEZhxbddR4nIo/gB1HxrdUxyjzHQKd1ysQ54BH9ZM51MqA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/3C0XNf29t+s/r1jat8fwWp8Gf7GiCaJEYG9VO24Chhi+MZCKBJnmx5G/98zvLw3f6a1FsEGZrw9RhF2vJKK6sD3rIvNkUsYmf0OhM7bf0NceFMGTJ/mFzM/JX0OHMtIyAvUfyyPVbQkIHNcGBgQMZasx07K3fjcn2lqv4FbHVi3HbdM="
file_glob: true
file: target/*.jar*
skip_cleanup: true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM java:8

CMD ["/usr/bin/java", "-jar", "iri-1.2.0.jar"]
CMD ["/usr/bin/java", "-jar", "iri-1.2.1.jar"]
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.2.1
- cleaner API messaging

1.2.0
- Mainnet release with MWM 15
- Snapshot
Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.iota</groupId>
<artifactId>iri</artifactId>
<name>IRI</name>
<version>1.2.0</version>
<version>1.2.1</version>
<description>IOTA Reference Implementation</description>
<scm>
<connection>scm:git:git://github.com/iotaledger/iri.git</connection>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.iota</groupId>
<artifactId>iri</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>

<name>IRI</name>
<description>IOTA Reference Implementation</description>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/iota/iri/IRI.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class IRI {

public static final String MAINNET_NAME = "IRI";
public static final String TESTNET_NAME = "IRI Testnet";
public static final String VERSION = "1.2.0";
public static final String VERSION = "1.2.1";
public static Iota iota;
public static API api;
public static IXI ixi;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/iota/iri/conf/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public enum DefaultConfSettings {
RESCAN_DB,
MAX_RANDOM_WALKS,
MAX_FIND_TRANSACTIONS,
MAX_GET_TRYTES,
MAX_DEPTH,
MAINNET_MWM,
TESTNET_MWM,
Expand Down Expand Up @@ -91,6 +92,7 @@ public enum DefaultConfSettings {
conf.put(DefaultConfSettings.MAX_DEPTH.name(), "15");

conf.put(DefaultConfSettings.MAX_FIND_TRANSACTIONS.name(), "100000");
conf.put(DefaultConfSettings.MAX_GET_TRYTES.name(), "10000");

}

Expand Down
33 changes: 24 additions & 9 deletions src/main/java/com/iota/iri/service/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -97,6 +96,7 @@ public class API {

private final int maxRandomWalks;
private final int maxFindTxs;
private final int maxGetTrytes;

private final static char ZERO_LENGTH_ALLOWED = 'Y';
private final static char ZERO_LENGTH_NOT_ALLOWED = 'N';
Expand All @@ -107,6 +107,7 @@ public API(Iota instance, IXI ixi) {
this.ixi = ixi;
maxRandomWalks = instance.configuration.integer(DefaultConfSettings.MAX_RANDOM_WALKS);
maxFindTxs = instance.configuration.integer(DefaultConfSettings.MAX_FIND_TRANSACTIONS);
maxGetTrytes = instance.configuration.integer(DefaultConfSettings.MAX_GET_TRYTES);

}

Expand Down Expand Up @@ -201,7 +202,12 @@ private AbstractResponse process(final String requestString, InetSocketAddress s
}
final Hash trunkTransaction = new Hash((String) request.get("trunkTransaction"));
final Hash branchTransaction = new Hash((String) request.get("branchTransaction"));
final int minWeightMagnitude = ((Double) request.get("minWeightMagnitude")).intValue();
final int minWeightMagnitude;
try {
minWeightMagnitude = ((Double) request.get("minWeightMagnitude")).intValue();
} catch (ClassCastException e) {
return ErrorResponse.create("Invalid minWeightMagnitude input");
}
final List<String> trytes = (List<String>) request.get("trytes");
for (final String tryt : trytes) {
if (!validTrytes(tryt, TRYTES_SIZE, ZERO_LENGTH_NOT_ALLOWED)) {
Expand Down Expand Up @@ -287,7 +293,12 @@ private AbstractResponse process(final String requestString, InetSocketAddress s
return getTipsStatement();
}
case "getTransactionsToApprove": {
final int depth = ((Double) request.get("depth")).intValue();
final int depth;
try {
depth = ((Double) request.get("depth")).intValue();
} catch (ClassCastException e) {
return ErrorResponse.create("Invalid depth input");
}
final Object referenceObj = request.get("reference");
final String reference = referenceObj == null? null: (String) referenceObj;
if (invalidSubtangleStatus()) {
Expand All @@ -311,7 +322,7 @@ private AbstractResponse process(final String requestString, InetSocketAddress s
return ErrorResponse.create("Wrong arguments");
}
for (final String hash : hashes) {
if (!validTrytes(hash, HASH_SIZE, ZERO_LENGTH_ALLOWED)) {
if (!validTrytes(hash, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) {
return ErrorResponse.create("Invalid hash input");
}
}
Expand Down Expand Up @@ -389,14 +400,17 @@ private AbstractResponse removeNeighborsStatement(List<String> uris) throws URIS
return RemoveNeighborsResponse.create(numberOfRemovedNeighbors.get());
}

private AbstractResponse getTrytesStatement(List<String> hashes) throws Exception {
private synchronized AbstractResponse getTrytesStatement(List<String> hashes) throws Exception {
final List<String> elements = new LinkedList<>();
for (final String hash : hashes) {
final TransactionViewModel transactionViewModel = TransactionViewModel.fromHash(instance.tangle, new Hash(hash));
if (transactionViewModel != null) {
elements.add(Converter.trytes(transactionViewModel.trits()));
}
}
if (elements.size() > maxGetTrytes){
return ErrorResponse.create("Could not complete request");
}
return GetTrytesResponse.create(elements);
}

Expand Down Expand Up @@ -566,7 +580,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map<String,

if (request.containsKey("bundles")) {
for (final String bundle : (List<String>) request.get("bundles")) {
if (!validTrytes(bundle, HASH_SIZE, ZERO_LENGTH_ALLOWED)) {
if (!validTrytes(bundle, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) {
return ErrorResponse.create("Invalid bundle hash");
}
bundlesTransactions.addAll(BundleViewModel.load(instance.tangle, new Hash(bundle)).getHashes());
Expand All @@ -579,7 +593,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map<String,
log.debug("Searching: {}", addresses.stream().reduce((a, b) -> a += ',' + b));

for (final String address : addresses) {
if (!validTrytes(address, HASH_SIZE, ZERO_LENGTH_ALLOWED)) {
if (!validTrytes(address, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) {
return ErrorResponse.create("Invalid address input");
}
addressesTransactions.addAll(AddressViewModel.load(instance.tangle, new Hash(address)).getHashes());
Expand All @@ -589,7 +603,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map<String,
final Set<Hash> tagsTransactions = new HashSet<>();
if (request.containsKey("tags")) {
for (String tag : (List<String>) request.get("tags")) {
if (!validTrytes(tag,tag.length(), ZERO_LENGTH_ALLOWED)) {
if (!validTrytes(tag,tag.length(), ZERO_LENGTH_NOT_ALLOWED)) {
return ErrorResponse.create("Invalid tag input");
}
while (tag.length() < Curl.HASH_LENGTH / Converter.NUMBER_OF_TRITS_IN_A_TRYTE) {
Expand All @@ -603,7 +617,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map<String,

if (request.containsKey("approvees")) {
for (final String approvee : (List<String>) request.get("approvees")) {
if (!validTrytes(approvee,HASH_SIZE, ZERO_LENGTH_ALLOWED)) {
if (!validTrytes(approvee,HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) {
return ErrorResponse.create("Invalid approvees hash");
}
approveeTransactions.addAll(TransactionViewModel.fromHash(instance.tangle, new Hash(approvee)).getApprovers(instance.tangle).getHashes());
Expand Down Expand Up @@ -772,6 +786,7 @@ private AbstractResponse addNeighborsStatement(final List<String> uris) throws U
final URI uri = new URI(uriString);

if ("udp".equals(uri.getScheme()) || "tcp".equals(uri.getScheme())) {
log.info("Adding neighbor: "+uriString);
// 3rd parameter true if tcp, 4th parameter true (configured tethering)
final Neighbor neighbor;
switch(uri.getScheme()) {
Expand Down

0 comments on commit bb72c64

Please sign in to comment.