add logging when event wallet id is not present

This commit is contained in:
Craig Raw 2021-08-04 10:45:01 +02:00
parent 34d1571669
commit 34b4c39ccd

View file

@ -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<String, Long> 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);
}