forked from citycoins/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetnetworkstatus.js
40 lines (37 loc) · 1.08 KB
/
getnetworkstatus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import console from "console";
import prompts from "prompts";
import {
exitWithError,
getBlockHeight,
getOptimalFee,
getTotalMempoolTx,
} from "./utils.js";
/** @module GetNetworkStatus */
/**
* @async
* @function getNetworkStatus
* @description Gets the current block height, mempool size, and average fees
*/
async function getNetworkStatus() {
const userConfig = await prompts({
type: "confirm",
name: "checkAllTx",
message: "Check all TX? (default: first 200)",
initial: false,
});
// get current block height
const currentBlock = await getBlockHeight().catch((err) =>
exitWithError(`getBlockHeight err: ${err}`)
);
console.log(`currentBlock: ${currentBlock}`);
// get current mempool size
const mempoolTxCount = await getTotalMempoolTx().catch((err) =>
exitWithError(`getTotalMempoolTx err: ${err}`)
);
console.log(`mempoolTxCount: ${mempoolTxCount}`);
// get estimated fee based on mempool average fees
await getOptimalFee(1, userConfig.checkAllTx).catch((err) =>
exitWithError(`getOptimalFee err: ${err}`)
);
}
getNetworkStatus();