|
1 | 1 | import * as dotenv from 'dotenv';
|
2 | 2 | import * as getopts from 'getopts';
|
| 3 | +import * as bigint from 'extra-bigint'; |
3 | 4 | import { table } from 'table';
|
4 | 5 | import { StacksCoreRpcClient } from '../../src/core-rpc/client';
|
5 | 6 | import { PgDataStore } from '../../src/datastore/postgres-store';
|
@@ -28,7 +29,8 @@ type TableCellValue = string | number | bigint | undefined;
|
28 | 29 | async function printTopAccountBalances(count: number, blockHeight: number) {
|
29 | 30 | const db = await PgDataStore.connect(true);
|
30 | 31 |
|
31 |
| - console.log(`Calculating balances for top ${count} accounts at block height ${blockHeight}...`); |
| 32 | + const heightText = blockHeight == 0 ? 'chain tip' : `block height ${blockHeight}`; |
| 33 | + console.log(`Calculating balances for top ${count} accounts at ${heightText}...`); |
32 | 34 | const blockInfo = await db.query(async client => {
|
33 | 35 | const result = await client.query<BlockInfo>(
|
34 | 36 | `
|
@@ -95,10 +97,16 @@ async function printTopAccountBalances(count: number, blockHeight: number) {
|
95 | 97 | await Promise.all(dbBalances.concat(nodeBalances));
|
96 | 98 |
|
97 | 99 | const tabularData: TableCellValue[][] = [
|
98 |
| - ['event count', 'address', 'api balance', 'node balance'], |
| 100 | + ['event count', 'address', 'api balance', 'node balance', 'delta'], |
99 | 101 | ];
|
100 | 102 | addressBalances.forEach(item => {
|
101 |
| - tabularData.push([item.count, item.address, item.apiBalance, item.nodeBalance]); |
| 103 | + tabularData.push([ |
| 104 | + item.count, |
| 105 | + item.address, |
| 106 | + item.apiBalance, |
| 107 | + item.nodeBalance, |
| 108 | + bigint.abs((item.apiBalance ?? BigInt(0)) - (item.nodeBalance ?? BigInt(0))), |
| 109 | + ]); |
102 | 110 | });
|
103 | 111 | console.log(table(tabularData));
|
104 | 112 |
|
|
0 commit comments