Skip to content

Commit

Permalink
wsUrl is added to NodeModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Baha committed Nov 17, 2021
1 parent 1d54e26 commit 2d1d3b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/core/database/entities/NodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export class NodeModel {
public readonly networkType: NetworkType,
public readonly publicKey?: string,
public nodePublicKey?: string,
public readonly wsUrl?: string,
) {}
}
11 changes: 7 additions & 4 deletions src/services/NodeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class NodeService {
true,
n.publicKey,
n.apiStatus?.nodePublicKey,
n.apiStatus.webSocket.url,
),
);
} catch (error) {
Expand All @@ -105,11 +106,11 @@ export class NodeService {

private async getNodeModelByMethod(
networkType: NetworkType,
nodeGetter: (string) => Promise<NodeApiNodeInfo>,
param: string,
nodeGetter: (param: string) => Promise<NodeApiNodeInfo>,
paramValue: string,
): Promise<NodeModel> {
try {
const nodeInfo = await nodeGetter(param);
const nodeInfo = await nodeGetter(paramValue);
if (!nodeInfo) {
return undefined;
}
Expand All @@ -120,6 +121,7 @@ export class NodeService {
true,
nodeInfo.publicKey,
nodeInfo.apiStatus?.nodePublicKey,
nodeInfo.apiStatus?.webSocket?.url,
);
} catch (error) {
// proceed to return
Expand Down Expand Up @@ -164,8 +166,9 @@ export class NodeService {
isDefault: boolean | undefined = undefined,
publicKey?: string,
nodePublicKey?: string,
wsUrl?: string,
): NodeModel {
return new NodeModel(url, friendlyName, isDefault, networkType, publicKey, nodePublicKey);
return new NodeModel(url, friendlyName, isDefault, networkType, publicKey, nodePublicKey, wsUrl);
}

public loadNodes(profile: ProfileModel): NodeModel[] {
Expand Down

0 comments on commit 2d1d3b5

Please sign in to comment.