예제 #1
0
    /**
     * Set needs_saving on only differences
     *
     * @param da
     */
    public void load(DirectoryAnnouncement da, boolean TCP) {
      if (DEBUG) System.out.println("DSCache: load: start " + da);

      boolean need_saving = false;
      if (da.globalID != null) {
        if (!Util.equalStrings_null_or_not(globalID, da.globalID)) {
          need_saving = true;
          globalID = da.globalID;
        }
      }
      if (da.globalIDhash != null) {
        if (!Util.equalStrings_null_or_not(globalIDhash, da.globalIDhash)) {
          need_saving = true;
          globalIDhash = da.globalIDhash;
        }
      }
      if (!Util.equalStrings_null_or_not(instance, da.instance)) {
        need_saving = true;
        instance = da.instance;
      }
      if (!Util.equalBytes_null_or_not(certificate, da.certificate)) {
        need_saving = true;
        certificate = da.certificate;
      }
      if (!Util.equalBytes_null_or_not(signature, da.signature)) {
        need_saving = true;
        signature = da.signature;
      }
      set_NAT(da.address._addresses, get_NAT(addresses, TCP), TCP);
      String _addresses = Address.joinAddresses(addresses);
      String _addresses_ = Address.joinAddresses(da.address._addresses);
      if (!Util.equalStrings_null_or_not(_addresses, _addresses_)) {
        need_saving = true;
        addresses = da.address._addresses;
      }
      timestamp = da.date;
      // need_saving = true;
      if (need_saving) {
        D_Directory_Storage.discardMessage(this);
        D_Directory_Storage.need_saving_add(globalIDhash, instance);
        known = true;
      }
      if (DEBUG) System.out.println("DSCache: load: end " + this);
    }
예제 #2
0
 /**
  * Compare with recently sent challenge (store last 2 challenges and do not generate more than 1
  * challenge/hour)
  *
  * @param challenge
  * @return
  */
 private static boolean unknownChallenge(byte[] challenge) {
   for (byte[] ch : recently_sent_challenges) {
     if (Util.equalBytes_null_or_not(challenge, ch)) return true;
   }
   return false;
 }