From e4447058826dbadff7888ca0afe71ac7bd742026 Mon Sep 17 00:00:00 2001 From: AP Date: Sun, 12 Jan 2020 13:28:17 +0100 Subject: [PATCH] chore: node info cleanup --- src/schemaTypes/query/info/nodeInfo.ts | 79 +++++++++----------------- src/schemas/query/general/nodeInfo.ts | 21 ++----- 2 files changed, 32 insertions(+), 68 deletions(-) diff --git a/src/schemaTypes/query/info/nodeInfo.ts b/src/schemaTypes/query/info/nodeInfo.ts index c07f5a47..464dd1c4 100644 --- a/src/schemaTypes/query/info/nodeInfo.ts +++ b/src/schemaTypes/query/info/nodeInfo.ts @@ -1,57 +1,30 @@ import { - GraphQLObjectType, - GraphQLBoolean, - GraphQLString, - GraphQLList -} from "graphql"; -import { GraphQLInt } from "graphql"; + GraphQLObjectType, + GraphQLBoolean, + GraphQLString, + GraphQLList, +} from 'graphql'; +import { GraphQLInt } from 'graphql'; export const NodeInfoType = new GraphQLObjectType({ - name: "nodeInfoType", - fields: () => { - return { - chains: { - type: new GraphQLList(GraphQLString) - }, - color: { - type: GraphQLString - }, - activeChannelsCount: { - type: GraphQLInt - }, - alias: { - type: GraphQLString - }, - currentBlockHash: { - type: GraphQLString - }, - currentBlockHeight: { - type: GraphQLBoolean - }, - isSyncedToChain: { - type: GraphQLBoolean - }, - isSyncedToGraph: { - type: GraphQLBoolean - }, - latestBlockAt: { - type: GraphQLString - }, - peersCount: { - type: GraphQLInt - }, - pendingChannelsCount: { - type: GraphQLInt - }, - publicKey: { - type: GraphQLString - }, - uris: { - type: new GraphQLList(GraphQLString) - }, - version: { - type: GraphQLString - } - }; - } + name: 'nodeInfoType', + fields: () => { + return { + chains: { type: new GraphQLList(GraphQLString) }, + color: { type: GraphQLString }, + active_channels_count: { type: GraphQLInt }, + closed_channels_count: { type: GraphQLInt }, + alias: { type: GraphQLString }, + current_block_hash: { type: GraphQLString }, + current_block_height: { type: GraphQLBoolean }, + is_synced_to_chain: { type: GraphQLBoolean }, + is_synced_to_graph: { type: GraphQLBoolean }, + latest_block_at: { type: GraphQLString }, + peers_count: { type: GraphQLInt }, + pending_channels_count: { type: GraphQLInt }, + public_key: { type: GraphQLString }, + uris: { type: new GraphQLList(GraphQLString) }, + version: { type: GraphQLString }, + }; + }, }); diff --git a/src/schemas/query/general/nodeInfo.ts b/src/schemas/query/general/nodeInfo.ts index 2ef9a3da..f9dba8ef 100644 --- a/src/schemas/query/general/nodeInfo.ts +++ b/src/schemas/query/general/nodeInfo.ts @@ -1,4 +1,4 @@ -import { getWalletInfo } from 'ln-service'; +import { getWalletInfo, getClosedChannels } from 'ln-service'; import { logger } from '../../../helpers/logger'; import { NodeInfoType } from '../../../schemaTypes/query/info/nodeInfo'; import { requestLimiter } from '../../../helpers/rateLimiter'; @@ -34,21 +34,12 @@ export const getNodeInfo = { const info: NodeInfoProps = await getWalletInfo({ lnd, }); + const closedChannels: { channels: [] } = await getClosedChannels({ + lnd, + }); return { - chains: info.chains, - color: info.color, - activeChannelsCount: info.active_channels_count, - alias: info.alias, - currentBlockHash: info.current_block_hash, - currentBlockHeight: info.current_block_height, - isSyncedToChain: info.is_synced_to_chain, - isSyncedToGraph: info.is_synced_to_graph, - latestBlockAt: info.latest_block_at, - peersCount: info.peers_count, - pendingChannelsCount: info.pending_channels_count, - publicKey: info.public_key, - uris: info.uris, - version: info.version, + ...info, + closed_channels_count: closedChannels.channels.length, }; } catch (error) { logger.error('Error getting node info: %o', error);