From 16e5a34f5df16d7df2d2af30203bf61f88fc893c Mon Sep 17 00:00:00 2001 From: galrogo Date: Wed, 18 Apr 2018 11:08:10 +0300 Subject: [PATCH] =?UTF-8?q?IRI-329=20=E2=81=83=20`readPreviousEpochsSpentA?= =?UTF-8?q?ddresses`=20should=20only=20run=20on=20mainnet=20(#630)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `readPreviousEpochsSpentAddresses` should only run on mainnet --- src/main/java/com/iota/iri/service/API.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iota/iri/service/API.java b/src/main/java/com/iota/iri/service/API.java index c22688120c..26032bcda8 100644 --- a/src/main/java/com/iota/iri/service/API.java +++ b/src/main/java/com/iota/iri/service/API.java @@ -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); @@ -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 {