From 3283b61428e9247e13875582d3381d45d3ec2a9a Mon Sep 17 00:00:00 2001 From: "chris.orogvany" Date: Wed, 28 Mar 2018 20:58:51 -0700 Subject: [PATCH] Trivial: Fix possible NPE, typo fix NPE fix typo and filter payouts to exclude other files --- src/main/java/com/semuxpool/pool/Pool.java | 2 +- .../java/com/semuxpool/pool/block/BlockResultFactory.java | 5 ++++- .../com/semuxpool/pool/persistence/JsonPersistence.java | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/semuxpool/pool/Pool.java b/src/main/java/com/semuxpool/pool/Pool.java index 73f32a3..8eee14e 100644 --- a/src/main/java/com/semuxpool/pool/Pool.java +++ b/src/main/java/com/semuxpool/pool/Pool.java @@ -189,7 +189,7 @@ private boolean shouldPay(long currentBlock, boolean isSynced) { if (isSynced) { - logger.info("Time is pays " + payoutTime + ", time to pay!"); + logger.info("Time is " + payoutTime + ", time to pay!"); } return isSynced; } diff --git a/src/main/java/com/semuxpool/pool/block/BlockResultFactory.java b/src/main/java/com/semuxpool/pool/block/BlockResultFactory.java index 21eaef7..0ad3cd1 100644 --- a/src/main/java/com/semuxpool/pool/block/BlockResultFactory.java +++ b/src/main/java/com/semuxpool/pool/block/BlockResultFactory.java @@ -122,7 +122,10 @@ public BlockResult getBlockResult(Block block) throws IOException, SemuxExceptio Long poolPayout = 0l; for (String profitAddress : poolProfitsAddress.getAddresses()) { - poolPayout += result.getPayouts().get(profitAddress); + if(result.getPayouts() != null && result.getPayouts().get(profitAddress) != null) + { + poolPayout += result.getPayouts().get(profitAddress); + } } logger.trace("Pool profits: " + poolPayout); float totalPercent = 0; diff --git a/src/main/java/com/semuxpool/pool/persistence/JsonPersistence.java b/src/main/java/com/semuxpool/pool/persistence/JsonPersistence.java index 0504198..5cd897c 100644 --- a/src/main/java/com/semuxpool/pool/persistence/JsonPersistence.java +++ b/src/main/java/com/semuxpool/pool/persistence/JsonPersistence.java @@ -123,7 +123,11 @@ public List getAllPayouts() throws IOException List payouts = new ArrayList<>(); for (String fileName : payoutFileNames) { - logger.debug("Checking file " + fileName); + if(!fileName.endsWith(".json")) + { + continue; + } + logger.info("Checking file " + fileName); //look for last one not paid out File file = new File(fileName); Payout payout = mapper.readValue(file, Payout.class);