chore: node info cleanup

This commit is contained in:
AP 2020-01-12 13:28:17 +01:00
parent 74969fd3b6
commit e444705882
2 changed files with 32 additions and 68 deletions

View file

@ -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 },
};
},
});

View file

@ -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);