Refactor: return early

This commit is contained in:
chimp1984 2021-01-11 23:59:58 -05:00
parent 8d866d5d06
commit a9802e60cd
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -493,8 +493,16 @@ public class MailboxMessageService implements SetupListener, RequestDataManager.
private void addMailboxData(MailboxStoragePayload expirableMailboxStoragePayload,
PublicKey receiversPublicKey,
SendMailboxMessageListener sendMailboxMessageListener) {
if (isBootstrapped) {
if (!networkNode.getAllConnections().isEmpty()) {
if (!isBootstrapped) {
throw new NetworkNotReadyException();
}
if (networkNode.getAllConnections().isEmpty()) {
sendMailboxMessageListener.onFault("There are no P2P network nodes connected. " +
"Please check your internet connection.");
return;
}
try {
ProtectedMailboxStorageEntry protectedMailboxStorageEntry = p2PDataStorage.getMailboxDataWithSignedSeqNr(
expirableMailboxStoragePayload,
@ -532,13 +540,6 @@ public class MailboxMessageService implements SetupListener, RequestDataManager.
} catch (CryptoException e) {
log.error("Signing at getMailboxDataWithSignedSeqNr failed.");
}
} else {
sendMailboxMessageListener.onFault("There are no P2P network nodes connected. " +
"Please check your internet connection.");
}
} else {
throw new NetworkNotReadyException();
}
}
private void removeMailboxEntryFromNetwork(ProtectedMailboxStorageEntry protectedMailboxStorageEntry) {