UNPKG

@ethersphere/swarm-cli

Version:
46 lines (45 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Rchash = void 0; const cafe_utility_1 = require("cafe-utility"); const spinner_1 = require("../../utils/spinner"); const text_1 = require("../../utils/text"); const root_command_1 = require("../root-command"); class Rchash extends root_command_1.RootCommand { constructor() { super(...arguments); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: 'rchash' }); Object.defineProperty(this, "description", { enumerable: true, configurable: true, writable: true, value: 'Check reserve sampling duration' }); } async run() { super.init(); const addresses = await this.bee.getNodeAddresses(); const topology = await this.bee.getTopology(); let stillRunning = true; const promise = this.bee.rchash(topology.depth, addresses.overlay.toHex(), addresses.overlay.toHex()); promise.finally(() => { stillRunning = false; }); const startedAt = Date.now(); const spinner = (0, spinner_1.createSpinner)('Running rchash...').start(); while (stillRunning) { await cafe_utility_1.System.sleepMillis(1000); const duration = (Date.now() - startedAt) / 1000; spinner.text = `Running rchash ${duration.toFixed()}s`; } spinner.stop(); const result = await promise; this.console.log((0, text_1.createKeyValue)('Reserve sampling duration', result + ' seconds')); } } exports.Rchash = Rchash;