File tree Expand file tree Collapse file tree 5 files changed +26
-9
lines changed
ironfish-cli/src/commands/miners
ironfish/src/mining/stratum/clients Expand file tree Collapse file tree 5 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { RemoteFlags } from '../../../flags'
19
19
import { getExplorer } from '../../../utils/explorer'
20
20
21
21
export class StartPool extends IronfishCommand {
22
- static description = `Start a mining pool that connects to a node `
22
+ static description = `start a mining pool`
23
23
24
24
static flags = {
25
25
...RemoteFlags ,
Original file line number Diff line number Diff line change @@ -16,12 +16,15 @@ import { Flags } from '@oclif/core'
16
16
import blessed from 'blessed'
17
17
import dns from 'dns'
18
18
import { IronfishCommand } from '../../../command'
19
+ import { JsonFlags } from '../../../flags'
19
20
import * as ui from '../../../ui'
20
21
21
22
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
23
25
24
26
static flags = {
27
+ ...JsonFlags ,
25
28
address : Flags . string ( {
26
29
char : 'a' ,
27
30
description : 'The public address for which to retrieve pool share data' ,
@@ -41,7 +44,7 @@ export class PoolStatus extends IronfishCommand {
41
44
} ) ,
42
45
}
43
46
44
- async start ( ) : Promise < void > {
47
+ async start ( ) : Promise < unknown > {
45
48
const { flags } = await this . parse ( PoolStatus )
46
49
47
50
if ( flags . address && ! isValidPublicAddress ( flags . address ) ) {
@@ -71,11 +74,17 @@ export class PoolStatus extends IronfishCommand {
71
74
}
72
75
73
76
if ( ! flags . follow ) {
77
+ let poolStatus
74
78
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
+ } )
76
83
stratum . start ( )
77
84
await waitForEmit ( stratum . onStatus )
78
- this . exit ( 0 )
85
+ stratum . stop ( )
86
+
87
+ return poolStatus
79
88
}
80
89
81
90
this . logger . pauseLogs ( )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { IronfishCommand } from '../../command'
19
19
import { RemoteFlags } from '../../flags'
20
20
21
21
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`
23
23
24
24
updateInterval : SetIntervalToken | null = null
25
25
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export abstract class StratumClient {
37
37
readonly version : number
38
38
39
39
private started : boolean
40
+ private isClosing = false
40
41
private id : number | null
41
42
private connected : boolean
42
43
private connectWarned : boolean
@@ -85,6 +86,10 @@ export abstract class StratumClient {
85
86
}
86
87
87
88
private async startConnecting ( ) : Promise < void > {
89
+ if ( this . isClosing ) {
90
+ return
91
+ }
92
+
88
93
if ( this . disconnectUntil && this . disconnectUntil > Date . now ( ) ) {
89
94
this . connectTimeout = setTimeout ( ( ) => void this . startConnecting ( ) , 60 * 1000 )
90
95
return
@@ -114,6 +119,7 @@ export abstract class StratumClient {
114
119
}
115
120
116
121
stop ( ) : void {
122
+ this . isClosing = true
117
123
void this . close ( )
118
124
119
125
if ( this . connectTimeout ) {
@@ -191,11 +197,13 @@ export abstract class StratumClient {
191
197
}
192
198
193
199
this . logger . info ( message )
194
- } else {
200
+ } else if ( ! this . isClosing ) {
195
201
this . logger . info ( 'Disconnected from pool unexpectedly. Reconnecting.' )
196
202
}
197
203
198
- this . connectTimeout = setTimeout ( ( ) => void this . startConnecting ( ) , 5000 )
204
+ if ( ! this . isClosing ) {
205
+ this . connectTimeout = setTimeout ( ( ) => void this . startConnecting ( ) , 5000 )
206
+ }
199
207
}
200
208
201
209
protected onError = ( error : unknown ) : void => {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export class StratumTcpClient extends StratumClient {
19
19
20
20
protected onSocketDisconnect = ( ) : void => {
21
21
this . client ?. off ( 'error' , this . onError )
22
- this . client ?. off ( 'close' , this . onDisconnect )
22
+ this . client ?. off ( 'close' , this . onSocketDisconnect )
23
23
this . client ?. off ( 'data' , this . onSocketData )
24
24
this . onDisconnect ( )
25
25
}
You can’t perform that action at this time.
0 commit comments