Skip to content

Commit 7966996

Browse files
authored
update miners command descriptions, add json to pool status (#5234)
1 parent 430496f commit 7966996

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

ironfish-cli/src/commands/miners/pools/start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { RemoteFlags } from '../../../flags'
1919
import { getExplorer } from '../../../utils/explorer'
2020

2121
export class StartPool extends IronfishCommand {
22-
static description = `Start a mining pool that connects to a node`
22+
static description = `start a mining pool`
2323

2424
static flags = {
2525
...RemoteFlags,

ironfish-cli/src/commands/miners/pools/status.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ import { Flags } from '@oclif/core'
1616
import blessed from 'blessed'
1717
import dns from 'dns'
1818
import { IronfishCommand } from '../../../command'
19+
import { JsonFlags } from '../../../flags'
1920
import * as ui from '../../../ui'
2021

2122
export class PoolStatus extends IronfishCommand {
22-
static description = `Show the status of a mining pool`
23+
static description = `show the mining pool's status`
24+
static enableJsonFlag = true
2325

2426
static flags = {
27+
...JsonFlags,
2528
address: Flags.string({
2629
char: 'a',
2730
description: 'The public address for which to retrieve pool share data',
@@ -41,7 +44,7 @@ export class PoolStatus extends IronfishCommand {
4144
}),
4245
}
4346

44-
async start(): Promise<void> {
47+
async start(): Promise<unknown> {
4548
const { flags } = await this.parse(PoolStatus)
4649

4750
if (flags.address && !isValidPublicAddress(flags.address)) {
@@ -71,11 +74,17 @@ export class PoolStatus extends IronfishCommand {
7174
}
7275

7376
if (!flags.follow) {
77+
let poolStatus
7478
stratum.onConnected.on(() => stratum.getStatus(flags.address))
75-
stratum.onStatus.on((status) => this.log(this.renderStatus(status)))
79+
stratum.onStatus.on((status) => {
80+
this.log(this.renderStatus(status))
81+
poolStatus = status
82+
})
7683
stratum.start()
7784
await waitForEmit(stratum.onStatus)
78-
this.exit(0)
85+
stratum.stop()
86+
87+
return poolStatus
7988
}
8089

8190
this.logger.pauseLogs()

ironfish-cli/src/commands/miners/start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IronfishCommand } from '../../command'
1919
import { RemoteFlags } from '../../flags'
2020

2121
export class Miner extends IronfishCommand {
22-
static description = `Start a miner and subscribe to new blocks for the node`
22+
static description = `start a miner`
2323

2424
updateInterval: SetIntervalToken | null = null
2525

ironfish/src/mining/stratum/clients/client.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export abstract class StratumClient {
3737
readonly version: number
3838

3939
private started: boolean
40+
private isClosing = false
4041
private id: number | null
4142
private connected: boolean
4243
private connectWarned: boolean
@@ -85,6 +86,10 @@ export abstract class StratumClient {
8586
}
8687

8788
private async startConnecting(): Promise<void> {
89+
if (this.isClosing) {
90+
return
91+
}
92+
8893
if (this.disconnectUntil && this.disconnectUntil > Date.now()) {
8994
this.connectTimeout = setTimeout(() => void this.startConnecting(), 60 * 1000)
9095
return
@@ -114,6 +119,7 @@ export abstract class StratumClient {
114119
}
115120

116121
stop(): void {
122+
this.isClosing = true
117123
void this.close()
118124

119125
if (this.connectTimeout) {
@@ -191,11 +197,13 @@ export abstract class StratumClient {
191197
}
192198

193199
this.logger.info(message)
194-
} else {
200+
} else if (!this.isClosing) {
195201
this.logger.info('Disconnected from pool unexpectedly. Reconnecting.')
196202
}
197203

198-
this.connectTimeout = setTimeout(() => void this.startConnecting(), 5000)
204+
if (!this.isClosing) {
205+
this.connectTimeout = setTimeout(() => void this.startConnecting(), 5000)
206+
}
199207
}
200208

201209
protected onError = (error: unknown): void => {

ironfish/src/mining/stratum/clients/tcpClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class StratumTcpClient extends StratumClient {
1919

2020
protected onSocketDisconnect = (): void => {
2121
this.client?.off('error', this.onError)
22-
this.client?.off('close', this.onDisconnect)
22+
this.client?.off('close', this.onSocketDisconnect)
2323
this.client?.off('data', this.onSocketData)
2424
this.onDisconnect()
2525
}

0 commit comments

Comments
 (0)