private void notifyInitialPeer(
      List<PeerAddress> peerList,
      BaseNotificationMessageFactory messageFactory,
      String userId,
      PublicKey publicKey) {
    boolean success = false;
    while (!success && !peerList.isEmpty()) {
      PeerAddress initial = NetworkUtils.choseFirstPeerAddress(peerList);
      BaseDirectMessage msg = messageFactory.createHintNotificationMessage(initial, userId);
      try {
        sendDirect(msg, publicKey);
        success = true;
      } catch (SendFailedException e) {
        if (!peerList.isEmpty()) {
          logger.error("Initial peer of user " + userId + " was offline. Try next in line.");
          peerList.remove(0);
        }
      }
    }

    if (success == false) {
      logger.info("All clients of user " + userId + " are currently offline or unreachable.");
    } else {
      logger.debug(
          "Successfully notified the initial peer of user "
              + userId
              + " that it should check its UP tasks.");
    }
  }
  private void notifyMyPeers(
      List<PeerAddress> ownPeers,
      BaseNotificationMessageFactory messageFactory,
      PublicKey ownPublicKey) {
    ownPeers.remove(networkManager.getConnection().getPeer().getPeerAddress());
    logger.debug("Notifying " + ownPeers.size() + " other peers of me (without myself)");
    for (PeerAddress peerAddress : ownPeers) {
      if (peerAddress.equals(networkManager.getConnection().getPeer().getPeerAddress())) {
        // don't send myself
        logger.trace("Skipping to send a message to myself");
        continue;
      }

      try {
        BaseDirectMessage message = messageFactory.createPrivateNotificationMessage(peerAddress);
        if (message == null) {
          logger.info("Not notifying any of the own peers because the message to be sent is null");
        } else {
          sendDirect(message, ownPublicKey);
        }
      } catch (SendFailedException e) {
        // add to the unreachable list, such that the next process can cleanup those
        // locations
        context.addUnreachableLocation(peerAddress);
        // continue anyhow
      }
    }
  }