Require password at startup, heck for open offers at emptying wallet, add check for isBootstrapped,

This commit is contained in:
Manfred Karrer 2016-04-07 02:54:52 +02:00
parent 5af70848a7
commit 0ebf3f6b36
12 changed files with 74 additions and 74 deletions

View file

@ -145,8 +145,12 @@ public class ArbitratorManager {
ArbitratorManager.this.onBootstrapComplete();
}
};
p2PService.addP2PServiceListener(bootstrapListener);
if (p2PService.isBootstrapped())
onBootstrapComplete();
else
p2PService.addP2PServiceListener(bootstrapListener);
} else {
republishArbitrator();
}

View file

@ -125,7 +125,10 @@ public class DisputeManager {
applyMessages();
}
};
p2PService.addP2PServiceListener(bootstrapListener);
if (p2PService.isBootstrapped())
applyMessages();
else
p2PService.addP2PServiceListener(bootstrapListener);
}
private void applyMessages() {
@ -146,7 +149,8 @@ public class DisputeManager {
});
decryptedMailboxMessageWithPubKeys.clear();
p2PService.removeP2PServiceListener(bootstrapListener);
if (bootstrapListener != null)
p2PService.removeP2PServiceListener(bootstrapListener);
}

View file

@ -151,13 +151,15 @@ public class TradeManager {
bootstrapListener = new BootstrapListener() {
@Override
public void onBootstrapComplete() {
Log.traceCall("onNetworkReady");
// Get called after onMailboxMessageAdded from initial data request
// The mailbox message will be removed inside the tasks after they are processed successfully
initPendingTrades();
}
};
p2PService.addP2PServiceListener(bootstrapListener);
if (p2PService.isBootstrapped())
initPendingTrades();
else
p2PService.addP2PServiceListener(bootstrapListener);
}
@ -167,7 +169,8 @@ public class TradeManager {
private void initPendingTrades() {
Log.traceCall();
p2PService.removeP2PServiceListener(bootstrapListener);
if (bootstrapListener != null)
p2PService.removeP2PServiceListener(bootstrapListener);
//List<Trade> failedTrades = new ArrayList<>();
for (Trade trade : trades) {

View file

@ -53,6 +53,7 @@ import javax.annotation.Nullable;
import javax.inject.Named;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@ -121,6 +122,11 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
};
p2PService.addP2PServiceListener(bootstrapListener);
p2PService.addDecryptedDirectMessageListener(this);
if (p2PService.isBootstrapped())
onBootstrapComplete();
else
p2PService.addP2PServiceListener(bootstrapListener);
}
@SuppressWarnings("WeakerAccess")
@ -151,6 +157,15 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
UserThread.runAfter(completeHandler::run, openOffers.size() * 100 + 200, TimeUnit.MILLISECONDS);
}
public void removeAllOpenOffers(@Nullable Runnable completeHandler) {
List<OpenOffer> openOffersList = new ArrayList<>(openOffers);
openOffersList.forEach(openOffer -> removeOpenOffer(openOffer, () -> {
}, errorMessage -> {
}));
if (completeHandler != null)
UserThread.runAfter(completeHandler::run, openOffers.size() * 100 + 200, TimeUnit.MILLISECONDS);
}
///////////////////////////////////////////////////////////////////////////////////////////
// DecryptedDirectMessageListener implementation
///////////////////////////////////////////////////////////////////////////////////////////
@ -172,7 +187,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
///////////////////////////////////////////////////////////////////////////////////////////
public void onBootstrapComplete() {
p2PService.removeP2PServiceListener(bootstrapListener);
if (bootstrapListener != null)
p2PService.removeP2PServiceListener(bootstrapListener);
stopped = false;