Add missing allServicesInitialized check

This commit is contained in:
chimp1984 2019-08-29 21:40:32 +02:00
parent 29e957a7ca
commit 855cb4f620
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
2 changed files with 10 additions and 5 deletions

View File

@ -108,8 +108,6 @@ public class DisputeManager implements PersistedDataHost {
private final Map<String, Subscription> disputeIsClosedSubscriptionsMap = new HashMap<>();
@Getter
private final IntegerProperty numOpenDisputes = new SimpleIntegerProperty();
private boolean servicesInitialized;
@Getter
private final ChatManager chatManager;
@ -160,7 +158,7 @@ public class DisputeManager implements PersistedDataHost {
}
public void onAllServicesInitialized() {
servicesInitialized = true;
chatManager.onAllServicesInitialized();
p2PService.addP2PServiceListener(new BootstrapListener() {
@Override
public void onUpdatedDataReceived() {

View File

@ -59,6 +59,7 @@ public class ChatManager {
private final CopyOnWriteArraySet<DecryptedMessageWithPubKey> decryptedMailboxMessageWithPubKeys = new CopyOnWriteArraySet<>();
private final CopyOnWriteArraySet<DecryptedMessageWithPubKey> decryptedDirectMessageWithPubKeys = new CopyOnWriteArraySet<>();
private boolean allServicesInitialized;
public ChatManager(P2PService p2PService,
WalletsSetup walletsSetup
@ -77,13 +78,18 @@ public class ChatManager {
});
}
public void onAllServicesInitialized() {
allServicesInitialized = true;
}
public void tryApplyMessages() {
if (isReadyForTxBroadcast())
applyMessages();
}
private boolean isReadyForTxBroadcast() {
return p2PService.isBootstrapped() &&
return allServicesInitialized &&
p2PService.isBootstrapped() &&
walletsSetup.isDownloadComplete() &&
walletsSetup.hasSufficientPeersForBroadcast();
}
@ -139,7 +145,8 @@ public class ChatManager {
sendAckMessage(disputeCommunicationMessage, receiverPubKeyRing, true, null);
}
private void processAckMessage(AckMessage ackMessage, @Nullable DecryptedMessageWithPubKey decryptedMessageWithPubKey) {
private void processAckMessage(AckMessage ackMessage,
@Nullable DecryptedMessageWithPubKey decryptedMessageWithPubKey) {
if (ackMessage.getSourceType() == AckMessageSourceType.DISPUTE_MESSAGE) {
if (ackMessage.isSuccess()) {
log.info("Received AckMessage for {} with tradeId {} and uid {}",