Skip to content

Commit

Permalink
Merge pull request #1024 from ExchangeUnion/fix/blockheight-undefined
Browse files Browse the repository at this point in the history
fix: blockheight prop of `undefined` in GetInfo
  • Loading branch information
sangaman authored Jun 11, 2019
2 parents a76d752 + eedb4c2 commit 13a5db5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/grpc/GrpcService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ class GrpcService {
return lnd;
});
const lndMap = response.getLndMap();
for (const currency in getInfoResponse.lnd) {
lndMap.set(currency, getLndInfo(getInfoResponse.lnd[currency]!));
}
getInfoResponse.lnd.forEach((lndInfo, currency) => {
lndMap.set(currency, getLndInfo(lndInfo));
});

if (getInfoResponse.raiden) {
const raiden = new xudrpc.RaidenInfo();
Expand Down
2 changes: 0 additions & 2 deletions lib/lndclient/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,3 @@ export type LndLogger = {
debug: Function,
trace: Function,
};

export type LndInfos = { [currency: string]: LndInfo | undefined };
2 changes: 1 addition & 1 deletion lib/service/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type XudInfo = {
numPeers: number;
numPairs: number;
orders: { peer: number, own: number};
lnd: { [currency: string]: LndInfo | undefined };
lnd: Map<string, LndInfo>;
raiden?: RaidenInfo;
};

Expand Down
16 changes: 9 additions & 7 deletions lib/swaps/SwapClientManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Config from '../Config';
import SwapClient from './SwapClient';
import LndClient from '../lndclient/LndClient';
import { LndLogger, LndInfos } from '../lndclient/types';
import { LndLogger, LndInfo } from '../lndclient/types';
import RaidenClient from '../raidenclient/RaidenClient';
import Logger, { Loggers } from '../Logger';
import { errors } from './errors';
Expand Down Expand Up @@ -169,19 +169,21 @@ class SwapClientManager extends EventEmitter {
* @returns A promise that resolves to an object containing lnd
* clients' info, throws otherwise.
*/
public getLndClientsInfo = async (): Promise<LndInfos> => {
const lndInfos: LndInfos = {};
public getLndClientsInfo = async () => {
const lndInfos = new Map<string, LndInfo>();
// TODO: consider maintaining this list of pubkeys
// (similar to how we're maintaining the list of raiden currencies)
// rather than determining it dynamically when needed. The benefits
// would be slightly improved performance.
const getInfoPromises: Promise<void>[] = [];
for (const [currency, swapClient] of this.swapClients.entries()) {
if (isLndClient(swapClient)) {
lndInfos[currency] = swapClient.isDisabled()
? undefined
: await swapClient.getLndInfo();
if (isLndClient(swapClient) && !swapClient.isDisabled()) {
getInfoPromises.push(swapClient.getLndInfo().then((lndInfo) => {
lndInfos.set(currency, lndInfo);
}));
}
}
await Promise.all(getInfoPromises);
return lndInfos;
}

Expand Down

0 comments on commit 13a5db5

Please sign in to comment.