@@ -43,6 +43,15 @@ type NetworkTemplate struct {
43
43
Genesis gen.GenesisData
44
44
Nodes []remote.NodeConfigGoal
45
45
Consensus config.ConsensusProtocols
46
+ kmdConfig TemplateKMDConfig
47
+ }
48
+
49
+ // TemplateKMDConfig is a subset of the kmd configuration that can be overridden in the network template
50
+ // by using OverrideKmdConfig TemplateOverride opts.
51
+ // The reason why config.KMDConfig cannot be used directly is that it contains DataDir field which is
52
+ // is not known until the template instantiation.
53
+ type TemplateKMDConfig struct {
54
+ SessionLifetimeSecs uint64
46
55
}
47
56
48
57
var defaultNetworkTemplate = NetworkTemplate {
@@ -133,13 +142,13 @@ func (t NetworkTemplate) createNodeDirectories(targetFolder string, binDir strin
133
142
}
134
143
135
144
var kmdDir string
136
- if len ( cfg . KmdJSONOverride ) > 0 {
145
+ if ( t . kmdConfig != TemplateKMDConfig {}) {
137
146
kmdDir = filepath .Join (nodeDir , libgoal .DefaultKMDDataDir )
138
147
err = os .MkdirAll (kmdDir , 0700 ) // kmd requires 700 permissions
139
148
if err != nil {
140
149
return
141
150
}
142
- err = createKMDConfigFile (cfg , kmdDir )
151
+ err = createKMDConfigFile (t . kmdConfig , kmdDir )
143
152
if err != nil {
144
153
return
145
154
}
@@ -268,15 +277,6 @@ func (t NetworkTemplate) Validate() error {
268
277
}
269
278
}
270
279
271
- // Validate KmdJSONOverride decoding
272
- for _ , cfg := range t .Nodes {
273
- kmdconf := kmdconfig.KMDConfig {}
274
- err := decodeJSONOverride (cfg .KmdJSONOverride , & kmdconf )
275
- if err != nil {
276
- return fmt .Errorf ("invalid template: unable to decode KmdJSONOverride: %w" , err )
277
- }
278
- }
279
-
280
280
// Follow nodes cannot be relays
281
281
// Relays cannot have peer list
282
282
for _ , cfg := range t .Nodes {
@@ -368,12 +368,8 @@ func createConfigFile(node remote.NodeConfigGoal, configFile string, numNodes in
368
368
return cfg , cfg .SaveToFile (configFile )
369
369
}
370
370
371
- func createKMDConfigFile (node remote. NodeConfigGoal , kmdDir string ) error {
371
+ func createKMDConfigFile (kmdConfig TemplateKMDConfig , kmdDir string ) error {
372
372
cfg := kmdconfig .DefaultConfig (kmdDir )
373
- err := decodeJSONOverride (node .KmdJSONOverride , & cfg )
374
- if err != nil {
375
- return err
376
- }
377
-
373
+ cfg .SessionLifetimeSecs = kmdConfig .SessionLifetimeSecs
378
374
return kmdconfig .SaveKMDConfig (kmdDir , cfg )
379
375
}
0 commit comments