@@ -21,6 +21,7 @@ import { constants } from '../core/index.mjs'
21
21
import { BaseCommand } from './base.mjs'
22
22
import * as flags from './flags.mjs'
23
23
import * as prompts from './prompts.mjs'
24
+ import { getNodeAccountMap } from '../core/constants.mjs'
24
25
25
26
export class RelayCommand extends BaseCommand {
26
27
constructor ( opts ) {
@@ -29,9 +30,10 @@ export class RelayCommand extends BaseCommand {
29
30
if ( ! opts || ! opts . profileManager ) throw new MissingArgumentError ( 'An instance of core/ProfileManager is required' , opts . downloader )
30
31
31
32
this . profileManager = opts . profileManager
33
+ this . accountManager = opts . accountManager
32
34
}
33
35
34
- async prepareValuesArg ( valuesFile , nodeIDs , chainID , relayRelease , replicaCount , operatorID , operatorKey ) {
36
+ async prepareValuesArg ( valuesFile , nodeIDs , chainID , relayRelease , replicaCount , operatorID , operatorKey , namespace ) {
35
37
let valuesArg = ''
36
38
if ( valuesFile ) {
37
39
valuesArg += this . prepareValuesFiles ( valuesFile )
@@ -43,7 +45,11 @@ export class RelayCommand extends BaseCommand {
43
45
valuesArg += this . prepareValuesFiles ( profileValuesFile )
44
46
}
45
47
46
- valuesArg += ` --set config.MIRROR_NODE_URL=${ constants . FULLSTACK_DEPLOYMENT_CHART } -rest`
48
+ valuesArg += ` --set config.MIRROR_NODE_URL=http://${ constants . FULLSTACK_DEPLOYMENT_CHART } -rest`
49
+ valuesArg += ` --set config.MIRROR_NODE_URL_WEB3=http://${ constants . FULLSTACK_DEPLOYMENT_CHART } -web3`
50
+ valuesArg += ' --set config.MIRROR_NODE_AGENT_CACHEABLE_DNS=false'
51
+ valuesArg += ' --set config.MIRROR_NODE_RETRY_DELAY=2001'
52
+ valuesArg += ' --set config.MIRROR_NODE_GET_CONTRACT_RESULTS_DEFAULT_RETRIES=21'
47
53
48
54
if ( chainID ) {
49
55
valuesArg += ` --set config.CHAIN_ID=${ chainID } `
@@ -69,12 +75,30 @@ export class RelayCommand extends BaseCommand {
69
75
throw new MissingArgumentError ( 'Node IDs must be specified' )
70
76
}
71
77
78
+ const networkJsonString = await this . prepareNetworkJsonString ( nodeIDs , namespace )
79
+ valuesArg += ` --set config.HEDERA_NETWORK='${ networkJsonString } '`
80
+ return valuesArg
81
+ }
82
+
83
+ // created a json string to represent the map between the node keys and their ids
84
+ // output example '{"node-1": "0.0.3", "node-2": "0.004"}'
85
+ async prepareNetworkJsonString ( nodeIDs = [ ] , namespace ) {
86
+ if ( ! nodeIDs ) {
87
+ throw new MissingArgumentError ( 'Node IDs must be specified' )
88
+ }
89
+
90
+ const networkIds = { }
91
+ const accountMap = getNodeAccountMap ( nodeIDs )
92
+
93
+ const networkNodeServicesMap = await this . accountManager . getNodeServiceMap ( namespace )
72
94
nodeIDs . forEach ( nodeID => {
73
- const networkKey = `network-${ nodeID . trim ( ) } -0:50211`
74
- valuesArg += ` --set config.HEDERA_NETWORK.${ networkKey } =0.0.3`
95
+ const nodeName = networkNodeServicesMap . get ( nodeID ) . nodeName
96
+ const haProxyGrpcPort = networkNodeServicesMap . get ( nodeID ) . haProxyGrpcPort
97
+ const networkKey = `network-${ nodeName } :${ haProxyGrpcPort } `
98
+ networkIds [ networkKey ] = accountMap . get ( nodeID )
75
99
} )
76
100
77
- return valuesArg
101
+ return JSON . stringify ( networkIds )
78
102
}
79
103
80
104
prepareReleaseName ( nodeIDs = [ ] ) {
@@ -145,7 +169,8 @@ export class RelayCommand extends BaseCommand {
145
169
ctx . config . relayRelease ,
146
170
ctx . config . replicaCount ,
147
171
ctx . config . operatorId ,
148
- ctx . config . operatorKey
172
+ ctx . config . operatorKey ,
173
+ ctx . config . namespace
149
174
)
150
175
}
151
176
} ,
0 commit comments