<commit_before>import { insertAuthority, removeAuthority } from './methods';

export class AuthorityRegistry {
  register ({ ip, port }, cb) {
    insertAuthority.call({ authorityIp: ip, port }, (err, res) => {
      if (err) {
        return cb(new Error(`Failed to insert Authority into registry: ${err}`));
      }
      return cb(null, res);
    });
  }
  unregister ({ ip, port }, cb) {
    // remove from collection
    removeAuthority.call({ authorityIp: ip }, (err, res) => {
      if (err) {
        return cb(new Error(`Failed to remove Authority from registry: ${err}`));
      }
      console.log(`Unregistered authority with ip ${ip}:${port}`);
      return cb(null, res);
    });
  }
  addDocToAuthority ({ authorityIp, docId }) {
    // delegate the doc to the specified authority
  }
  removeDocFromAuthority ({ docId }) {
    // remove a doc from its authority
  }
  getAuthorityIpHostingDoc ({ docId }) {
    // return ip of authority, or undefined
  }
  chooseAuthorityToHostDoc ({ docId }) {
    // -queries collection for all authorities
    // -gets ip of last selected authority from db
    // -iterate over authorities in sorted order. choose the one AFTER the last one selected
  }
}<commit_msg>dont pass port to unregister<commit_after>import { insertAuthority, removeAuthority } from './methods';

export class AuthorityRegistry {
  register ({ ip, port }, cb) {
    insertAuthority.call({ authorityIp: ip, port }, (err, res) => {
      if (err) {
        return cb(new Error(`Failed to insert Authority into registry: ${err}`));
      }
      return cb(null, res);
    });
  }
  unregister ({ ip }, cb) {
    // remove from collection
    removeAuthority.call({ authorityIp: ip }, (err, res) => {
      if (err) {
        return cb(new Error(`Failed to remove Authority from registry: ${err}`));
      }
      console.log(`Unregistered authority with ip ${ip}`);
      return cb(null, res);
    });
  }
  addDocToAuthority ({ authorityIp, docId }) {
    // delegate the doc to the specified authority
  }
  removeDocFromAuthority ({ docId }) {
    // remove a doc from its authority
  }
  getAuthorityIpHostingDoc ({ docId }) {
    // return ip of authority, or undefined
  }
  chooseAuthorityToHostDoc ({ docId }) {
    // -queries collection for all authorities
    // -gets ip of last selected authority from db
    // -iterate over authorities in sorted order. choose the one AFTER the last one selected
  }
}
{'fraction_non_alphanumeric': 0.12494879147890209, 'fraction_numerical': 0.0, 'mean_word_length': 2.8639240506329116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6986685', 'n_tokens_mistral': 696, 'n_tokens_neox': 694, 'n_words': 239}