<commit_before>(function() {


  const path = require('path');
  const jetpack = require('fs-jetpack');
  const env = require('../env');
  const log = require('../log');
  const Nxt = require('./nxt_nrs');


  let tasks = [];
  let bc = {
    nxt: {},
  };


  const init = function() {
    const nxtList = getServerList('nxt');
    bc.nxt = new Nxt(nxtList);
    tasks.push({
      name: 'nxtNumBlocks',
      interval: 10000,
      type: 'nxt',
      command: 'getBlockchainStatus',
      params: {},
      callback: function(resp) {
        Relief.emit('nxt.BlockHeight', (resp.data.numberOfBlocks - 1));
      },
    });
    runTasks();
  };


  const runTasks = function() {
    const now = new Date().getTime();
    for (let i in tasks) {
      const task = tasks[i];
      if ((now - task.lastRun) < task.interval) {
        continue;
      }
      log.info('Running task', task.name)
      switch (task.type) {
        case 'nxt': {
          task.params.requestType = task.command;
          bc.nxt.request(task.params).then(task.callback, log.error);
          tasks[i].lastRun = now;
          break;
        }
      }
    }
    setTimeout(function() {
      runTasks();
    }, 1000);
  };


  const getServerList = function(platform) {
    if (platform === 'nxt') {
      const file = env.nxtTestnet
        ? 'servers_nxt_testnet.json'
        : 'server_nxt.json';
      const dataDir = path.join(__dirname, '..', '..', 'data');
      const nxtFile = path.join(dataDir, file);
      return jetpack.read(nxtFile, 'json');
    }
  };

  module.exports = {
    init: init,
    bc: bc,
    getServerList: getServerList,
  };


})();
<commit_msg>Update block height only every 60s<commit_after>(function() {


  const path = require('path');
  const jetpack = require('fs-jetpack');
  const env = require('../env');
  const log = require('../log');
  const Nxt = require('./nxt_nrs');


  let tasks = [];
  let bc = {
    nxt: {},
  };


  const init = function() {
    const nxtList = getServerList('nxt');
    bc.nxt = new Nxt(nxtList);
    tasks.push({
      name: 'nxtNumBlocks',
      interval: 60000,
      type: 'nxt',
      command: 'getBlockchainStatus',
      params: {},
      callback: function(resp) {
        Relief.emit('nxt.BlockHeight', (resp.data.numberOfBlocks - 1));
      },
    });
    runTasks();
  };


  const runTasks = function() {
    const now = new Date().getTime();
    for (let i in tasks) {
      const task = tasks[i];
      if ((now - task.lastRun) < task.interval) {
        continue;
      }
      log.info('Running task', task.name)
      switch (task.type) {
        case 'nxt': {
          task.params.requestType = task.command;
          bc.nxt.request(task.params).then(task.callback, log.error);
          tasks[i].lastRun = now;
          break;
        }
      }
    }
    setTimeout(function() {
      runTasks();
    }, 1000);
  };


  const getServerList = function(platform) {
    if (platform === 'nxt') {
      const file = env.nxtTestnet
        ? 'servers_nxt_testnet.json'
        : 'server_nxt.json';
      const dataDir = path.join(__dirname, '..', '..', 'data');
      const nxtFile = path.join(dataDir, file);
      return jetpack.read(nxtFile, 'json');
    }
  };

  module.exports = {
    init: init,
    bc: bc,
    getServerList: getServerList,
  };


})();

{'fraction_non_alphanumeric': 0.1664163412436167, 'fraction_numerical': 0.006608591168519075, 'mean_word_length': 2.189655172413793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4988950', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1099, 'n_words': 229}