@@ -11,14 +11,17 @@ import {EnvoyProxyComponent} from './components/envoy_proxy_component.js';
11
11
import { ConsensusNodeComponent } from './components/consensus_node_component.js' ;
12
12
import { MirrorNodeExplorerComponent } from './components/mirror_node_explorer_component.js' ;
13
13
import {
14
+ type ClusterRef ,
14
15
type Component ,
16
+ type ComponentName ,
15
17
type ComponentsDataStructure ,
16
18
type IConsensusNodeComponent ,
17
19
type IRelayComponent ,
18
- type ComponentName ,
19
20
type NamespaceNameAsString ,
20
21
} from './types.js' ;
21
22
import { type ToObject , type Validate } from '../../../types/index.js' ;
23
+ import type { NodeAlias } from '../../../types/aliases.js' ;
24
+ import { Templates } from '../../templates.js' ;
22
25
23
26
/**
24
27
* Represent the components in the remote config and handles:
@@ -232,29 +235,24 @@ export class ComponentsDataWrapper implements Validate, ToObject<ComponentsDataS
232
235
}
233
236
234
237
public static initializeWithNodes (
235
- nodeAliases : string [ ] ,
236
- cluster : string ,
238
+ nodeAliasesByCluster : Record < ClusterRef , NodeAlias [ ] > ,
237
239
namespace : NamespaceNameAsString ,
238
240
) : ComponentsDataWrapper {
239
241
const consensusNodeComponents : Record < ComponentName , ConsensusNodeComponent > = { } ;
240
- nodeAliases . forEach ( ( alias , index ) => {
241
- consensusNodeComponents [ alias ] = new ConsensusNodeComponent (
242
- alias ,
243
- cluster ,
244
- namespace ,
245
- ConsensusNodeStates . REQUESTED ,
246
- index ,
247
- ) ;
242
+
243
+ Object . entries ( nodeAliasesByCluster ) . forEach ( ( [ clusterRef , nodeAliases ] ) => {
244
+ nodeAliases . forEach ( nodeAlias => {
245
+ consensusNodeComponents [ nodeAlias ] = new ConsensusNodeComponent (
246
+ nodeAlias ,
247
+ clusterRef ,
248
+ namespace ,
249
+ ConsensusNodeStates . REQUESTED ,
250
+ Templates . nodeIdFromNodeAlias ( nodeAlias ) ,
251
+ ) ;
252
+ } ) ;
248
253
} ) ;
249
- const componentDataWrapper = new ComponentsDataWrapper (
250
- undefined ,
251
- undefined ,
252
- undefined ,
253
- undefined ,
254
- consensusNodeComponents ,
255
- undefined ,
256
- ) ;
257
- return componentDataWrapper ;
254
+
255
+ return new ComponentsDataWrapper ( undefined , undefined , undefined , undefined , consensusNodeComponents , undefined ) ;
258
256
}
259
257
260
258
/** checks if component exists in the respective group */
0 commit comments