Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opening the repl without opening the DB #3753

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ironfish-cli/src/commands/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { NodeUtils, RpcMemoryClient } from '@ironfish/sdk'
import { Flags } from '@oclif/core'
import fs from 'fs/promises'
import repl from 'node:repl'
import path from 'path'
Expand All @@ -22,14 +23,21 @@ export default class Repl extends IronfishCommand {
[VerboseFlagKey]: VerboseFlag,
[ConfigFlagKey]: ConfigFlag,
[DataDirFlagKey]: DataDirFlag,
opendb: Flags.boolean({
description: 'open the databases',
allowNo: true,
}),
}

async start(): Promise<void> {
await this.parse(Repl)
const { flags } = await this.parse(Repl)

const node = await this.sdk.node()
const client = new RpcMemoryClient(this.logger, node)
await NodeUtils.waitForOpen(node)

if (flags.opendb) {
await NodeUtils.waitForOpen(node)
}

this.log('Examples:')
this.log(' Get the head block hash')
Expand Down