bwt fixes and startup status

This commit is contained in:
Craig Raw 2021-01-08 16:10:00 +02:00
parent 3c4b25ecee
commit 3e083b907d
5 changed files with 23 additions and 1 deletions

View file

@ -1251,6 +1251,11 @@ public class AppController implements Initializable {
}
}
@Subscribe
public void bwtBootStatus(BwtBootStatusEvent event) {
statusUpdated(new StatusEvent(event.getStatus()));
}
@Subscribe
public void bwtSyncStatus(BwtSyncStatusEvent event) {
if((AppServices.isConnecting() || AppServices.isConnected()) && !event.isCompleted()) {

View file

@ -0,0 +1,7 @@
package com.sparrowwallet.sparrow.event;
public class BwtBootStatusEvent extends BwtStatusEvent {
public BwtBootStatusEvent(String status) {
super(status);
}
}

View file

@ -198,6 +198,9 @@ public class Bwt {
@SerializedName("setup_logger")
public Boolean setupLogger;
@SerializedName("http_addr")
public String httpAddr;
}
public final class ConnectionService extends Service<Void> {
@ -220,7 +223,7 @@ public class Bwt {
public void onBooting() {
log.debug("Booting bwt");
if(!terminating) {
Platform.runLater(() -> EventManager.get().post(new BwtStatusEvent("Starting bwt")));
Platform.runLater(() -> EventManager.get().post(new BwtBootStatusEvent("Connecting to Bitcoin Core node at " + Config.get().getCoreServer() + "...")));
}
}

View file

@ -14,11 +14,15 @@ import javafx.beans.property.IntegerProperty;
import javafx.beans.property.IntegerPropertyBase;
import javafx.beans.property.LongProperty;
import javafx.beans.property.LongPropertyBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.stream.Collectors;
public class TransactionEntry extends Entry implements Comparable<TransactionEntry> {
private static final Logger log = LoggerFactory.getLogger(TransactionEntry.class);
private final BlockTransaction blockTransaction;
public TransactionEntry(Wallet wallet, BlockTransaction blockTransaction, Map<BlockTransactionHashIndex, KeyPurpose> inputs, Map<BlockTransactionHashIndex, KeyPurpose> outputs) {
@ -86,6 +90,7 @@ public class TransactionEntry extends Entry implements Comparable<TransactionEnt
if(optRef.isPresent()) {
validEntries++;
if(getChildren().stream().noneMatch(entry -> ((HashIndexEntry)entry).getHashIndex().equals(optRef.get().getSpentBy()) && ((HashIndexEntry)entry).getType().equals(HashIndexEntry.Type.INPUT))) {
log.warn("TransactionEntry " + blockTransaction.getHash() + " for wallet " + getWallet().getName() + " missing child for input " + optRef.get().getSpentBy() + " on output " + optRef.get());
return false;
}
}
@ -95,12 +100,14 @@ public class TransactionEntry extends Entry implements Comparable<TransactionEnt
if(optRef.isPresent()) {
validEntries++;
if(getChildren().stream().noneMatch(entry -> ((HashIndexEntry)entry).getHashIndex().equals(optRef.get()) && ((HashIndexEntry)entry).getType().equals(HashIndexEntry.Type.OUTPUT))) {
log.warn("TransactionEntry " + blockTransaction.getHash() + " for wallet " + getWallet().getName() + " missing child for output " + optRef.get());
return false;
}
}
}
if(getChildren().size() != validEntries) {
log.warn("TransactionEntry " + blockTransaction.getHash() + " for wallet " + getWallet().getName() + " has incorrect number of children " + getChildren().size() + " (should be " + validEntries + ")");
return false;
}