From 34b4c39ccd1fac6b8da073a2b5183952cbe1e839 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 4 Aug 2021 10:45:01 +0200 Subject: [PATCH] add logging when event wallet id is not present --- .../com/sparrowwallet/sparrow/event/StorageEvent.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/event/StorageEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/StorageEvent.java index 655f2bdb..43f745f2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/event/StorageEvent.java +++ b/src/main/java/com/sparrowwallet/sparrow/event/StorageEvent.java @@ -1,12 +1,16 @@ package com.sparrowwallet.sparrow.event; import com.sparrowwallet.sparrow.io.Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.util.HashMap; import java.util.Map; public class StorageEvent extends TimedEvent { + private static final Logger log = LoggerFactory.getLogger(StorageEvent.class); + private static boolean firstRunDone = false; private static final Map eventTime = new HashMap<>(); @@ -22,8 +26,10 @@ public class StorageEvent extends TimedEvent { eventTime.put(walletId, System.currentTimeMillis()); timeMills = keyDerivationPeriod; } else if(action == Action.END) { - long start = eventTime.get(walletId); - if(firstRunDone) { + Long start = eventTime.get(walletId); + if(start == null) { + log.error("Could not find start event time for wallet id " + walletId); + } else if(firstRunDone) { keyDerivationPeriod = (int)(System.currentTimeMillis() - start); Config.get().setKeyDerivationPeriod(keyDerivationPeriod); }