-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3364 from iron-fish/staging
STAGING -> MASTER (2023-02-09)
- Loading branch information
Showing
130 changed files
with
5,775 additions
and
1,398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Node.js CI | |
on: | ||
pull_request: | ||
branches: | ||
- '*' | ||
- '**' | ||
push: | ||
branches: | ||
- master | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ironfish", | ||
"version": "0.1.65", | ||
"version": "0.1.66", | ||
"description": "CLI for running and interacting with an Iron Fish node", | ||
"author": "Iron Fish <[email protected]> (https://ironfish.network)", | ||
"main": "build/src/index.js", | ||
|
@@ -59,8 +59,8 @@ | |
"@aws-sdk/s3-request-presigner": "3.127.0", | ||
"@aws-sdk/client-cognito-identity": "3.215.0", | ||
"@aws-sdk/client-s3": "3.127.0", | ||
"@ironfish/rust-nodejs": "0.1.25", | ||
"@ironfish/sdk": "0.0.42", | ||
"@ironfish/rust-nodejs": "0.1.26", | ||
"@ironfish/sdk": "0.0.43", | ||
"@oclif/core": "1.23.1", | ||
"@oclif/plugin-help": "5.1.12", | ||
"@oclif/plugin-not-found": "2.3.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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 { FileUtils } from '@ironfish/sdk' | ||
import { parseNumber } from '../../args' | ||
import { IronfishCommand } from '../../command' | ||
import { LocalFlags } from '../../flags' | ||
|
||
export default class Power extends IronfishCommand { | ||
static description = "Show the network's hash power (hash/s)" | ||
|
||
static flags = { | ||
...LocalFlags, | ||
} | ||
|
||
static args = [ | ||
{ | ||
name: 'blocks', | ||
parse: (input: string): Promise<number | null> => Promise.resolve(parseNumber(input)), | ||
required: false, | ||
description: | ||
'The number of blocks to look back to calculate the power. This value must be > 0', | ||
}, | ||
{ | ||
name: 'sequence', | ||
parse: (input: string): Promise<number | null> => Promise.resolve(parseNumber(input)), | ||
required: false, | ||
description: 'The sequence of the latest block from when to estimate network speed ', | ||
}, | ||
] | ||
|
||
async start(): Promise<void> { | ||
const { args } = await this.parse(Power) | ||
const inputBlocks = args.blocks as number | null | undefined | ||
const inputSequence = args.sequence as number | null | undefined | ||
|
||
await this.sdk.client.connect() | ||
|
||
const data = await this.sdk.client.getNetworkHashPower({ | ||
blocks: inputBlocks, | ||
sequence: inputSequence, | ||
}) | ||
|
||
const { hashesPerSecond, blocks, sequence } = data.content | ||
const formattedHashesPerSecond = FileUtils.formatHashRate(hashesPerSecond) | ||
|
||
this.log( | ||
`The network power for block ${sequence} was ${formattedHashesPerSecond} averaged over ${blocks} previous blocks.`, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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 { BannedPeerResponse, GetBannedPeersResponse, PromiseUtils } from '@ironfish/sdk' | ||
import { CliUx, Flags } from '@oclif/core' | ||
import blessed from 'blessed' | ||
import { IronfishCommand } from '../../command' | ||
import { RemoteFlags } from '../../flags' | ||
|
||
const tableFlags = CliUx.ux.table.flags() | ||
|
||
export class BannedCommand extends IronfishCommand { | ||
static description = `List all banned peers` | ||
|
||
static flags = { | ||
...RemoteFlags, | ||
...tableFlags, | ||
follow: Flags.boolean({ | ||
char: 'f', | ||
default: false, | ||
description: 'Follow the banned peers list live', | ||
}), | ||
} | ||
|
||
async start(): Promise<void> { | ||
const { flags } = await this.parse(BannedCommand) | ||
|
||
if (!flags.follow) { | ||
await this.sdk.client.connect() | ||
const response = await this.sdk.client.getBannedPeers() | ||
this.log(renderTable(response.content)) | ||
this.exit(0) | ||
} | ||
|
||
// Console log will create display issues with Blessed | ||
this.logger.pauseLogs() | ||
|
||
const screen = blessed.screen({ smartCSR: true, fullUnicode: true }) | ||
const text = blessed.text() | ||
screen.append(text) | ||
|
||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
const connected = await this.sdk.client.tryConnect() | ||
if (!connected) { | ||
text.clearBaseLine(0) | ||
text.setContent('Connecting...') | ||
screen.render() | ||
await PromiseUtils.sleep(1000) | ||
continue | ||
} | ||
|
||
const response = this.sdk.client.getBannedPeersStream() | ||
|
||
for await (const value of response.contentStream()) { | ||
text.clearBaseLine(0) | ||
text.setContent(renderTable(value)) | ||
screen.render() | ||
} | ||
} | ||
} | ||
} | ||
|
||
function renderTable(content: GetBannedPeersResponse): string { | ||
const columns: CliUx.Table.table.Columns<BannedPeerResponse> = { | ||
identity: { | ||
minWidth: 45, | ||
header: 'IDENTITY', | ||
get: (row) => { | ||
return row.identity | ||
}, | ||
}, | ||
reason: { | ||
minWidth: 15, | ||
header: 'BAN REASON', | ||
get: (row) => { | ||
return row.reason | ||
}, | ||
}, | ||
} | ||
|
||
let result = '' | ||
|
||
CliUx.ux.table(content.peers, columns, { | ||
printLine: (line) => (result += `${String(line)}\n`), | ||
}) | ||
|
||
return result | ||
} |
Oops, something went wrong.