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

Commit

Permalink
IRI-329 ⁃ readPreviousEpochsSpentAddresses should only run on mainn…
Browse files Browse the repository at this point in the history
…et (#630)

`readPreviousEpochsSpentAddresses` should only run on mainnet
  • Loading branch information
GalRogozinski authored Apr 18, 2018
1 parent 1337870 commit 16e5a34
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/iota/iri/service/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public API(Iota instance, IXI ixi) {
}

public void init() throws IOException {
readPreviousEpochsSpentAddresses();
readPreviousEpochsSpentAddresses(testNet);

final int apiPort = instance.configuration.integer(DefaultConfSettings.PORT);
final String apiHost = instance.configuration.string(DefaultConfSettings.API_HOST);
Expand Down Expand Up @@ -145,14 +145,18 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
server.start();
}

private void readPreviousEpochsSpentAddresses() {
private void readPreviousEpochsSpentAddresses(boolean isTestnet) {
if (isTestnet) {
return;
}

if (!SignedFiles.isFileSignatureValid(Configuration.PREVIOUS_EPOCHS_SPENT_ADDRESSES_TXT,
Configuration.PREVIOUS_EPOCH_SPENT_ADDRESSES_SIG,
Snapshot.SNAPSHOT_PUBKEY, Snapshot.SNAPSHOT_PUBKEY_DEPTH, Snapshot.SPENT_ADDRESSES_INDEX)) {
throw new RuntimeException("Failed to load previousEpochsSpentAddresses - signature failed.");
}

InputStream in = Snapshot.class.getResourceAsStream("/previousEpochsSpentAddresses.txt");
InputStream in = Snapshot.class.getResourceAsStream(Configuration.PREVIOUS_EPOCHS_SPENT_ADDRESSES_TXT);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
try {
Expand Down

0 comments on commit 16e5a34

Please sign in to comment.