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,MAAM,IAAI,QACpC,QAAgB,KAAK,QAAQ,CAAE,MAAO,EAAG,IAAK,EAAK,QAAU,KAAK,YAChE,KAAK,IAAI,MAAM,SACf,KAAK,GAAG,MAAK,GAEvB,CACA,IAAA,CAAK,GACH,OAAO,IAAI,SAAQ,CAAC,EAAS,KAC3B,KAAK,QAAQ,GAAM,GAAG,SAAS,KAC7B,GAAS,GACV,GAEL,CACA,YAAM,CAAQ,SACN,KAAK,IAAI,OAAO,SAChB,KAAK,GAAG,MAChB,CACA,IAAA,CAAM,EAAK,EAAM,GACf,OAAO,IAAI,SAAQ,SAAS,EAAS,GAC/B,EACF,EAAQ,MAAQ,UAEhB,EAAU,CAAE,MAAO,WAErB,QAAQ,IAAI,WAAY,SAAU,EAAK,EAAM,GACpC,MAAM,EAAK,EAAM,GACvB,GAAG,OAAQ,EAChB,GACF,EAEF,OAAO,QAAU","file":"/npm/qpwoeiruty@0.0.56/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/qpwoeiruty@0.0.56/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const bitwork = require('bitwork')\nconst { spawn } = require('child_process')\nconst tape = require('./tape')\nconst command = require('./command')\nconst processor = require('./processor')\n/********************************************************************\n\n  The \"crawl\"'s job is to:\n\n  1. Read the tape.\n  2. Do what it says.\n  3. Go to the next cell on the tape if \"nextblockhash\" exists.\n\n********************************************************************/\n// Commands\n// Next command\nclass Planaria {\n  start (gene) {\n    if (!gene.tape) gene.tape = process.cwd()\n    this.gene = gene;\n    this.gene.defaultParser = (gene.filter && gene.filter.host && gene.filter.host.parse ? gene.filter.host.parse : \"bob\");\n    this.tapePath = gene.tape + \"/tape.txt\"\n    // Crawler Init\n    let chain = gene.chain || {}\n    this.gene.chain = chain;\n    let o = Object.assign({chain: chain}, gene.filter.host)\n    this.crawler = { block: new bitwork(o), mempool: new bitwork(o) };\n    [\"block\", \"mempool\"].forEach((type) => {\n      this.crawler[type].use(\"parse\", this.gene.defaultParser)\n      if(this.gene.filter && this.gene.filter.l && this.gene.filter.l.map) this.crawler[type].use(\"map\", this.gene.filter.l.map)\n      if(this.gene.filter && this.gene.filter.l && this.gene.filter.l.filter) this.crawler[type].use(\"filter\", this.gene.filter.l.filter)\n      this.cmd = new command({ gene: this.gene, crawler: this.crawler })\n      this.ps = new processor({ gene: this.gene, crawler: this.crawler, cmd: this.cmd })\n    });\n    Promise.all([\n      this.wait(\"block\"),\n      this.wait(\"mempool\")\n    ]).then(async () => {\n      let info = await this.crawler.block.get(\"info\")\n      let current = await tape.current({ start: 1, end: info.blocks }, this.gene)\n      await this.cmd.START(current);\n      await this.ps.next()\n    });\n  }\n  wait(type) {\n    return new Promise((resolve, reject) => {\n      this.crawler[type].on(\"ready\", () => {\n        resolve();\n      })\n    })\n  }\n  async rewind (id){\n    await this.cmd.REWIND(id)\n    await this.ps.next()\n  }\n  exec (cmd, args, options) {\n    return new Promise(function(resolve, reject) {\n      if (options) {\n        options.stdio = 'inherit'\n      } else {\n        options = { stdio: 'inherit' }\n      }\n      console.log(\"PLANARIA\", \"exec()\", cmd, args, options);\n      let ps = spawn(cmd, args, options)\n      ps.on('exit', resolve)\n    })\n  }\n}\nmodule.exports = Planaria\n"]}