MCPcopy Create free account
hub / github.com/Sifchain/sifnode / replaceConfigTOML

Method replaceConfigTOML

tools/sifgen/node/node.go:310–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

308}
309
310func (n *Node) replaceConfigTOML() error {
311 config, err := n.parseConfigTOML()
312 if err != nil {
313 return err
314 }
315
316 file, err := os.Create(n.CLI.ConfigFilePath())
317 if err != nil {
318 return err
319 }
320
321 if !n.Standalone {
322 addressList := []string{n.PeerAddress}
323 config.P2P.PersistentPeers = strings.Join(addressList[:], ",")
324 }
325
326 if n.IPAddr != "" {
327 config.P2P.ExternalAddress = fmt.Sprintf("%v:%v", n.IPAddr, common.P2PPort)
328 }
329
330 config.RPC.CorsAllowedOrigins = []string{"*"}
331 config.RPC.CorsAllowedHeaders = []string{"*"}
332 config.P2P.MaxNumInboundPeers = common.MaxNumInboundPeers
333 config.P2P.MaxNumOutboundPeers = common.MaxNumOutboundPeers
334 config.P2P.AllowDuplicateIP = common.AllowDuplicateIP
335
336 if err := toml.NewEncoder(file).Encode(config); err != nil {
337 return err
338 }
339
340 if err := file.Close(); err != nil {
341 return err
342 }
343
344 return nil
345}
346
347func (n *Node) replaceAppTOML() error {
348 config, err := n.parseAppTOML()

Callers 2

networkGenesisMethod · 0.95
seedGenesisMethod · 0.95

Calls 3

parseConfigTOMLMethod · 0.95
ConfigFilePathMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected